-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (21 loc) · 760 Bytes
/
index.js
File metadata and controls
29 lines (21 loc) · 760 Bytes
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
const express = require('express')
const cors = require('cors')
const app = express()
const writeIndexHTML = require('./scripts/markdownToHTML')
const PORT = process.env.PORT || 3000
// Use public folder as static
app.use(express.static('public'))
// Write the index.html file with markdown data
writeIndexHTML()
// Allow Cross Origin Resource Sharing from any origin
app.use(cors({origin: '*'}))
// Use the router to assign .js files to each route
app.use('/api/lists', require('./router/lists.js'))
app.use('/api/validate', require('./router/validate.js'))
// Handle 404 error:
app.use((req, res) => {
res.status(404).json({
error: '404 error, nothing here'
})
})
app.listen(PORT, () => console.log(`Listening app at port ${ PORT }`))