Added async validation

This commit is contained in:
Dries Augustyns
2025-12-01 15:21:12 +01:00
parent 1f3978e89c
commit 361ff6fede
20 changed files with 240 additions and 109 deletions
+4 -2
View File
@@ -1,10 +1,11 @@
import {Controller, Middleware, Post} from '@overnightjs/core';
import type {Request, Response} from 'express';
import type {NextFunction, Request, Response} from 'express';
import multer from 'multer';
import type {AuthResponse} from '../middleware/auth.js';
import {requireAuth} from '../middleware/auth.js';
import * as S3Service from '../services/S3Service.js';
import {CatchAsync} from '../utils/asyncHandler.js';
// Configure multer for file uploads (memory storage)
const upload = multer({
@@ -32,7 +33,8 @@ export class Uploads {
*/
@Post('image')
@Middleware([requireAuth, upload.single('image')])
public async uploadImage(req: Request, res: Response) {
@CatchAsync
public async uploadImage(req: Request, res: Response, next: NextFunction) {
const auth = res.locals.auth as AuthResponse;
try {