Merge pull request 'deps-fix' () from deps-fix into staging

Reviewed-on: 
This commit is contained in:
Otto 2025-03-27 08:53:11 +00:00
commit f6689dd3b2

@ -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)