-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
66 lines (59 loc) · 1.34 KB
/
index.ts
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
import { Adapter as IAdapter } from '../src/adapter';
import Adapter from '../src/decorators/Adapter';
import After from '../src/decorators/After';
import Before from '../src/decorators/Before';
import Headers from '../src/decorators/Headers';
import Get from '../src/decorators/HTTPMethods/Get';
import Post from '../src/decorators/HTTPMethods/Post';
import JSONP from '../src/decorators/JSONP';
import { makeBody, Prefix, _prefixSymbol } from '../src/index';
const adapter: IAdapter = {
name: 'testAdapter',
async handler(config: any) {
console.log('async handler(config: any) {');
console.log(config);
},
}
@Prefix('https://test.com')
@Before(() => {
console.log('class Before');
})
@After(() => {
console.log('each after');
})
class Request {
@Get('123/:id')
// @Headers('Auth', '123')
@Headers(() => {
return {
x: '2'
}
})
@Before((): boolean => {
console.log('before');
return true;
})
@Adapter(adapter)
// @JSONP()
@After<{a: 1}>((a, b) => {
console.log('after');
})
public test() {
return makeBody({
placeholders: {id: 1},
query: {b: 2},
params: {c: 3},
onProgress: () => {
},
jsonp: '123',
});
}
}
const req = new Request();
// console.log((req as any)[_prefixSymbol])
req.test();
// console.log(body({
// params: {
// a: 1,
// }
// }));