-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
34 lines (26 loc) · 980 Bytes
/
server.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 path = require('path');
const express = require('express');
const session = require('express-session');
const passport = require('./config/passport');
const db = require('./models');
const app = express();
// Konfigurasi awal express
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
app.use(express.static(path.join(__dirname, 'public')));
// Konfigurasi express agar bisa menangani authentifikasi
app.use(
session({ secret: 'FP PemWeb', resave: true, saveUninitialized: true }),
);
app.use(passport.initialize());
app.use(passport.session());
// Konfigurasi express agar bisa render view engine
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// Konfigurasi routing
require('./routes/homepage')(app);
require('./routes/login')(app);
require('./routes/signup')(app);
require('./routes/profile')(app);
require('./routes/products')(app);
db.sequelize.sync().then(() => app.listen(process.env.PORT || 3000));