-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
25 lines (23 loc) · 936 Bytes
/
app.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import express from 'express';
import recipeRouter from './routers/recipeRouters'; // Update the import statement to use recipeRouter
import { AppDataSource } from './data-source'; // Ensure this is correctly imported
import likeRouter from './routers/likeRouters';
import commentRoutes from './routers/commentRouter';
const app = express();
app.use(express.json()); // Middleware to parse JSON bodies
app.use('/api/recipes', recipeRouter); // Use the recipe router for routes starting with /api/recipes
app.use('/recipes', likeRouter);
app.use('/api', commentRoutes);
// Initialize the data source
AppDataSource.initialize()
.then(() => {
console.log('Data Source has been initialized!');
})
.catch((err) => {
console.error('Error during Data Source initialization', err);
});
// Start the server
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});