-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
33 lines (25 loc) · 849 Bytes
/
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
"use strict";
const express = require('express')
const logger = require('morgan')
const path = require('path')
const bodyParser = require('body-parser')
const apiRoute = require('./routes/apiRoute.js')
const app = express()
const PORT = process.env.PORT || process.argv[2] || 3000
const env = process.env.NODE_ENV || 'dev';
const DEV = env==='dev';
// set up some logging
app.use( logger( DEV ? 'dev' : 'common') );
// we're only going to accept json
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
// set up ejs to render the views
app.set('view engine', 'ejs')
// app.set('views', path.join(__dirname, 'views'));
/* ROUTES */
app.use('/api', apiRoute)
app.use(express.static(path.join(__dirname, 'dist')))
// set up server
app.listen(PORT, function(){
console.log("server up and running on port", PORT)
})