0f7af70b90
Updated Docker configuration, refactored middleware for improved error handling, and restructured account, order, plan, profile, and support modules, including their routes, services, and validations. Enhanced email processing queues and utilities for token generation, pagination, and response management to streamline the application architecture and enhance maintainability.
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
import cookieParser from 'cookie-parser';
|
|
import cors from 'cors';
|
|
import express from 'express';
|
|
import swaggerJSDoc from 'swagger-jsdoc';
|
|
import swaggerUi from "swagger-ui-express";
|
|
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';
|
|
// define app
|
|
const app = express();
|
|
const swaggerSpec = swaggerJSDoc(swaggerOptions);
|
|
app.use("/docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
|
|
// middleware
|
|
app.use(cors({
|
|
origin: ["http://localhost:3000"],
|
|
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, res) => {
|
|
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;
|