cleanup
This commit is contained in:
parent
6169274fe1
commit
866922e0f2
8 changed files with 32 additions and 40 deletions
|
@ -1,25 +1,29 @@
|
|||
const express = require("express");
|
||||
const cors = require("cors");
|
||||
const { PrismaClient } = require("@prisma/client");
|
||||
const appRoutes = require("./routes/appRoutes");
|
||||
|
||||
const app = express();
|
||||
const cors = require("cors");
|
||||
const port = 3000;
|
||||
|
||||
// Middleware
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
|
||||
// Routes
|
||||
app.use("/api", appRoutes);
|
||||
|
||||
// Prisma client initialization
|
||||
const port = process.env.PORT || 3000;
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
module.exports = { app, prisma };
|
||||
function setupMiddleware(app) {
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
app.use("/api", appRoutes);
|
||||
}
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Server is running on http://localhost:${port}`);
|
||||
});
|
||||
setupMiddleware(app);
|
||||
|
||||
// Start server
|
||||
async function startServer() {
|
||||
try {
|
||||
app.listen(port);
|
||||
console.log(`Server is running on http://localhost:${port}`);
|
||||
} catch (error) {
|
||||
console.error("Error starting the server:", error);
|
||||
}
|
||||
}
|
||||
|
||||
process.on("SIGINT", async () => {
|
||||
try {
|
||||
|
@ -31,3 +35,7 @@ process.on("SIGINT", async () => {
|
|||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
startServer();
|
||||
|
||||
module.exports = { app, prisma };
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
// todo
|
Loading…
Add table
Add a link
Reference in a new issue