Commit dcae3430 authored by “Yevgeniy's avatar “Yevgeniy

#23 added routers for Projects

parent 945f33fa
import express,{Router, Request, Response} from 'express';
import {User} from '../models/User';
import {Project} from '../models/Project';
import {myDataSource} from '../app-data-source';
import { nanoid } from 'nanoid';
const router:Router = express.Router();
const dataSource = myDataSource;
router.get('/',async (req:Request, res:Response) => {
const projects:Project[]|undefined = await dataSource.manager.find(Project)
return res.send({projects})
})
router.get("/:project_id",async (req:Request, res:Response) => {
const project : Project|null= await dataSource.manager.findOneBy(Project, {
id: req.params.project_id
})
if (!project) return res.status(404).send({Message:'no info in the base'})
return res.send({project})
})
export default router;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment