-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserver.js
38 lines (25 loc) · 1 KB
/
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
35
36
37
require( 'dotenv' ).config() // looks for .env ; process.env gets it's values
const express = require('express')
const apiRouter = require('./app/router/router')
const app = express()
const db = require('./app/models')
const fs = require('fs')
// const https = require('https')
// const privateKey = fs.readFileSync('./ssl/server.key', 'utf-8')
// const certificate = fs.readFileSync('./ssl/server.crt', 'utf-8')
const { pathToFileURL } = require('url')
// var credentials = {key: privateKey, cert: certificate}
const PORT = process.env.PORT || 8080
// for parsing incoming POST data
app.use(express.urlencoded({ extended: true }))
app.use(express.json())
// for serving all the normal html
app.use( express.static('public') )
// for routes
apiRouter(app)
// const httpsServer = https.createServer(credentials, app)
db.sequelize.sync({force:true}).then(function(){
app.listen(PORT, function() {
console.log( `Database (name=${process.env.DB_NAME}); Serving app on: http://localhost:${PORT}` )
})
})