-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.mjs
More file actions
27 lines (21 loc) · 793 Bytes
/
server.mjs
File metadata and controls
27 lines (21 loc) · 793 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
import express from 'express'
import { resolve, dirname } from 'path'
import { fileURLToPath } from 'url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const app = express()
const port = +process.env.PORT || 80
import cookieParser from 'cookie-parser'
import bodyParser from 'body-parser'
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.urlencoded({ extended: false }))
app.use(express.json())
app.use(cookieParser())
import routes from './lib/routes.mjs'
app.use(routes)
app.use(express.static(resolve(__dirname, 'lib/static')))
app.set('view engine', 'ejs')
app.set('views', resolve(__dirname, 'lib/templates'))
app.get('/ping', (_, res) => res.end('pong'))
app.listen(port, '0.0.0.0', () => {
console.log(`listening on http://localhost:${port}`)
})