-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
39 lines (33 loc) · 1.08 KB
/
Copy pathapp.js
File metadata and controls
39 lines (33 loc) · 1.08 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
const express = require('express')
const path = require('path')
const bodyParser = require('body-parser')
const db = require('./db')
const machine = require('./machine')
const env = require('./env')
const app = express()
app.use(require('cors')())
app.use(require('morgan')('dev'))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
app.use('/public', express.static(path.join(__dirname, 'public')))
app.use('/dist', express.static(path.join(__dirname, 'dist')))
app.use('/api', require('./api'))
app.get('/*', (req, res, next) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'))
})
app.use((err, req, res, next) => {
console.log(err)
res.status(err.status || 500).send(err)
})
const port = process.env.PORT || 3000
db.sync()
// .then(() => {
// return db.models.MachineData.findAll()
// .then(samples => {
// samples.forEach(data => {
// machine.addDocument(data.phrase, data.category)
// })
// machine.train()
// })
// })
.then(() => app.listen(port, () => console.log(`listening on port ${port}`)))