Untitled
unknown
plain_text
9 months ago
776 B
3
Indexable
import express, { Request, Response, NextFunction } from "express";
import cors from "cors";
import containerRoutes from "./routes/container.routes";
import { AppError } from "./types/error";
const app = express();
const PORT = process.env.PORT || 5000;
app.use(cors());
app.use(express.json());
app.get("/", (req: Request, res: Response) => {
res.send("API up and running 🚀");
});
app.use("/api/containers", containerRoutes);
app.use((err: AppError, req: Request, res: Response, next: NextFunction) => {
console.error(err.stack);
const status = err.status || 500;
res.status(status).json({ error: err.message || "Something went wrong!" });
});
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});
Editor is loading...
Leave a Comment