2026-04-02 21:27:09 +06:00
|
|
|
import cookieParser from 'cookie-parser';
|
|
|
|
|
import cors from 'cors';
|
|
|
|
|
import express, { Request, Response } from 'express';
|
|
|
|
|
import swaggerJSDoc from 'swagger-jsdoc';
|
|
|
|
|
import swaggerUi from "swagger-ui-express";
|
2026-04-21 03:12:39 +06:00
|
|
|
import globalErrorHandler from './app/middlewares/global_error_handler.js';
|
|
|
|
|
import notFound from './app/middlewares/not_found_api.js';
|
|
|
|
|
import appRouter from './routes.js';
|
|
|
|
|
import { swaggerOptions } from './swaggerOptions.js';
|
2026-04-02 21:27:09 +06:00
|
|
|
|
|
|
|
|
// define app
|
|
|
|
|
const app = express()
|
|
|
|
|
const swaggerSpec = swaggerJSDoc(swaggerOptions);
|
|
|
|
|
app.use("/docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
|
|
|
|
|
|
|
|
|
|
// middleware
|
|
|
|
|
app.use(cors({
|
2026-05-23 20:12:09 +06:00
|
|
|
origin: ["http://localhost:5173","https://quick-launch-techzaa.vercel.app"],
|
2026-04-02 21:27:09 +06:00
|
|
|
methods: ["GET", "POST", "PATCH", "DELETE", "PUT"],
|
|
|
|
|
credentials: true
|
|
|
|
|
}))
|
|
|
|
|
app.use(express.json({ limit: "100mb" }))
|
|
|
|
|
app.use(express.raw())
|
|
|
|
|
app.use(cookieParser())
|
|
|
|
|
app.use(express.urlencoded({ extended: true }));
|
|
|
|
|
app.use("/api", appRouter)
|
|
|
|
|
|
|
|
|
|
// stating point
|
|
|
|
|
app.get('/', (req: Request, res: Response) => {
|
|
|
|
|
res.status(200).json({
|
|
|
|
|
status: 'success',
|
|
|
|
|
message: 'Server is running successful !!',
|
|
|
|
|
data: null,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// global error handler
|
|
|
|
|
app.use(globalErrorHandler);
|
|
|
|
|
app.use(notFound);
|
|
|
|
|
|
|
|
|
|
// export app
|
|
|
|
|
export default app;
|