feat: ngebuat API tambahan dan upload middleware

This commit is contained in:
Rafi Athallah
2026-06-01 10:19:57 +07:00
parent 49cfd7b4b6
commit 1bd74f4b46
16 changed files with 1880 additions and 13 deletions
+9 -1
View File
@@ -1,3 +1,4 @@
import path from 'path';
import express, { Request, Response, NextFunction } from 'express';
import cors from 'cors';
import helmet from 'helmet';
@@ -8,10 +9,17 @@ import { errorHandler, CustomError } from './middleware/errorHandler';
const app = express();
app.use(helmet());
app.use(cors());
app.use(cors({
origin: true,
credentials: true,
}));
app.use(morgan('dev'));
// File upload statis biar bisa diakses lewat /uploads atau /api/uploads
app.use('/uploads', express.static(path.join(__dirname, '../uploads')));
app.use('/api/uploads', express.static(path.join(__dirname, '../uploads')));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));