-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestApp.cjs
48 lines (42 loc) · 1016 Bytes
/
testApp.cjs
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
40
41
42
43
44
45
46
47
48
const express = require('express')
const app = express()
const port = 3000
const path = require('path')
app.get('/', (req, res) => {
const file = path.join(__dirname, 'example/index.html')
res.sendFile(file, {
headers: {
'Content-Type': 'text/html'
}
})
})
app.get('/dist/molamola.mjs', (req, res) => {
const file = path.join(__dirname, '/dist/molamola.mjs')
res.sendFile(file, {
headers: {
'Content-Type': 'application/javascript'
}
})
})
app.get('/dist/molamola.iife.js', (req, res) => {
const file = path.join(__dirname, '/dist/molamola.iife.js')
res.sendFile(file, {
headers: {
'Content-Type': 'application/javascript'
}
})
})
let count = 0
app.post('/form-post', express.json(), (req, res) => {
res.send({
status: 'ok',
message: 'success',
redirect: '/?redirect-' + (++count)
})
})
app.post('/lookup', express.json(), (req, res) => {
res.send({
found: req.body.value === 'match'
})
})
app.listen(port, () => console.log(`Example app listening on port ${port}!`))