Compare commits
2 Commits
89a861a2dd
...
999d493c68
Author | SHA1 | Date | |
---|---|---|---|
999d493c68 | |||
7a9e12e62d |
@ -1,5 +1,5 @@
|
||||
import { Request, Response } from '@types/express/index.d.ts';
|
||||
import Transaction from './Transaction.ts';
|
||||
import { Request, Response } from '@types/express';
|
||||
import Transaction from './Transaction';
|
||||
|
||||
export default abstract class Handler {
|
||||
private _handlers: array<Function> = [];
|
||||
|
@ -1,5 +1,5 @@
|
||||
export default class Session {
|
||||
public user_id: number;
|
||||
public user_name: string;
|
||||
public permissions: Array<string>;
|
||||
public user_id?: number;
|
||||
public user_name?: string;
|
||||
public permissions?: Array<string>;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ export default class Status {
|
||||
return this._status;
|
||||
}
|
||||
|
||||
public set status (value: number): void {
|
||||
public set status (value: number) {
|
||||
this._status = value;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Request, Response } from '@types/express/index.d.ts';
|
||||
import Status from './Status.ts';
|
||||
import Session from './Session.ts';
|
||||
import { Request, Response } from 'express';
|
||||
import Status from './Status';
|
||||
import Session from './Session';
|
||||
|
||||
export default class Transaction {
|
||||
/* private */
|
||||
@ -12,7 +12,7 @@ export default class Transaction {
|
||||
public get req (): Request { return this._req; }
|
||||
public get res (): Response { return this._res; }
|
||||
public get status (): Status { return this._status; }
|
||||
public session: Session;
|
||||
public session?: Session;
|
||||
|
||||
/* constructor */
|
||||
public constructor (req: Request, res: Response) {
|
||||
@ -22,8 +22,8 @@ export default class Transaction {
|
||||
}
|
||||
|
||||
/* methods */
|
||||
public finalize (): void {
|
||||
if (this._status.has_status ())
|
||||
public finalize (data: any): void {
|
||||
if (this._status.has_status)
|
||||
this._res.status (this.status.status);
|
||||
this._res.end (data);
|
||||
}
|
14
lib/index.ts
14
lib/index.ts
@ -1,5 +1,5 @@
|
||||
import { App } from '@types/express/index.d.ts';
|
||||
import Handler from './classes/Handler.ts';
|
||||
import { App } from 'express';
|
||||
import Handler from './classes/Handler';
|
||||
|
||||
/**
|
||||
* register an array of handlers to an express app
|
||||
@ -9,13 +9,13 @@ import Handler from './classes/Handler.ts';
|
||||
*/
|
||||
export default function load_handlers (
|
||||
app: App,
|
||||
handlers: array<Handler>
|
||||
handlers: Array<Handler>
|
||||
): void {
|
||||
for (const h of handlers)
|
||||
app.use (h.path, h.run_http_handler);
|
||||
}
|
||||
|
||||
export * from './classes/Session.ts';
|
||||
export * from './classes/Status.ts';
|
||||
export * from './classes/Transaction.ts';
|
||||
export * from './classes/Handler.ts';
|
||||
export * from './classes/Session';
|
||||
export * from './classes/Status';
|
||||
export * from './classes/Transaction';
|
||||
export * from './classes/Handler';
|
||||
|
@ -5,7 +5,7 @@
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"test": "nyc ava",
|
||||
"lint": "eslint .",
|
||||
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue,.mjs",
|
||||
"ci": "yarn --frozen-lockfile && node jenkins.js",
|
||||
"mutate": "stryker run"
|
||||
},
|
||||
@ -22,6 +22,7 @@
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ava/typescript": "^1.1.1",
|
||||
"@scode/eslint-config-ts": "^1.0.12",
|
||||
"@stryker-mutator/core": "^3.1.0",
|
||||
"@stryker-mutator/javascript-mutator": "^3.1.0",
|
||||
|
17
test/.eslintrc.js
Normal file
17
test/.eslintrc.js
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
env: {
|
||||
commonjs: true,
|
||||
es6: true,
|
||||
node: true
|
||||
},
|
||||
extends: [
|
||||
'@scode/eslint-config-ts'
|
||||
]
|
||||
}
|
5
test/main.ts
Normal file
5
test/main.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import test from 'ava';
|
||||
|
||||
test ('testing', (t) => {
|
||||
t.is (true, true);
|
||||
});
|
25
yarn.lock
25
yarn.lock
@ -2,6 +2,13 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@ava/typescript@^1.1.1":
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@ava/typescript/-/typescript-1.1.1.tgz#3dcaba3aced8026fdb584d927d809752854dc6e6"
|
||||
integrity sha512-KbLUAe2cWXK63WLK6LnOJonjwEDU/8MNXCOA1ooX/YFZgKRmeAD1kZu+2K0ks5fnOCEcckNQAooyBNGdZUmMQA==
|
||||
dependencies:
|
||||
escape-string-regexp "^2.0.0"
|
||||
|
||||
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.8.3":
|
||||
version "7.8.3"
|
||||
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.8.3.tgz#33e25903d7481181534e12ec0a25f16b6fcf419e"
|
||||
@ -256,17 +263,17 @@
|
||||
integrity sha512-T2YeiJIiok+LDpsTh6/IVLxCl8/NyHOM0zeyeoo54TR1Dwp0M1u0CI38vua0S1GGuyPo+l5KLGl5lQjvx7++Ng==
|
||||
|
||||
"@scode/eslint-config-es6@^1.0.1":
|
||||
version "1.0.12"
|
||||
resolved "https://npm.scode.ovh/@scode%2feslint-config-es6/-/eslint-config-es6-1.0.12.tgz#c2a983b6ea82ac5c815ed5e2b6710f0abbf786d9"
|
||||
integrity sha512-Qd0HoZ3AJa1NfDlI+m/60UNvWEW9lfqX/I0sJ8S6zAhwMHO4ETjE5wTPJJFKRt4zrLmTxFiA+qAElaYSP+aaiQ==
|
||||
version "1.0.14"
|
||||
resolved "https://npm.scode.ovh/@scode%2feslint-config-es6/-/eslint-config-es6-1.0.14.tgz#3b1f023b6ac653e29eb12f1ce4ec9103e0066be0"
|
||||
integrity sha512-uVSO52wbpoynUBFI6nkRh5d5DD1Pqto7Alic9cr5WEyDF6ihScy0bTQBrdRGHRHVlvMYrVCNNK9gRvSwPdjatA==
|
||||
dependencies:
|
||||
"@scode/eslint-config" "^2.0.1"
|
||||
eslint-plugin-import "^2.20.1"
|
||||
|
||||
"@scode/eslint-config-ts@^1.0.12":
|
||||
version "1.0.12"
|
||||
resolved "https://npm.scode.ovh/@scode%2feslint-config-ts/-/eslint-config-ts-1.0.12.tgz#d6779d41a804b4c47e8878a73fce98ac473bfd99"
|
||||
integrity sha512-vo5cuc7sggDakWC1xDMF+7m5OaQl1kOHMIFA0w3B3YD3JOP6mVLBozT2f1CgYV3umfm2JBva6LUiHv0yY4UVOA==
|
||||
version "1.0.13"
|
||||
resolved "https://npm.scode.ovh/@scode%2feslint-config-ts/-/eslint-config-ts-1.0.13.tgz#0c58638617217b4907949e8ff601608703ca9c7b"
|
||||
integrity sha512-mfrby0ffIlEAYG03L/JIsKphyM+Wa7jyEESGN8pcHtw/sBMxGijzLfaxpYdzGn6GcYHSlsD1TG8CUt65+RGtCw==
|
||||
dependencies:
|
||||
"@scode/eslint-config-es6" "^1.0.1"
|
||||
"@typescript-eslint/eslint-plugin" "^2.26.0"
|
||||
@ -421,9 +428,9 @@
|
||||
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
|
||||
|
||||
"@types/node@*":
|
||||
version "13.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.11.0.tgz#390ea202539c61c8fa6ba4428b57e05bc36dc47b"
|
||||
integrity sha512-uM4mnmsIIPK/yeO+42F2RQhGUIs39K2RFmugcJANppXe6J1nvH87PvzPZYpza7Xhhs8Yn9yIAVdLZ84z61+0xQ==
|
||||
version "13.11.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.11.1.tgz#49a2a83df9d26daacead30d0ccc8762b128d53c7"
|
||||
integrity sha512-eWQGP3qtxwL8FGneRrC5DwrJLGN4/dH1clNTuLfN81HCrxVtxRjygDTUoZJ5ASlDEeo0ppYFQjQIlXhtXpOn6g==
|
||||
|
||||
"@types/normalize-package-data@^2.4.0":
|
||||
version "2.4.0"
|
||||
|
Reference in New Issue
Block a user