This repository was archived by the owner on May 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathapp.js
More file actions
53 lines (46 loc) · 1.24 KB
/
app.js
File metadata and controls
53 lines (46 loc) · 1.24 KB
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
45
46
47
48
49
50
51
52
53
/**
* Module dependencies.
*/
const express = require('express')
const bodyParser = require('body-parser')
const chalk = require('chalk')
// const dotenv = require('dotenv');
const passport = require('passport')
const cors = require('cors')
const expressValidator = require('express-validator')
/**
* Load environment variables from .env file, where API keys and passwords are configured.
*/
// dotenv.load({ path: '.env.example' });
/**
* Controllers (route handlers).
*/
const userController = require('./controllers/user')
const app = express()
/**
* Express configuration.
*/
app.set('host', '0.0.0.0')
app.set('port', process.env.PORT || 8080)
app.set('json spaces', 2) // number of spaces for indentation
app.use(cors())
app.use(bodyParser.json())
app.use(expressValidator())
app.use(passport.initialize())
app.use(passport.session())
app.post('/login', userController.postLogin)
app.post('/signup', userController.postSignup)
app.get('/webhook', userController.getWebhook)
app.get('/jwks', userController.getJwks)
/**
* Start Express server.
*/
app.listen(app.get('port'), () => {
console.log(
'%s App is running at http://localhost:%d in %s mode',
chalk.green('✓'),
app.get('port'),
app.get('env')
)
})
module.exports = app