diff options
author | ab <abdullah_ahmed@brown.edu> | 2019-08-12 12:24:51 -0400 |
---|---|---|
committer | ab <abdullah_ahmed@brown.edu> | 2019-08-12 12:24:51 -0400 |
commit | 73ac98d53b80230bb085d71b61254f6c24a3e397 (patch) | |
tree | 43b13e482c29ce6a3db1108aca056581495303d7 /src/Utils.ts | |
parent | b8ab5a823ae22b021c09dfd713b77211a51b3eae (diff) | |
parent | 3aea955ae56c1aa0611de09c4a013e9dc5c86c42 (diff) |
merged
Diffstat (limited to 'src/Utils.ts')
-rw-r--r-- | src/Utils.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Utils.ts b/src/Utils.ts index 8df67df5d..959b89fe5 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -3,6 +3,7 @@ import v5 = require("uuid/v5"); import { Socket } from 'socket.io'; import { Message } from './server/Message'; import { RouteStore } from './server/RouteStore'; +import requestPromise = require('request-promise'); export class Utils { @@ -132,6 +133,8 @@ export function WithKeys(obj: any, keys: string[], addKeyFunc?: (dup: any) => vo return dup; } +export function numberRange(num: number) { return Array.from(Array(num)).map((v, i) => i); } + export function returnTrue() { return true; } export function returnFalse() { return false; } @@ -140,6 +143,8 @@ export function returnOne() { return 1; } export function returnZero() { return 0; } +export function returnEmptyString() { return ""; } + export function emptyFunction() { } export type Without<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; @@ -171,4 +176,14 @@ export namespace JSONUtils { return results; } +} + +export function PostToServer(relativeRoute: string, body: any) { + let options = { + method: "POST", + uri: Utils.prepend(relativeRoute), + json: true, + body: body + }; + return requestPromise.post(options); }
\ No newline at end of file |