import { Request , Response , NextFunction } from 'express' ; import Controller , { Methods } from '../typings/Controller' ; import Token from '../services/TokenService' ; import db from '../models/index' ; export default class RoomController extends Controller { path = '/room' ; routes = [ { path : '/add-rep' , method : Methods . POST , handler : this . handleAddRep , localMiddleware : [ Token . verify ] } ] ; async handleAddRep ( req , res , next ) { try { const { valueToAdd , username } = req . body ; console . log ( valueToAdd , username ) ; const user = await db . User . findOne ( { where : { username : username } } ) ; await db . User . update ( { rep : user ! . rep + valueToAdd } , { where : { username : username } } ) ; } catch ( e ) { console . log ( e ) ; super . sendError ( res ) ; } } }