diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7a7bb90..4b1c9b7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -35,4 +35,5 @@ jobs: corepack enable yarn install --frozen-lockfile yarn build + yarn db:migrate pm2 restart /root/apps/challenge-logger/ecosystem.config.js \ No newline at end of file diff --git a/src/api/user/index.ts b/src/api/user/index.ts index dada2c5..9a95f94 100644 --- a/src/api/user/index.ts +++ b/src/api/user/index.ts @@ -6,10 +6,18 @@ const route = express.Router(); route.use(authMiddleware); -route.get('/test', (req: Request, res: Response) => { +route.get('/', (req: Request, res: Response) => { const user = (req as AuthorizedRequest).user; - res.status(200).send({ message: `Hello, ${user.email}` }); + return res.status(200).json({ + type: 'USER_FETCHED', + statusCode: 200, + message: 'User fetched successfully', + isSuccess: true, + details: { + user, + }, + }); }); export default route; diff --git a/src/index.ts b/src/index.ts index e63cdc8..39ce083 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,6 +21,13 @@ app.get('/healthcheck', (req: Request, res: Response) => { return res.status(200).send('OK'); }); +app.all('*', (req: Request, res: Response) => { + return res.status(404).json({ + error: true, + message: 'Endpoint not found.', + }); +}); + app.listen(PORT, async () => { console.info(`Server is running on port ${PORT}`);