-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (26 loc) · 991 Bytes
/
index.js
File metadata and controls
34 lines (26 loc) · 991 Bytes
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 bodyParser = require('body-parser');
const passport = require('passport');
const config = require('./config/index.json');
const cors = require('cors');
// connect to the database and load models
require('./models').connect(config.dbUri);
const app = express();
app.use(cors());
// tell the app to parse HTTP body messages
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
// pass the passport middleware
app.use(passport.initialize());
// load passport strategies
const localSignupStrategy = require('./passport/local-signup');
const localLoginStrategy = require('./passport/local-login');
passport.use('local-signup', localSignupStrategy);
passport.use('local-login', localLoginStrategy);
// routes
const authRoutes = require('./routes/auth');
app.use('/auth', authRoutes);
// start the server
app.listen(1234, () => {
console.log('Server is running on http://localhost:1234 or http://127.0.0.1:1234');
});