[update] - latest code

This commit is contained in:
Swapnil Bendal
2024-12-10 17:13:27 +05:30
parent 70ed1e2782
commit ca6d4551ca
16 changed files with 3999 additions and 434 deletions

View File

@@ -3,10 +3,11 @@ import express, { Application, NextFunction, Request, Response } from "express";
import config from "./config/config";
import morgan from "./config/morgan";
import path from 'path';
import ApiError from './utils/helper/ApiError';
import { errorConverter, errorHandler } from './middleware/error';
import logger from './config/logger';
import productRouter from "./routes/productRoutes";
import ApiError from './utils/helper/ApiError';
import error from './middleware/error';
import routes from './routes';
class App {
private app: Application;
@@ -30,7 +31,7 @@ class App {
}
private initializeRoutes(): void {
this.app.use('/api', productRouter);
this.app.use('/api', routes);
// Define our routes
this.app.use((req: Request, res: Response, next: NextFunction) => {
next(new ApiError(404, "Not found"));
@@ -38,8 +39,8 @@ class App {
}
private initializeErrorHandling(): void {
this.app.use(errorConverter);
this.app.use(errorHandler);
this.app.use(error.errorConverter);
this.app.use(error.errorHandler);
}
public listen(port: number): ReturnType<typeof this.app.listen> {