-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction2.ts
More file actions
40 lines (29 loc) · 960 Bytes
/
function2.ts
File metadata and controls
40 lines (29 loc) · 960 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
30
31
32
33
34
35
36
37
38
39
40
import { Storage } from 'znk-infra';
var ApiBuilder = require("claudia-api-builder");
var api = new ApiBuilder();
api.get('/rate', async function (request) {
request.pathParams.id;
let log = 'log: ';
let storage = new Storage();
await storage.addItem('item1');
log += '1 - ' + new Date().getTime();
await storage.addItem('item2');
log += '2 - ' + new Date().getTime();
await storage.addItem('item3');
log += '3 - ' + new Date().getTime();
let res = await storage.getItem(1);
log += '4 - ' + new Date().getTime();
log += '5 - ' + res;
return "welcome to rate api, log=" + log;
});
api.get('/rate/{id}', function (request) {
var rateId = request.pathParams.id;
return "get rate by ID " +rateId ;
});
api.post('/rate', function (request) {
'use strict';
var rateName = request.body.name;
return 'posted new rate, ' + rateName;
// return dynamo result directly
});
module.exports = api;