1234567891011121314151617181920212223242526 |
- import {clone, extend} from "@util/JsonToolkit";
- const request = require('supertest');
- const globalAny: any = global;
- export const DatetimeRegex = /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$/;
- export const DateRegex = /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/;
- const json: any = {
- ver: '1.0',
- app_id: 'test-app-id',
- timestamp: new Date().getTime(),
- token: 'token',
- __cachedData: {},
- }
- export const api = async (path: string, data: any): Promise<any> => {
- try {
- let req = clone(json);
- req.__cachedData.user_id = globalAny.user_id;
- req = extend(req, {data: data});
- let response = await request(globalAny.app)
- .post(path).send(req);
- return response.body;
- } catch (e) {
- console.error('Could not request', e);
- }
- };
|