-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (29 loc) · 1.13 KB
/
index.js
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
26
27
28
29
30
31
32
33
34
35
const express = require('express');
const bodyParser = require('body-parser');
const sequelize = require('./config/database');
const { swaggerServe, swaggerSetup } = require("./config/swagger.config");
const dotenv = require('dotenv').config();
const app = express();
// Test the database connection
sequelize.authenticate()
.then(() => {
console.log('Connection has been established successfully.');
})
.catch(err => {
console.error('Unable to connect to the database:', err);
});
sequelize.sync();
// Middleware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// Routes
const organizationRouter = require('./route/organization.route')
const itemRouter = require('./route/item.route')
const pricingRouter = require('./route/pricing.route')
app.get('/', (req, res) => res.status(200).send('Welcome To Food Delivery App'));
app.use('/api/organization', organizationRouter);
app.use('/api/item',itemRouter);
app.use('/api/pricing',pricingRouter);
app.use("/api-docs", swaggerServe, swaggerSetup)
app.listen(process.env.SERVER_PORT, () => console.log("Server is running: " + process.env.SERVER_PORT))
module.exports = app;