-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·45 lines (39 loc) · 1.2 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
35
36
37
38
39
40
41
42
43
44
45
// ***require / import***
const path = require( 'path' );
const express = require( 'express' );
const qrcode = require( 'qrcode' );
const dotenv = require( 'dotenv' );
const authenticate = require( './routes/authenticate' );
const api_generate = require( './routes/generate' );
const cors = require( 'express-cors' );
// ***INIT***
// starting express
const app = express();
// set static content location
express.static.mime.default_type = "text/css";
app.use( express.static( path.join( __dirname, 'static' ) ) )
// Load .env
dotenv.load();
// View engine (pug)
app.set( 'views', path.join( __dirname, 'views' ) );
app.set( 'view engine', 'pug' );
app.use( cors() )
// {
// allowedOrigins: [
// 'authentic8-ui.herokuapp.com', 'localhost:3120', 'localhost:3110', '127.0.0.1:8887'
// ]
// } ) )
console.log( process.env.APPVERSION );
// ***routes***
app.get( '/', ( req, res ) => {
res.render( 'index', {
version: process.env.APPVERSION,
env: process.env.ENV
} );
} )
app.use( '/userservices', authenticate );
app.use( '/api', api_generate );
// ***start listening***
app.listen( ( process.env.PORT || 3120 ), _ => {
console.log( 'Setting up add on port ' + ( process.env.PORT || 3000 ) );
} );