From c045555e00a926e3506a80824d43ffc887e196f5 Mon Sep 17 00:00:00 2001 From: Kevin J Hoerr Date: Sun, 10 Nov 2019 13:44:09 -0500 Subject: Set up initial project Initializes project with TypeScript, ExpressJS, and Badgen. Defines initial (v1) request paths: GET /bash GET /v1/:org/:repo/:branch.svg GET /v1/:org/:repo/:branch.html GET /v1/:org/:repo/:branch/:commit.svg GET /v1/:org/:repo/:branch/:commit.html POST /v1/:org/:repo/:branch/:commit.html?token=&format= Also sets up interfaces for defining multiple formats. Tarpaulin is defined but not implemented. All requests (aside from GET /bash) return 501 NOT IMPLEMENTED. A global TOKEN is expected for POST request. This can and should be adapted to assigning tokens per repository, though this may require verification from the originating repository or administrative designation. --- formats.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 formats.ts (limited to 'formats.ts') diff --git a/formats.ts b/formats.ts new file mode 100644 index 0000000..b5a24bf --- /dev/null +++ b/formats.ts @@ -0,0 +1,33 @@ +interface Format { + parse_coverage: (file: Document) => number; +} + +interface FormatList { + [key: string]: Format +} + +interface FormatObj { + formats: FormatList, + list_formats: () => string[], + get_format: (format: string) => Format, +} + +const FormatsObj: FormatObj = { + formats: { + tarpaulin: { + parse_coverage: (file: Document) => { + return 0.0; + } + }, + }, + + list_formats: function () { + return Object.keys(this.formats); + }, + + get_format: function (format: string) { + return this.formats[format]; + } +} + +export default FormatsObj; \ No newline at end of file -- cgit