feat(auth): add processing user requests

This commit is contained in:
Karol Sójko
2022-11-02 13:23:49 +01:00
parent f2415527f0
commit 2255f856f9
32 changed files with 443 additions and 93 deletions
@@ -0,0 +1,24 @@
import { Request, Response } from 'express'
import { inject } from 'inversify'
import { controller, BaseHttpController, results, httpPost } from 'inversify-express-utils'
import TYPES from '../../Bootstrap/Types'
import { UserRequestsController } from '../../Controller/UserRequestsController'
@controller('/users/:userUuid/requests')
export class InversifyExpressAuthController extends BaseHttpController {
constructor(@inject(TYPES.UserRequestsController) private userRequestsController: UserRequestsController) {
super()
}
@httpPost('/', TYPES.ApiGatewayAuthMiddleware)
async submitRequest(request: Request, response: Response): Promise<results.JsonResult> {
const result = await this.userRequestsController.submitUserRequest({
requestType: request.body.requestType,
userUuid: response.locals.user.uuid,
userEmail: response.locals.user.email,
})
return this.json(result.data, result.status)
}
}