-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.js
More file actions
29 lines (24 loc) · 771 Bytes
/
Copy pathapp.js
File metadata and controls
29 lines (24 loc) · 771 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 app = require('express')();
const basicAuth = require('express-basic-auth');
const pass = process.env.BASIC_PASSWORD || "secret";
app.start = (port, context, callback) => {
app.context = context
app.quit = callback;
return app.listen(port, () => {
console.log('App listening on port %d', port);
})
}
app.use(basicAuth({
users: {'admin': pass},
challenge: true,
realm: 'lambda-ngrok'
}))
app.get('/bye', (req, res) => {
app.quit(req, res);
})
app.get('/', (req, res) => {
const now = new Date();
const remain = app.context.getRemainingTimeInMillis();
res.send('Current Time: ' + now + '<br/>Remain: ' + remain / 1000 + '<br/><a href="/bye">Quit</a>');
})
module.exports = app;