1
0
forked from noxious/server

DB updates, removed all CRUD func's from repositories as prisma's func's are sufficient and reduces boilerplate.

This commit is contained in:
2024-07-22 02:16:35 +02:00
parent 6131a8455a
commit 34d6aa3d1b
23 changed files with 196 additions and 217 deletions

View File

@ -11,7 +11,6 @@ import path from 'path'
import { TAsset } from './Types'
import tileRepository from '../repositories/TileRepository'
import objectRepository from '../repositories/ObjectRepository'
import spriteRepository from '../repositories/SpriteRepository'
async function addHttpRoutes(app: Application) {
app.get('/assets', async (req: Request, res: Response) => {
@ -69,8 +68,7 @@ async function addHttpRoutes(app: Application) {
const userService = new UserService()
const user = await userService.login(username, password)
if (user) {
//test
if (user && typeof user !== 'boolean') {
const token = jwt.sign({ id: user.id }, config.JWT_SECRET, { expiresIn: '4h' })
return res.status(200).json({ token })
}
@ -91,8 +89,7 @@ async function addHttpRoutes(app: Application) {
const user = await userService.register(username, password)
if (user) {
const token = jwt.sign({ id: user.id }, config.JWT_SECRET, { expiresIn: '4h' })
return res.status(200).json({ token })
return res.status(200)
}
return res.status(400).json({ message: 'Failed to register user' })