-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathapp.js
44 lines (33 loc) · 1.05 KB
/
app.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
36
37
38
39
40
41
42
43
44
const path = require('path');
const express = require('express');
var cors = require('cors')
const sequelize = require('./util/database');
const User = require('./models/users');
const Expense = require('./models/expenses');
const Order = require('./models/orders');
const userRoutes = require('./routes/user')
const expenseRoutes = require('./routes/expense')
const purchaseRoutes = require('./routes/purchase')
const premiumFeatureRoutes = require('./routes/premiumFeature')
const app = express();
const dotenv = require('dotenv');
// get config vars
dotenv.config();
app.use(cors());
// app.use(bodyParser.urlencoded()); ////this is for handling forms
app.use(express.json()); //this is for handling jsons
app.use('/user', userRoutes)
app.use('/expense', expenseRoutes)
app.use('/purchase', purchaseRoutes)
app.use('/premium', premiumFeatureRoutes)
User.hasMany(Expense);
Expense.belongsTo(User);
User.hasMany(Order);
Order.belongsTo(User);
sequelize.sync()
.then(() => {
app.listen(3000);
})
.catch(err => {
console.log(err);
})