diff --git a/src/routes/users.router.ts b/src/routes/users.router.ts index 73c0b4a..b7e6b29 100644 --- a/src/routes/users.router.ts +++ b/src/routes/users.router.ts @@ -1,6 +1,5 @@ // External Dependencies import express, { Request, Response } from 'express' -import { ObjectId } from 'mongodb' import { collections } from '../services/database.service' import User from '../models/user' @@ -15,6 +14,7 @@ usersRouter.get('/', async (_req: Request, res: Response) => { const users = await collections.users?.find({}).toArray() res.status(200).send(users) + // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (error: any) { res.status(500).send(error.message) } @@ -26,11 +26,14 @@ usersRouter.post('/', async (req: Request, res: Response) => { const newUser = req.body as User const result = await collections.users?.insertOne(newUser) - result - ? res - .status(201) - .send(`Successfully created a new user with id ${result.insertedId}`) - : res.status(500).send('Failed to create a new user.') + if (result) { + res + .status(201) + .send(`Successfully created a new user with id ${result.insertedId}`) + } else { + res.status(500).send('Failed to create a new user.') + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (error: any) { console.error(error) res.status(400).send(error.message)