-
Notifications
You must be signed in to change notification settings - Fork 0
/
adm.js
76 lines (65 loc) · 1.34 KB
/
adm.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var express = require('express')
var utils = require('./utils.js')
var db = require('./db.js')
var router = express.Router()
router.use('*', (req, res, next) => {
if (req.locals.user == 'flo') {
next()
} else {
res.json({
err: {
type: 'internal',
code: 4,
msg: 'not_authorized'
}
})
}
})
router.post('/app', (req, res) => {
var token = utils.uid(256)
res.json({
token: token
})
db.addApplication(req.body.user, token, req.body.name, req.body.description)
})
router.get('/app', (req, res) => {
db.getApplications((err, l) => {
res.json(l)
})
})
router.get('/recvmsgs', (req, res) => {
db.getMsgsRecv((err, l) => {
res.json(l)
})
})
router.get('/recvcalls', (req, res) => {
db.getCallsRecv((err, l) => {
res.json(l)
})
})
router.get('/sentmsgs', (req, res) => {
db.getMsgs(req.query.user, (err, l) => {
res.json(l)
})
})
router.get('/sentcalls', (req, res) => {
db.getCalls(req.query.user, (err, l) => {
res.json(l)
})
})
router.get('/subscriptions', (req, res) => {
db.getSubscriptions(req.query.user, (err, l) => {
res.json(l)
})
})
router.get('/transactions', (req, res) => {
db.getTransactions(req.query.user, (err, l) => {
res.json(l)
})
})
router.get('/stopped', (req, res) => {
db.getStopped((err, l) => {
res.json(l)
})
})
module.exports = router