- use this
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
EXPOSE 5000
CMD ["npm", "start"]
- FIX THE SECOND PROBLEM
export const errorHandler = (
err,
req,
res,
next
) => {
console.error(err);
res.status(err.status || 500).json({
success: false,
message: err.message || "Internal Server Error",
});
};
-
Change to moderate structure
Modern Structure
src/
├── api/
│ ├── controllers/
│ ├── services/
│ ├── routes/
│ └── middlewares/
│
├── config/
├── database/
├── modules/
│ ├── github/
│ ├── auth/
│ └── analytics/
│
├── utils/
├── types/
└── app.ts
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
EXPOSE 5000
CMD ["npm", "start"]
export const errorHandler = (
err,
req,
res,
next
) => {
console.error(err);
res.status(err.status || 500).json({
success: false,
message: err.message || "Internal Server Error",
});
};
Change to moderate structure
Modern Structure
src/
├── api/
│ ├── controllers/
│ ├── services/
│ ├── routes/
│ └── middlewares/
│
├── config/
├── database/
├── modules/
│ ├── github/
│ ├── auth/
│ └── analytics/
│
├── utils/
├── types/
└── app.ts