-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
34 lines (28 loc) · 1.01 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
const express = require('express');
const sequelize = require('./config/database');
const bodyParser = require('body-parser');
const cors = require('cors');
const authRouter = require('./routes/auth')
const titlesRouter = require('./routes/titles')
const usersRouter = require('./routes/users')
const userActivitiesRouter = require('./routes/userActivities')
require('dotenv').config()
const app = express();
const corsOptions = {
origin: 'http://localhost:3000',
}
app.use(cors(corsOptions))
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use('/api/auth', authRouter);
app.use('/api/titles', titlesRouter);
app.use('/api/users', usersRouter);
app.use('/api/activity', userActivitiesRouter);
sequelize.sync({ force: false })
.then(async () => {
console.log(`Database & tables created!`);
console.log('Postgress Connected');
})
.catch(err => console.log(err));
const port = process.env.PORT || 8000;
app.listen(port, () => console.log('Server running...'));