-
Notifications
You must be signed in to change notification settings - Fork 1
/
bundle.js
58 lines (47 loc) · 1.58 KB
/
bundle.js
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
49
50
51
52
53
54
55
56
57
58
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('express')) :
typeof define === 'function' && define.amd ? define(['express'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.express));
})(this, (function (express) { 'use strict';
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
// import bodyParser from 'body-parser'
const bodyParser = require('body-parser');
// import onDuty from '../src/onDuty'
const onDuty = require('./src/onDuty');
const app = express__default["default"]();
const port = 30678;
app.use(bodyParser.json());
app.get('/health', (req, res) => {
res.end('onDuty is online!');
});
app.post('/test', (req, res) => {
onDuty.test().then(response => {
res.type('json').send({
...response,
data: req.body
});
}).catch(error => {
res.status(500).end(error);
});
});
app.post('/punch', (req, res) => {
console.log('Start Punch');
onDuty.config(req.body);
onDuty.start().then(response => {
console.log('response', response);
res.type('json').send({
...response,
user: {
...req.body
}
});
}).catch(error => {
console.log('error', error);
res.status(500).end(error);
});
});
app.listen(port, () => {
console.log(`app listening at http://localhost:${port}`);
});
}));