-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb.others.js
More file actions
104 lines (100 loc) · 2.71 KB
/
Copy pathweb.others.js
File metadata and controls
104 lines (100 loc) · 2.71 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const { Op, Model } = require('sequelize');
const util = require('util');
const HE = require('he');
const createError = require('http-errors');
const Router = require('koa-router');
const router = new Router({
prefix: '',
});
router.get('/', async (ctx, next) => {
try {
// let user = await ctx.UserBiz.create(Date.now());
ctx.state.where = {
is: 'adc',
};
await ctx.render('index.html', {
test: { time: new Date().getTime() },
});
} catch (e) {
ctx.response.body = e.message;
}
await next();
});
router.get('/wechat', async (ctx, next) => {
try {
// let user = await ctx.UserBiz.create(Date.now());
ctx.state.where = {
is: 'adc',
};
await ctx.render('index.html', {
test: { time: new Date().getTime() },
});
} catch (e) {
ctx.response.body = e.message;
}
await next();
});
router.get('/socketio', async (ctx, next) => {
try {
ctx.state.where = {
is: 'adc',
};
await ctx.render('socketio.html', {
test: { time: new Date().getTime() },
});
} catch (e) {
ctx.response.body = e.message;
}
await next();
});
router.get('/testmongodb', async (ctx, next) => {
try {
let ttt = new UserSchema({ name: 'ttt' });
let rrr = await ttt.save();
ctx.response.body = JSON.stringify({
name: ttt.name,
test111: true,
api: 'testmongodb',
});
} catch (e) {
ctx.response.body = e.message;
}
await next();
});
router.post('/openapi/xining/alert/test', async (ctx, next) => {
try {
let query = ctx.query;
let headers = ctx.headers;
let body = ctx.request.body;
let details = JSON.parse(HE.decode(body.details));
console.log('value is ', details.Fields.value / 1000000, details);
ctx.response.body = JSON.stringify({
name: 'wl',
test111: true,
api: 'testmongodb',
});
} catch (e) {
throw createError(400, e.message);
}
await next();
});
router.post('/openapi/xining/alert/test2', async (ctx, next) => {
console.log('----------------------------------');
try {
let query = ctx.query;
let headers = ctx.headers;
let body = ctx.request.body;
console.log('body is ', body);
ctx.response.body = JSON.stringify({
name: 'wl',
test111: true,
api: 'testmongodb',
});
} catch (e) {
console.log(e);
throw createError(400, e.message);
// ctx.response.body = e.message;
}
await next();
});
module.exports = router;