[MAJOR][FIRSTCOMMIT] Added basic routes, controllers, repos to kanban service (no postgres yet)

This commit is contained in:
2025-09-27 14:09:35 +05:30
parent f283f6043f
commit fd7ceca2ef
109 changed files with 3554 additions and 444 deletions

View File

@@ -0,0 +1,42 @@
import { Request, Response } from 'express';
import UserRepo from '@src/repos/user.repo';
import { IUser } from '@src/models/user.model';
class UserController {
public getAll = async (req: Request, res: Response) => {
if (req.headers.authorization !== 'Bearer testtoken') {
return res.status(401).json({ error: 'Unauthorized' });
}
const users = await UserRepo.getAll();
return res.status(200).json({ users });
};
public add = async (req: Request, res: Response) => {
if (req.headers.authorization !== 'Bearer testtoken') {
return res.status(401).json({ error: 'Unauthorized' });
}
const user = req.body.user as IUser;
await UserRepo.add(user);
return res.status(201).end();
};
public update = async (req: Request, res: Response) => {
if (req.headers.authorization !== 'Bearer testtoken') {
return res.status(401).json({ error: 'Unauthorized' });
}
const user = req.body.user as IUser;
await UserRepo.update(user);
return res.status(200).end();
};
public delete = async (req: Request, res: Response) => {
if (req.headers.authorization !== 'Bearer testtoken') {
return res.status(401).json({ error: 'Unauthorized' });
}
const id = +req.params.id;
await UserRepo.delete(id);
return res.status(200).end();
};
}
export default new UserController();