Switch to local npm registry publishing and move ts type deps to dev
This commit is contained in:
parent
6aa9250fe9
commit
1c661cee5e
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
.idea
|
.idea
|
||||||
node_modules
|
node_modules
|
||||||
|
dist
|
20
dist/Application.d.ts
vendored
20
dist/Application.d.ts
vendored
@ -1,20 +0,0 @@
|
|||||||
import WebSocketListener from "./WebSocketListener";
|
|
||||||
import ApplicationComponent from "./ApplicationComponent";
|
|
||||||
import Controller from "./Controller";
|
|
||||||
export default abstract class Application {
|
|
||||||
private readonly version;
|
|
||||||
private readonly controllers;
|
|
||||||
private readonly webSocketListeners;
|
|
||||||
private readonly components;
|
|
||||||
private ready;
|
|
||||||
protected constructor(version: string);
|
|
||||||
protected abstract init(): Promise<void>;
|
|
||||||
protected use(thing: Controller | WebSocketListener | ApplicationComponent<any>): void;
|
|
||||||
start(): Promise<void>;
|
|
||||||
stop(): Promise<void>;
|
|
||||||
private routes;
|
|
||||||
getWebSocketListeners(): {
|
|
||||||
[p: string]: WebSocketListener;
|
|
||||||
};
|
|
||||||
isReady(): boolean;
|
|
||||||
}
|
|
140
dist/Application.js
vendored
140
dist/Application.js
vendored
File diff suppressed because one or more lines are too long
10
dist/ApplicationComponent.d.ts
vendored
10
dist/ApplicationComponent.d.ts
vendored
@ -1,10 +0,0 @@
|
|||||||
import { Express, Router } from "express";
|
|
||||||
export default abstract class ApplicationComponent<T> {
|
|
||||||
private val?;
|
|
||||||
abstract start(app: Express, router: Router): Promise<void>;
|
|
||||||
abstract stop(): Promise<void>;
|
|
||||||
protected export(val: T): void;
|
|
||||||
import(): T;
|
|
||||||
protected prepare(name: string, prepare: () => Promise<void>): Promise<void>;
|
|
||||||
protected close(thingName: string, thing: any, fn: Function): Promise<void>;
|
|
||||||
}
|
|
55
dist/ApplicationComponent.js
vendored
55
dist/ApplicationComponent.js
vendored
@ -1,55 +0,0 @@
|
|||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
import Logger from "./Logger";
|
|
||||||
import { sleep } from "./Utils";
|
|
||||||
export default class ApplicationComponent {
|
|
||||||
export(val) {
|
|
||||||
this.val = val;
|
|
||||||
}
|
|
||||||
import() {
|
|
||||||
if (!this.val)
|
|
||||||
throw 'Cannot import if nothing was exported.';
|
|
||||||
return this.val;
|
|
||||||
}
|
|
||||||
prepare(name, prepare) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let err;
|
|
||||||
do {
|
|
||||||
try {
|
|
||||||
yield prepare();
|
|
||||||
err = null;
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
err = e;
|
|
||||||
Logger.error(err, `${name} failed to prepare; retrying in 5s...`);
|
|
||||||
yield sleep(5000);
|
|
||||||
}
|
|
||||||
} while (err);
|
|
||||||
Logger.info(`${name} ready!`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
close(thingName, thing, fn) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
|
||||||
yield new Promise((resolve, reject) => fn.call(thing, (err) => {
|
|
||||||
if (err)
|
|
||||||
reject(err);
|
|
||||||
else
|
|
||||||
resolve();
|
|
||||||
}));
|
|
||||||
Logger.info(`${thingName} closed.`);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
Logger.error(e, `An error occurred while closing the ${thingName}.`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
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lzZTx2b2lkPjtcblxuICAgIHByb3RlY3RlZCBleHBvcnQodmFsOiBUKSB7XG4gICAgICAgIHRoaXMudmFsID0gdmFsO1xuICAgIH1cblxuICAgIHB1YmxpYyBpbXBvcnQoKTogVCB7XG4gICAgICAgIGlmICghdGhpcy52YWwpIHRocm93ICdDYW5ub3QgaW1wb3J0IGlmIG5vdGhpbmcgd2FzIGV4cG9ydGVkLic7XG4gICAgICAgIHJldHVybiB0aGlzLnZhbDtcbiAgICB9XG5cbiAgICBwcm90ZWN0ZWQgYXN5bmMgcHJlcGFyZShuYW1lOiBzdHJpbmcsIHByZXBhcmU6ICgpID0+IFByb21pc2U8dm9pZD4pOiBQcm9taXNlPHZvaWQ+IHtcbiAgICAgICAgbGV0IGVycjtcbiAgICAgICAgZG8ge1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICBhd2FpdCBwcmVwYXJlKCk7XG4gICAgICAgICAgICAgICAgZXJyID0gbnVsbDtcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgICAgICBlcnIgPSBlO1xuICAgICAgICAgICAgICAgIExvZ2dlci5lcnJvcihlcnIsIGAke25hbWV9IGZhaWxlZCB0byBwcmVwYXJlOyByZXRyeWluZyBpbiA1cy4uLmApXG4gICAgICAgICAgICAgICAgYXdhaXQgc2xlZXAoNTAwMCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gd2hpbGUgKGVycik7XG4gICAgICAgIExvZ2dlci5pbmZvKGAke25hbWV9IHJlYWR5IWApO1xuICAgIH1cblxuICAgIHByb3RlY3RlZCBhc3luYyBjbG9zZSh0aGluZ05hbWU6IHN0cmluZywgdGhpbmc6IGFueSwgZm46IEZ1bmN0aW9uKTogUHJvbWlzZTx2b2lkPiB7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICBhd2FpdCBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiBmbi5jYWxsKHRoaW5nLCAoZXJyOiBhbnkpID0+IHtcbiAgICAgICAgICAgICAgICBpZiAoZXJyKSByZWplY3QoZXJyKTtcbiAgICAgICAgICAgICAgICBlbHNlIHJlc29sdmUoKTtcbiAgICAgICAgICAgIH0pKTtcblxuICAgICAgICAgICAgTG9nZ2VyLmluZm8oYCR7dGhpbmdOYW1lfSBjbG9zZWQuYCk7XG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgIExvZ2dlci5lcnJvcihlLCBgQW4gZXJyb3Igb2NjdXJyZWQgd2hpbGUgY2xvc2luZyB0aGUgJHt0aGluZ05hbWV9LmApO1xuICAgICAgICB9XG4gICAgfVxufSJdfQ==
|
|
21
dist/Controller.d.ts
vendored
21
dist/Controller.d.ts
vendored
@ -1,21 +0,0 @@
|
|||||||
import { RequestHandler, Router } from "express";
|
|
||||||
import { PathParams } from "express-serve-static-core";
|
|
||||||
export default abstract class Controller {
|
|
||||||
private static readonly routes;
|
|
||||||
static route(route: string, params?: RouteParams, absolute?: boolean): string;
|
|
||||||
private router?;
|
|
||||||
getGlobalHandlers(): RequestHandler[];
|
|
||||||
hasGlobalHandlers(): boolean;
|
|
||||||
setupGlobalHandlers(router: Router): void;
|
|
||||||
getRoutesPrefix(): string;
|
|
||||||
abstract routes(): void;
|
|
||||||
setupRoutes(router: Router): void;
|
|
||||||
protected use(handler: RequestHandler): void;
|
|
||||||
protected get(path: PathParams, handler: RequestHandler, routeName?: string, ...middlewares: RequestHandler[]): void;
|
|
||||||
protected post(path: PathParams, handler: RequestHandler, routeName?: string, ...middlewares: RequestHandler[]): void;
|
|
||||||
private wrap;
|
|
||||||
private registerRoutes;
|
|
||||||
}
|
|
||||||
export declare type RouteParams = {
|
|
||||||
[p: string]: string;
|
|
||||||
} | string[] | string | number;
|
|
104
dist/Controller.js
vendored
104
dist/Controller.js
vendored
File diff suppressed because one or more lines are too long
28
dist/HttpError.d.ts
vendored
28
dist/HttpError.d.ts
vendored
@ -1,28 +0,0 @@
|
|||||||
import { WrappingError } from "./Utils";
|
|
||||||
export declare abstract class HttpError extends WrappingError {
|
|
||||||
readonly instructions: string;
|
|
||||||
constructor(message: string, instructions: string, cause?: Error);
|
|
||||||
get name(): string;
|
|
||||||
abstract get errorCode(): number;
|
|
||||||
}
|
|
||||||
export declare class BadRequestError extends HttpError {
|
|
||||||
readonly url: string;
|
|
||||||
constructor(message: string, instructions: string, url: string, cause?: Error);
|
|
||||||
get errorCode(): number;
|
|
||||||
}
|
|
||||||
export declare class ForbiddenHttpError extends BadRequestError {
|
|
||||||
constructor(thing: string, url: string, cause?: Error);
|
|
||||||
get errorCode(): number;
|
|
||||||
}
|
|
||||||
export declare class NotFoundHttpError extends BadRequestError {
|
|
||||||
constructor(thing: string, url: string, cause?: Error);
|
|
||||||
get errorCode(): number;
|
|
||||||
}
|
|
||||||
export declare class ServerError extends HttpError {
|
|
||||||
constructor(message: string, cause?: Error);
|
|
||||||
get errorCode(): number;
|
|
||||||
}
|
|
||||||
export declare class ServiceUnavailableHttpError extends ServerError {
|
|
||||||
constructor(message: string, cause?: Error);
|
|
||||||
get errorCode(): number;
|
|
||||||
}
|
|
52
dist/HttpError.js
vendored
52
dist/HttpError.js
vendored
@ -1,52 +0,0 @@
|
|||||||
import { WrappingError } from "./Utils";
|
|
||||||
export class HttpError extends WrappingError {
|
|
||||||
constructor(message, instructions, cause) {
|
|
||||||
super(message, cause);
|
|
||||||
this.instructions = instructions;
|
|
||||||
}
|
|
||||||
get name() {
|
|
||||||
return this.constructor.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export class BadRequestError extends HttpError {
|
|
||||||
constructor(message, instructions, url, cause) {
|
|
||||||
super(message, instructions, cause);
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
get errorCode() {
|
|
||||||
return 400;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export class ForbiddenHttpError extends BadRequestError {
|
|
||||||
constructor(thing, url, cause) {
|
|
||||||
super(`You don't have access to this ${thing}.`, `${url} doesn't belong to *you*.`, url, cause);
|
|
||||||
}
|
|
||||||
get errorCode() {
|
|
||||||
return 403;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export class NotFoundHttpError extends BadRequestError {
|
|
||||||
constructor(thing, url, cause) {
|
|
||||||
super(`${thing.charAt(0).toUpperCase()}${thing.substr(1)} not found.`, `${url} doesn't exist or was deleted.`, url, cause);
|
|
||||||
}
|
|
||||||
get errorCode() {
|
|
||||||
return 404;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export class ServerError extends HttpError {
|
|
||||||
constructor(message, cause) {
|
|
||||||
super(message, `Maybe you should contact us; see instructions below.`, cause);
|
|
||||||
}
|
|
||||||
get errorCode() {
|
|
||||||
return 500;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export class ServiceUnavailableHttpError extends ServerError {
|
|
||||||
constructor(message, cause) {
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
get errorCode() {
|
|
||||||
return 503;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSHR0cEVycm9yLmpzIiwic291cmNlUm9vdCI6Ii4vIiwic291cmNlcyI6WyJIdHRwRXJyb3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFDLGFBQWEsRUFBQyxNQUFNLFNBQVMsQ0FBQztBQUV0QyxNQUFNLE9BQWdCLFNBQVUsU0FBUSxhQUFhO0lBR2pELFlBQVksT0FBZSxFQUFFLFlBQW9CLEVBQUUsS0FBYTtRQUM1RCxLQUFLLENBQUMsT0FBTyxFQUFFLEtBQUssQ0FBQyxDQUFDO1FBQ3RCLElBQUksQ0FBQyxZQUFZLEdBQUcsWUFBWSxDQUFDO0lBQ3JDLENBQUM7SUFFRCxJQUFJLElBQUk7UUFDSixPQUFPLElBQUksQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDO0lBQ2pDLENBQUM7Q0FHSj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CBvciB3YXMgZGVsZXRlZC5gLFxuICAgICAgICAgICAgdXJsLFxuICAgICAgICAgICAgY2F1c2VcbiAgICAgICAgKTtcbiAgICB9XG5cbiAgICBnZXQgZXJyb3JDb2RlKCk6IG51bWJlciB7XG4gICAgICAgIHJldHVybiA0MDQ7XG4gICAgfVxufVxuXG5leHBvcnQgY2xhc3MgU2VydmVyRXJyb3IgZXh0ZW5kcyBIdHRwRXJyb3Ige1xuICAgIGNvbnN0cnVjdG9yKG1lc3NhZ2U6IHN0cmluZywgY2F1c2U/OiBFcnJvcikge1xuICAgICAgICBzdXBlcihtZXNzYWdlLCBgTWF5YmUgeW91IHNob3VsZCBjb250YWN0IHVzOyBzZWUgaW5zdHJ1Y3Rpb25zIGJlbG93LmAsIGNhdXNlKTtcbiAgICB9XG5cbiAgICBnZXQgZXJyb3JDb2RlKCk6IG51bWJlciB7XG4gICAgICAgIHJldHVybiA1MDA7XG4gICAgfVxufVxuXG5leHBvcnQgY2xhc3MgU2VydmljZVVuYXZhaWxhYmxlSHR0cEVycm9yIGV4dGVuZHMgU2VydmVyRXJyb3Ige1xuICAgIGNvbnN0cnVjdG9yKG1lc3NhZ2U6IHN0cmluZywgY2F1c2U/OiBFcnJvcikge1xuICAgICAgICBzdXBlcihtZXNzYWdlLCBjYXVzZSk7XG4gICAgfVxuXG4gICAgZ2V0IGVycm9yQ29kZSgpOiBudW1iZXIge1xuICAgICAgICByZXR1cm4gNTAzO1xuICAgIH1cbn0iXX0=
|
|
18
dist/Logger.d.ts
vendored
18
dist/Logger.d.ts
vendored
@ -1,18 +0,0 @@
|
|||||||
export default class Logger {
|
|
||||||
static silentError(error: Error, ...message: any[]): string;
|
|
||||||
static error(error: Error, ...message: any[]): string;
|
|
||||||
static warn(...message: any[]): void;
|
|
||||||
static info(...message: any[]): void;
|
|
||||||
static debug(...message: any[]): void;
|
|
||||||
static dev(...message: any[]): void;
|
|
||||||
private static log;
|
|
||||||
private constructor();
|
|
||||||
}
|
|
||||||
export declare enum LogLevel {
|
|
||||||
ERROR = 0,
|
|
||||||
WARN = 1,
|
|
||||||
INFO = 2,
|
|
||||||
DEBUG = 3,
|
|
||||||
DEV = 4
|
|
||||||
}
|
|
||||||
export declare type LogLevelKeys = keyof typeof LogLevel;
|
|
111
dist/Logger.js
vendored
111
dist/Logger.js
vendored
File diff suppressed because one or more lines are too long
24
dist/Mail.d.ts
vendored
24
dist/Mail.d.ts
vendored
@ -1,24 +0,0 @@
|
|||||||
import { SentMessageInfo } from "nodemailer";
|
|
||||||
export declare function mailRoute(template: string): string;
|
|
||||||
export default class Mail {
|
|
||||||
private static transporter;
|
|
||||||
private static getTransporter;
|
|
||||||
static prepare(): Promise<void>;
|
|
||||||
static end(): void;
|
|
||||||
static parse(template: string, data: any, textOnly: boolean): string;
|
|
||||||
private readonly template;
|
|
||||||
private readonly options;
|
|
||||||
private readonly data;
|
|
||||||
constructor(template: MailTemplate, data?: {
|
|
||||||
[p: string]: any;
|
|
||||||
});
|
|
||||||
private verifyData;
|
|
||||||
send(...to: string[]): Promise<SentMessageInfo[]>;
|
|
||||||
}
|
|
||||||
export declare class MailTemplate {
|
|
||||||
private readonly _template;
|
|
||||||
private readonly subject;
|
|
||||||
constructor(template: string, subject: (data: any) => string);
|
|
||||||
get template(): string;
|
|
||||||
getSubject(data: any): string;
|
|
||||||
}
|
|
122
dist/Mail.js
vendored
122
dist/Mail.js
vendored
File diff suppressed because one or more lines are too long
10
dist/Pagination.d.ts
vendored
10
dist/Pagination.d.ts
vendored
@ -1,10 +0,0 @@
|
|||||||
import Model from "./db/Model";
|
|
||||||
export default class Pagination<T extends Model> {
|
|
||||||
private readonly models;
|
|
||||||
readonly page: number;
|
|
||||||
readonly perPage: number;
|
|
||||||
readonly totalCount: number;
|
|
||||||
constructor(models: T[], page: number, perPage: number, totalCount: number);
|
|
||||||
hasPrevious(): boolean;
|
|
||||||
hasNext(): boolean;
|
|
||||||
}
|
|
15
dist/Pagination.js
vendored
15
dist/Pagination.js
vendored
@ -1,15 +0,0 @@
|
|||||||
export default class Pagination {
|
|
||||||
constructor(models, page, perPage, totalCount) {
|
|
||||||
this.models = models;
|
|
||||||
this.page = page;
|
|
||||||
this.perPage = perPage;
|
|
||||||
this.totalCount = totalCount;
|
|
||||||
}
|
|
||||||
hasPrevious() {
|
|
||||||
return this.page > 1;
|
|
||||||
}
|
|
||||||
hasNext() {
|
|
||||||
return this.models.length >= this.perPage && this.page * this.perPage < this.totalCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUGFnaW5hdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIuLyIsInNvdXJjZXMiOlsiUGFnaW5hdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxNQUFNLENBQUMsT0FBTyxPQUFPLFVBQVU7SUFNM0IsWUFBWSxNQUFXLEVBQUUsSUFBWSxFQUFFLE9BQWUsRUFBRSxVQUFrQjtRQUN0RSxJQUFJLENBQUMsTUFBTSxHQUFHLE1BQU0sQ0FBQztRQUNyQixJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQztRQUNqQixJQUFJLENBQUMsT0FBTyxHQUFHLE9BQU8sQ0FBQztRQUN2QixJQUFJLENBQUMsVUFBVSxHQUFHLFVBQVUsQ0FBQztJQUNqQyxDQUFDO0lBRU0sV0FBVztRQUNkLE9BQU8sSUFBSSxDQUFDLElBQUksR0FBRyxDQUFDLENBQUM7SUFDekIsQ0FBQztJQUVNLE9BQU87UUFDVixPQUFPLElBQUksQ0FBQyxNQUFNLENBQUMsTUFBTSxJQUFJLElBQUksQ0FBQyxPQUFPLElBQUksSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxVQUFVLENBQUM7SUFDNUYsQ0FBQztDQUVKIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IE1vZGVsIGZyb20gXCIuL2RiL01vZGVsXCI7XG5cbmV4cG9ydCBkZWZhdWx0IGNsYXNzIFBhZ2luYXRpb248VCBleHRlbmRzIE1vZGVsPiB7XG4gICAgcHJpdmF0ZSByZWFkb25seSBtb2RlbHM6IFRbXTtcbiAgICBwdWJsaWMgcmVhZG9ubHkgcGFnZTogbnVtYmVyO1xuICAgIHB1YmxpYyByZWFkb25seSBwZXJQYWdlOiBudW1iZXI7XG4gICAgcHVibGljIHJlYWRvbmx5IHRvdGFsQ291bnQ6IG51bWJlcjtcblxuICAgIGNvbnN0cnVjdG9yKG1vZGVsczogVFtdLCBwYWdlOiBudW1iZXIsIHBlclBhZ2U6IG51bWJlciwgdG90YWxDb3VudDogbnVtYmVyKSB7XG4gICAgICAgIHRoaXMubW9kZWxzID0gbW9kZWxzO1xuICAgICAgICB0aGlzLnBhZ2UgPSBwYWdlO1xuICAgICAgICB0aGlzLnBlclBhZ2UgPSBwZXJQYWdlO1xuICAgICAgICB0aGlzLnRvdGFsQ291bnQgPSB0b3RhbENvdW50O1xuICAgIH1cblxuICAgIHB1YmxpYyBoYXNQcmV2aW91cygpOiBib29sZWFuIHtcbiAgICAgICAgcmV0dXJuIHRoaXMucGFnZSA+IDE7XG4gICAgfVxuXG4gICAgcHVibGljIGhhc05leHQoKTogYm9vbGVhbiB7XG4gICAgICAgIHJldHVybiB0aGlzLm1vZGVscy5sZW5ndGggPj0gdGhpcy5wZXJQYWdlICYmIHRoaXMucGFnZSAqIHRoaXMucGVyUGFnZSA8IHRoaXMudG90YWxDb3VudDtcbiAgICB9XG5cbn0iXX0=
|
|
7
dist/Utils.d.ts
vendored
7
dist/Utils.d.ts
vendored
@ -1,7 +0,0 @@
|
|||||||
export declare function sleep(ms: number): Promise<void>;
|
|
||||||
export declare abstract class WrappingError extends Error {
|
|
||||||
readonly cause?: Error;
|
|
||||||
protected constructor(message: string, cause?: Error);
|
|
||||||
get name(): string;
|
|
||||||
}
|
|
||||||
export declare function cryptoRandomDictionary(size: number, dictionary: string): string;
|
|
38
dist/Utils.js
vendored
38
dist/Utils.js
vendored
@ -1,38 +0,0 @@
|
|||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
import * as crypto from "crypto";
|
|
||||||
export function sleep(ms) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return yield new Promise(resolve => {
|
|
||||||
setTimeout(() => resolve(), ms);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
export class WrappingError extends Error {
|
|
||||||
constructor(message, cause) {
|
|
||||||
super(message);
|
|
||||||
this.cause = cause;
|
|
||||||
if (cause !== undefined) {
|
|
||||||
this.stack = (this.stack || '') + `\n> Caused by: ${cause.stack}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
get name() {
|
|
||||||
return this.constructor.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export function cryptoRandomDictionary(size, dictionary) {
|
|
||||||
const randomBytes = crypto.randomBytes(size);
|
|
||||||
const output = new Array(size);
|
|
||||||
for (let i = 0; i < size; i++) {
|
|
||||||
output[i] = dictionary[Math.floor((randomBytes[i] / 255) * dictionary.length)];
|
|
||||||
}
|
|
||||||
return output.join('');
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiVXRpbHMuanMiLCJzb3VyY2VSb290IjoiLi8iLCJzb3VyY2VzIjpbIlV0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mluZyB7XG4gICAgICAgIHJldHVybiB0aGlzLmNvbnN0cnVjdG9yLm5hbWU7XG4gICAgfVxufVxuXG5leHBvcnQgZnVuY3Rpb24gY3J5cHRvUmFuZG9tRGljdGlvbmFyeShzaXplOiBudW1iZXIsIGRpY3Rpb25hcnk6IHN0cmluZyk6IHN0cmluZyB7XG4gICAgY29uc3QgcmFuZG9tQnl0ZXMgPSBjcnlwdG8ucmFuZG9tQnl0ZXMoc2l6ZSk7XG4gICAgY29uc3Qgb3V0cHV0ID0gbmV3IEFycmF5KHNpemUpO1xuXG4gICAgZm9yIChsZXQgaSA9IDA7IGkgPCBzaXplOyBpKyspIHtcbiAgICAgICAgb3V0cHV0W2ldID0gZGljdGlvbmFyeVtNYXRoLmZsb29yKChyYW5kb21CeXRlc1tpXSAvIDI1NSkgKiBkaWN0aW9uYXJ5Lmxlbmd0aCldO1xuICAgIH1cblxuICAgIHJldHVybiBvdXRwdXQuam9pbignJyk7XG59Il19
|
|
8
dist/WebSocketListener.d.ts
vendored
8
dist/WebSocketListener.d.ts
vendored
@ -1,8 +0,0 @@
|
|||||||
/// <reference types="node" />
|
|
||||||
/// <reference types="express-session" />
|
|
||||||
import WebSocket from "ws";
|
|
||||||
import { IncomingMessage } from "http";
|
|
||||||
export default abstract class WebSocketListener {
|
|
||||||
abstract path(): string;
|
|
||||||
abstract handle(socket: WebSocket, request: IncomingMessage, session: Express.SessionData): Promise<void>;
|
|
||||||
}
|
|
3
dist/WebSocketListener.js
vendored
3
dist/WebSocketListener.js
vendored
@ -1,3 +0,0 @@
|
|||||||
export default class WebSocketListener {
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiV2ViU29ja2V0TGlzdGVuZXIuanMiLCJzb3VyY2VSb290IjoiLi8iLCJzb3VyY2VzIjpbIldlYlNvY2tldExpc3RlbmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLE1BQU0sQ0FBQyxPQUFPLE9BQWdCLGlCQUFpQjtDQUk5QyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBXZWJTb2NrZXQgZnJvbSBcIndzXCI7XG5pbXBvcnQge0luY29taW5nTWVzc2FnZX0gZnJvbSBcImh0dHBcIjtcblxuZXhwb3J0IGRlZmF1bHQgYWJzdHJhY3QgY2xhc3MgV2ViU29ja2V0TGlzdGVuZXIge1xuICAgIHB1YmxpYyBhYnN0cmFjdCBwYXRoKCk6IHN0cmluZztcblxuICAgIHB1YmxpYyBhYnN0cmFjdCBhc3luYyBoYW5kbGUoc29ja2V0OiBXZWJTb2NrZXQsIHJlcXVlc3Q6IEluY29taW5nTWVzc2FnZSwgc2Vzc2lvbjogRXhwcmVzcy5TZXNzaW9uRGF0YSk6IFByb21pc2U8dm9pZD47XG59Il19
|
|
6
dist/components/CsrfProtectionComponent.d.ts
vendored
6
dist/components/CsrfProtectionComponent.d.ts
vendored
@ -1,6 +0,0 @@
|
|||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import { Express, Router } from "express";
|
|
||||||
export default class CsrfProtectionComponent extends ApplicationComponent<void> {
|
|
||||||
start(app: Express, router: Router): Promise<void>;
|
|
||||||
stop(): Promise<void>;
|
|
||||||
}
|
|
57
dist/components/CsrfProtectionComponent.js
vendored
57
dist/components/CsrfProtectionComponent.js
vendored
@ -1,57 +0,0 @@
|
|||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import crypto from "crypto";
|
|
||||||
import { BadRequestError } from "../HttpError";
|
|
||||||
export default class CsrfProtectionComponent extends ApplicationComponent {
|
|
||||||
start(app, router) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
router.use((req, res, next) => {
|
|
||||||
if (!req.session) {
|
|
||||||
throw new Error('Session is unavailable.');
|
|
||||||
}
|
|
||||||
res.locals.getCSRFToken = () => {
|
|
||||||
if (typeof req.session.csrf !== 'string') {
|
|
||||||
req.session.csrf = crypto.randomBytes(64).toString('base64');
|
|
||||||
}
|
|
||||||
return req.session.csrf;
|
|
||||||
};
|
|
||||||
if (!['GET', 'HEAD', 'OPTIONS'].find(s => s === req.method)) {
|
|
||||||
if (req.session.csrf === undefined) {
|
|
||||||
throw new InvalidCsrfTokenError(req.baseUrl, `You weren't assigned any CSRF token.`);
|
|
||||||
}
|
|
||||||
else if (req.body.csrf === undefined) {
|
|
||||||
throw new InvalidCsrfTokenError(req.baseUrl, `You didn't provide any CSRF token.`);
|
|
||||||
}
|
|
||||||
else if (req.session.csrf !== req.body.csrf) {
|
|
||||||
throw new InvalidCsrfTokenError(req.baseUrl, `Tokens don't match.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
stop() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class InvalidCsrfTokenError extends BadRequestError {
|
|
||||||
constructor(url, details, cause) {
|
|
||||||
super(`Invalid CSRF token`, `${details} We can't process this request. Please try again.`, url, cause);
|
|
||||||
}
|
|
||||||
get name() {
|
|
||||||
return 'Invalid CSRF Token';
|
|
||||||
}
|
|
||||||
get errorCode() {
|
|
||||||
return 401;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ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H07XG5cbiAgICAgICAgICAgIGlmICghWydHRVQnLCAnSEVBRCcsICdPUFRJT05TJ10uZmluZChzID0+IHMgPT09IHJlcS5tZXRob2QpKSB7XG4gICAgICAgICAgICAgICAgaWYgKHJlcS5zZXNzaW9uLmNzcmYgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgSW52YWxpZENzcmZUb2tlbkVycm9yKHJlcS5iYXNlVXJsLCBgWW91IHdlcmVuJ3QgYXNzaWduZWQgYW55IENTUkYgdG9rZW4uYCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChyZXEuYm9keS5jc3JmID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEludmFsaWRDc3JmVG9rZW5FcnJvcihyZXEuYmFzZVVybCwgYFlvdSBkaWRuJ3QgcHJvdmlkZSBhbnkgQ1NSRiB0b2tlbi5gKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHJlcS5zZXNzaW9uLmNzcmYgIT09IHJlcS5ib2R5LmNzcmYpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEludmFsaWRDc3JmVG9rZW5FcnJvcihyZXEuYmFzZVVybCwgYFRva2VucyBkb24ndCBtYXRjaC5gKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBuZXh0KCk7XG4gICAgICAgIH0pO1xuICAgIH1cblxuICAgIHB1YmxpYyBhc3luYyBzdG9wKCk6IFByb21pc2U8dm9pZD4ge1xuICAgIH1cbn1cblxuY2xhc3MgSW52YWxpZENzcmZUb2tlbkVycm9yIGV4dGVuZHMgQmFkUmVxdWVzdEVycm9yIHtcbiAgICBjb25zdHJ1Y3Rvcih1cmw6IHN0cmluZywgZGV0YWlsczogc3RyaW5nLCBjYXVzZT86IEVycm9yKSB7XG4gICAgICAgIHN1cGVyKFxuICAgICAgICAgICAgYEludmFsaWQgQ1NSRiB0b2tlbmAsXG4gICAgICAgICAgICBgJHtkZXRhaWxzfSBXZSBjYW4ndCBwcm9jZXNzIHRoaXMgcmVxdWVzdC4gUGxlYXNlIHRyeSBhZ2Fpbi5gLFxuICAgICAgICAgICAgdXJsLFxuICAgICAgICAgICAgY2F1c2VcbiAgICAgICAgKTtcbiAgICB9XG5cbiAgICBnZXQgbmFtZSgpOiBzdHJpbmcge1xuICAgICAgICByZXR1cm4gJ0ludmFsaWQgQ1NSRiBUb2tlbic7XG4gICAgfVxuXG4gICAgZ2V0IGVycm9yQ29kZSgpOiBudW1iZXIge1xuICAgICAgICByZXR1cm4gNDAxO1xuICAgIH1cbn1cbiJdfQ==
|
|
12
dist/components/ExpressAppComponent.d.ts
vendored
12
dist/components/ExpressAppComponent.d.ts
vendored
@ -1,12 +0,0 @@
|
|||||||
/// <reference types="node" />
|
|
||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import { Express, Router } from "express";
|
|
||||||
import { Server } from "http";
|
|
||||||
export default class ExpressAppComponent extends ApplicationComponent<void> {
|
|
||||||
private readonly port;
|
|
||||||
private server?;
|
|
||||||
constructor(port: number);
|
|
||||||
start(app: Express, router: Router): Promise<void>;
|
|
||||||
stop(): Promise<void>;
|
|
||||||
getServer(): Server;
|
|
||||||
}
|
|
45
dist/components/ExpressAppComponent.js
vendored
45
dist/components/ExpressAppComponent.js
vendored
@ -1,45 +0,0 @@
|
|||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import express from "express";
|
|
||||||
import Logger from "../Logger";
|
|
||||||
export default class ExpressAppComponent extends ApplicationComponent {
|
|
||||||
constructor(port) {
|
|
||||||
super();
|
|
||||||
this.port = port;
|
|
||||||
}
|
|
||||||
start(app, router) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
this.server = app.listen(this.port, 'localhost', () => {
|
|
||||||
Logger.info(`Web server running on localhost:${this.port}.`);
|
|
||||||
});
|
|
||||||
router.use(express.json());
|
|
||||||
router.use(express.urlencoded());
|
|
||||||
router.use((req, res, next) => {
|
|
||||||
req.models = {};
|
|
||||||
req.modelCollections = {};
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
stop() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
if (this.server) {
|
|
||||||
yield this.close('Webserver', this.server, this.server.close);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getServer() {
|
|
||||||
if (!this.server)
|
|
||||||
throw 'Server was not initialized.';
|
|
||||||
return this.server;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRXhwcmVzc0FwcENvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIuLyIsInNvdXJjZXMiOlsiY29tcG9uZW50cy9FeHByZXNzQXBwQ29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7OztBQUFBLE9BQU8sb0JBQW9CLE1BQU0seUJBQXlCLENBQUM7QUFDM0QsT0FBTyxPQUEwQixNQUFNLFNBQVMsQ0FBQztBQUNqRCxPQUFPLE1BQU0sTUFBTSxXQUFXLENBQUM7QUFHL0IsTUFBTSxDQUFDLE9BQU8sT0FBTyxtQkFBb0IsU0FBU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hwcmVzcy51cmxlbmNvZGVkKCkpO1xuXG4gICAgICAgIHJvdXRlci51c2UoKHJlcSwgcmVzLCBuZXh0KSA9PiB7XG4gICAgICAgICAgICByZXEubW9kZWxzID0ge307XG4gICAgICAgICAgICByZXEubW9kZWxDb2xsZWN0aW9ucyA9IHt9O1xuICAgICAgICAgICAgbmV4dCgpO1xuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBwdWJsaWMgYXN5bmMgc3RvcCgpOiBQcm9taXNlPHZvaWQ+IHtcbiAgICAgICAgaWYgKHRoaXMuc2VydmVyKSB7XG4gICAgICAgICAgICBhd2FpdCB0aGlzLmNsb3NlKCdXZWJzZXJ2ZXInLCB0aGlzLnNlcnZlciwgdGhpcy5zZXJ2ZXIuY2xvc2UpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgcHVibGljIGdldFNlcnZlcigpOiBTZXJ2ZXIge1xuICAgICAgICBpZiAoIXRoaXMuc2VydmVyKSB0aHJvdyAnU2VydmVyIHdhcyBub3QgaW5pdGlhbGl6ZWQuJztcbiAgICAgICAgcmV0dXJuIHRoaXMuc2VydmVyO1xuICAgIH1cbn0iXX0=
|
|
6
dist/components/FormHelperComponent.d.ts
vendored
6
dist/components/FormHelperComponent.d.ts
vendored
@ -1,6 +0,0 @@
|
|||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import { Express, Router } from "express";
|
|
||||||
export default class FormHelperComponent extends ApplicationComponent<void> {
|
|
||||||
start(app: Express, router: Router): Promise<void>;
|
|
||||||
stop(): Promise<void>;
|
|
||||||
}
|
|
52
dist/components/FormHelperComponent.js
vendored
52
dist/components/FormHelperComponent.js
vendored
@ -1,52 +0,0 @@
|
|||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
export default class FormHelperComponent extends ApplicationComponent {
|
|
||||||
start(app, router) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
router.use((req, res, next) => {
|
|
||||||
if (!req.session) {
|
|
||||||
throw new Error('Session is unavailable.');
|
|
||||||
}
|
|
||||||
res.locals.query = req.query;
|
|
||||||
let _validation = null;
|
|
||||||
res.locals.validation = () => {
|
|
||||||
if (!_validation) {
|
|
||||||
const v = req.flash('validation');
|
|
||||||
_validation = v.length > 0 ? v[0] : null;
|
|
||||||
}
|
|
||||||
return _validation;
|
|
||||||
};
|
|
||||||
let _previousFormData = null;
|
|
||||||
res.locals.previousFormData = () => {
|
|
||||||
if (!_previousFormData) {
|
|
||||||
const v = req.flash('previousFormData');
|
|
||||||
_previousFormData = v.length > 0 ? v[0] : null;
|
|
||||||
}
|
|
||||||
return _previousFormData;
|
|
||||||
};
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
router.use((req, res, next) => {
|
|
||||||
if (['GET', 'POST'].find(m => m === req.method)) {
|
|
||||||
if (typeof req.body === 'object') {
|
|
||||||
req.flash('previousFormData', req.body);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
stop() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRm9ybUhlbHBlckNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIuLyIsInNvdX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cHJlc3NcIjtcblxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgRm9ybUhlbHBlckNvbXBvbmVudCBleHRlbmRzIEFwcGxpY2F0aW9uQ29tcG9uZW50PHZvaWQ+IHtcbiAgICBwdWJsaWMgYXN5bmMgc3RhcnQoYXBwOiBFeHByZXNzLCByb3V0ZXI6IFJvdXRlcik6IFByb21pc2U8dm9pZD4ge1xuICAgICAgICByb3V0ZXIudXNlKChyZXEsIHJlcywgbmV4dCkgPT4ge1xuICAgICAgICAgICAgaWYgKCFyZXEuc2Vzc2lvbikge1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignU2Vzc2lvbiBpcyB1bmF2YWlsYWJsZS4nKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcmVzLmxvY2Fscy5xdWVyeSA9IHJlcS5xdWVyeTtcblxuICAgICAgICAgICAgbGV0IF92YWxpZGF0aW9uOiBhbnkgPSBudWxsO1xuICAgICAgICAgICAgcmVzLmxvY2Fscy52YWxpZGF0aW9uID0gKCkgPT4ge1xuICAgICAgICAgICAgICAgIGlmICghX3ZhbGlkYXRpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgdiA9IHJlcS5mbGFzaCgndmFsaWRhdGlvbicpO1xuICAgICAgICAgICAgICAgICAgICBfdmFsaWRhdGlvbiA9IHYubGVuZ3RoID4gMCA/IHZbMF0gOiBudWxsO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIHJldHVybiBfdmFsaWRhdGlvbjtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbGV0IF9wcmV2aW91c0Zvcm1EYXRhOiBhbnkgPSBudWxsO1xuICAgICAgICAgICAgcmVzLmxvY2Fscy5wcmV2aW91c0Zvcm1EYXRhID0gKCkgPT4ge1xuICAgICAgICAgICAgICAgIGlmICghX3ByZXZpb3VzRm9ybURhdGEpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgdiA9IHJlcS5mbGFzaCgncHJldmlvdXNGb3JtRGF0YScpO1xuICAgICAgICAgICAgICAgICAgICBfcHJldmlvdXNGb3JtRGF0YSA9IHYubGVuZ3RoID4gMCA/IHYgWzBdIDogbnVsbDtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICByZXR1cm4gX3ByZXZpb3VzRm9ybURhdGE7XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgbmV4dCgpO1xuICAgICAgICB9KTtcblxuICAgICAgICByb3V0ZXIudXNlKChyZXEsIHJlcywgbmV4dCkgPT4ge1xuICAgICAgICAgICAgaWYgKFsnR0VUJywgJ1BPU1QnXS5maW5kKG0gPT4gbSA9PT0gcmVxLm1ldGhvZCkpIHtcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlcS5ib2R5ID09PSAnb2JqZWN0Jykge1xuICAgICAgICAgICAgICAgICAgICByZXEuZmxhc2goJ3ByZXZpb3VzRm9ybURhdGEnLCByZXEuYm9keSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbmV4dCgpO1xuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBwdWJsaWMgYXN5bmMgc3RvcCgpOiBQcm9taXNlPHZvaWQ+IHtcbiAgICB9XG5cbn0iXX0=
|
|
6
dist/components/LogRequestsComponent.d.ts
vendored
6
dist/components/LogRequestsComponent.d.ts
vendored
@ -1,6 +0,0 @@
|
|||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import { Express, Router } from "express";
|
|
||||||
export default class LogRequestsComponent extends ApplicationComponent<void> {
|
|
||||||
start(app: Express, router: Router): Promise<void>;
|
|
||||||
stop(): Promise<void>;
|
|
||||||
}
|
|
31
dist/components/LogRequestsComponent.js
vendored
31
dist/components/LogRequestsComponent.js
vendored
@ -1,31 +0,0 @@
|
|||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import onFinished from "on-finished";
|
|
||||||
import Logger from "../Logger";
|
|
||||||
export default class LogRequestsComponent extends ApplicationComponent {
|
|
||||||
start(app, router) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
router.use((req, res, next) => {
|
|
||||||
onFinished(res, (err) => {
|
|
||||||
if (!err) {
|
|
||||||
Logger.info(`${req.method} ${req.originalUrl} - ${res.statusCode}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
stop() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTG9nUmVxdWVzdHNDb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiLi8iLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvTG9nUmVxdWVzdHNDb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O0FBQUEsT0FBTyxvQkFBb0IsTUFBTSx5QkFBeUIsQ0FBQztBQUMzRCxPQUFPLFVBQVUsTUFBTSxhQUFhLENBQUM7QUFDckMsT0FBTyxNQUFNLE1BQU0sV0FBVyxDQUFDO0FBRy9CLE1BQU0sQ0FBQyxPQUFPLE9BQU8sb0JBQXFCLFNBQVEsb0JBQ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4gICAgICAgICAgICBvbkZpbmlzaGVkKHJlcywgKGVycikgPT4ge1xuICAgICAgICAgICAgICAgIGlmICghZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgIExvZ2dlci5pbmZvKGAke3JlcS5tZXRob2R9ICR7cmVxLm9yaWdpbmFsVXJsfSAtICR7cmVzLnN0YXR1c0NvZGV9YCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICBuZXh0KCk7XG4gICAgICAgIH0pO1xuICAgIH1cblxuICAgIHB1YmxpYyBhc3luYyBzdG9wKCk6IFByb21pc2U8dm9pZD4ge1xuICAgIH1cblxufSJdfQ==
|
|
6
dist/components/MailComponent.d.ts
vendored
6
dist/components/MailComponent.d.ts
vendored
@ -1,6 +0,0 @@
|
|||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import { Express, Router } from "express";
|
|
||||||
export default class MailComponent extends ApplicationComponent<void> {
|
|
||||||
start(app: Express, router: Router): Promise<void>;
|
|
||||||
stop(): Promise<void>;
|
|
||||||
}
|
|
24
dist/components/MailComponent.js
vendored
24
dist/components/MailComponent.js
vendored
@ -1,24 +0,0 @@
|
|||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import Mail from "../Mail";
|
|
||||||
export default class MailComponent extends ApplicationComponent {
|
|
||||||
start(app, router) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
yield this.prepare('Mail connection', () => Mail.prepare());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
stop() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
Mail.end();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFpbENvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIuLyIsInNvdXJjZXMiOlsiY29tcG9uZW50cy9NYWlsQ29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7OztBQUFBLE9BQU8sb0JBQW9CLE1BQU0seUJBQXlCLENBQUM7QUFFM0QsT0FBTyxJQUFJLE1BQU0sU0FBUyxDQUFDO0FBRTNCLE1BQU0sQ0FBQyxPQUFPLE9BQU8sYUFBYyxTQUFRLG9CQUEwQjtJQUNwRCxLQUFLLENBQUMsR0FBWSxFQUFFLE1BQWM7O1lBQzNDLE1BQU0sSUFBSSxDQUFDLE9BQU8sQ0FBQyxpQkFBaUIsRUFBRSxHQUFHLEVBQUUsQ0FBQyxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUMsQ0FBQztRQUNoRSxDQUFDO0tBQUE7SUFFWSxJQUFJOztZQUNiLElBQUksQ0FBQyxHQUFHLEVBQUUsQ0FBQztRQUNmLENBQUM7S0FBQTtDQUVKIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IEFwcGxpY2F0aW9uQ29tcG9uZW50IGZyb20gXCIuLi9BcHBsaWNhdGlvbkNvbXBvbmVudFwiO1xuaW1wb3J0IHtFeHByZXNzLCBSb3V0ZXJ9IGZyb20gXCJleHByZXNzXCI7XG5pbXBvcnQgTWFpbCBmcm9tIFwiLi4vTWFpbFwiO1xuXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBNYWlsQ29tcG9uZW50IGV4dGVuZHMgQXBwbGljYXRpb25Db21wb25lbnQ8dm9pZD4ge1xuICAgIHB1YmxpYyBhc3luYyBzdGFydChhcHA6IEV4cHJlc3MsIHJvdXRlcjogUm91dGVyKTogUHJvbWlzZTx2b2lkPiB7XG4gICAgICAgIGF3YWl0IHRoaXMucHJlcGFyZSgnTWFpbCBjb25uZWN0aW9uJywgKCkgPT4gTWFpbC5wcmVwYXJlKCkpO1xuICAgIH1cblxuICAgIHB1YmxpYyBhc3luYyBzdG9wKCk6IFByb21pc2U8dm9pZD4ge1xuICAgICAgICBNYWlsLmVuZCgpO1xuICAgIH1cblxufSJdfQ==
|
|
10
dist/components/MaintenanceComponent.d.ts
vendored
10
dist/components/MaintenanceComponent.d.ts
vendored
@ -1,10 +0,0 @@
|
|||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import { Express, Router } from "express";
|
|
||||||
import Application from "../Application";
|
|
||||||
export default class MaintenanceComponent extends ApplicationComponent<void> {
|
|
||||||
private readonly application;
|
|
||||||
private readonly canServe;
|
|
||||||
constructor(application: Application, canServe: () => boolean);
|
|
||||||
start(app: Express, router: Router): Promise<void>;
|
|
||||||
stop(): Promise<void>;
|
|
||||||
}
|
|
42
dist/components/MaintenanceComponent.js
vendored
42
dist/components/MaintenanceComponent.js
vendored
@ -1,42 +0,0 @@
|
|||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import { ServiceUnavailableHttpError } from "../HttpError";
|
|
||||||
export default class MaintenanceComponent extends ApplicationComponent {
|
|
||||||
constructor(application, canServe) {
|
|
||||||
super();
|
|
||||||
this.application = application;
|
|
||||||
this.canServe = canServe;
|
|
||||||
}
|
|
||||||
start(app, router) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
router.use((req, res, next) => {
|
|
||||||
if (res.headersSent) {
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
if (!this.application.isReady()) {
|
|
||||||
res.header({ 'Retry-After': 60 });
|
|
||||||
res.locals.refresh_after = 5;
|
|
||||||
throw new ServiceUnavailableHttpError('Watch My Stream is readying up. Please wait a few seconds...');
|
|
||||||
}
|
|
||||||
if (!this.canServe()) {
|
|
||||||
res.locals.refresh_after = 30;
|
|
||||||
throw new ServiceUnavailableHttpError('Watch My Stream is unavailable due to failure of dependent services.');
|
|
||||||
}
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
stop() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFpbnRlbmFuY2VDb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiLi8iLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvTWFpbnRlbmFuY2VDb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O0FBQUEsT0FBTyxvQkFBb0IsTUFBTSx5QkFBeUIsQ0FBQztBQUUzRCxPQUFPLEVBQUMsMkJBQTJCLEVBQUMsTUFBTSxjQUFjLENBQUM7QUFHekQsTUFBTSxDQUFDLE9BQU8sT0FBTyxvQkFBcUIsU0FBUSxvQkFBMEI7SUFJeEUsWUFBWSxXQUF3QixFQUFFLFFBQXVCO1FBQ3pELEtBQUssRUFBR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AgICAgcmVzLmhlYWRlcih7J1JldHJ5LUFmdGVyJzogNjB9KTtcbiAgICAgICAgICAgICAgICByZXMubG9jYWxzLnJlZnJlc2hfYWZ0ZXIgPSA1O1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBTZXJ2aWNlVW5hdmFpbGFibGVIdHRwRXJyb3IoJ1dhdGNoIE15IFN0cmVhbSBpcyByZWFkeWluZyB1cC4gUGxlYXNlIHdhaXQgYSBmZXcgc2Vjb25kcy4uLicpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoIXRoaXMuY2FuU2VydmUoKSkge1xuICAgICAgICAgICAgICAgIHJlcy5sb2NhbHMucmVmcmVzaF9hZnRlciA9IDMwO1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBTZXJ2aWNlVW5hdmFpbGFibGVIdHRwRXJyb3IoJ1dhdGNoIE15IFN0cmVhbSBpcyB1bmF2YWlsYWJsZSBkdWUgdG8gZmFpbHVyZSBvZiBkZXBlbmRlbnQgc2VydmljZXMuJyk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIG5leHQoKTtcbiAgICAgICAgfSk7XG4gICAgfVxuXG4gICAgcHVibGljIGFzeW5jIHN0b3AoKTogUHJvbWlzZTx2b2lkPiB7XG4gICAgfVxuXG59Il19
|
|
7
dist/components/MysqlComponent.d.ts
vendored
7
dist/components/MysqlComponent.d.ts
vendored
@ -1,7 +0,0 @@
|
|||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import { Express, Router } from "express";
|
|
||||||
export default class MysqlComponent extends ApplicationComponent<void> {
|
|
||||||
start(app: Express, router: Router): Promise<void>;
|
|
||||||
stop(): Promise<void>;
|
|
||||||
canServe(): boolean;
|
|
||||||
}
|
|
27
dist/components/MysqlComponent.js
vendored
27
dist/components/MysqlComponent.js
vendored
@ -1,27 +0,0 @@
|
|||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import MysqlConnectionManager from "../db/MysqlConnectionManager";
|
|
||||||
export default class MysqlComponent extends ApplicationComponent {
|
|
||||||
start(app, router) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
yield this.prepare('Mysql connection', () => MysqlConnectionManager.prepare());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
stop() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
yield MysqlConnectionManager.endPool();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
canServe() {
|
|
||||||
return MysqlConnectionManager.pool !== undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTXlzcWxDb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiLi8iLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvTXlzcWxDb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O0FBQUEsT0FBTyxvQkFBb0IsTUFBTSx5QkFBeUIsQ0FBQztBQUUzRCxPQUFPLHNCQUFzQixNQUFNLDhCQUE4QixDQUFDO0FBRWxFLE1BQU0sQ0FBQyxPQUFPLE9BQU8sY0FBZSxTQUFRLG9CQUEwQjtJQUNyRCxLQUFLLENBQUMsR0FBWSxFQUFFLE1BQWM7O1lBQzNDLE1BQU0sSUFBSSxDQUFD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gICAgIHJldHVybiBNeXNxbENvbm5lY3Rpb25NYW5hZ2VyLnBvb2wgIT09IHVuZGVmaW5lZDtcbiAgICB9XG5cbn0iXX0=
|
|
6
dist/components/RedirectBackComponent.d.ts
vendored
6
dist/components/RedirectBackComponent.d.ts
vendored
@ -1,6 +0,0 @@
|
|||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import { Express, Router } from "express";
|
|
||||||
export default class RedirectBackComponent extends ApplicationComponent<void> {
|
|
||||||
start(app: Express, router: Router): Promise<void>;
|
|
||||||
stop(): Promise<void>;
|
|
||||||
}
|
|
52
dist/components/RedirectBackComponent.js
vendored
52
dist/components/RedirectBackComponent.js
vendored
@ -1,52 +0,0 @@
|
|||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import onFinished from "on-finished";
|
|
||||||
import Logger from "../Logger";
|
|
||||||
import { ServerError } from "../HttpError";
|
|
||||||
export default class RedirectBackComponent extends ApplicationComponent {
|
|
||||||
start(app, router) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
router.use((req, res, next) => {
|
|
||||||
if (!req.session) {
|
|
||||||
throw new Error('Session is unavailable.');
|
|
||||||
}
|
|
||||||
onFinished(res, (err) => {
|
|
||||||
if (!err && res.statusCode === 200) {
|
|
||||||
req.session.previousUrl = req.originalUrl;
|
|
||||||
Logger.debug('Prev url set to', req.session.previousUrl);
|
|
||||||
req.session.save((err) => {
|
|
||||||
if (err) {
|
|
||||||
Logger.error(err, 'Error while saving session');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
res.redirectBack = (defaultUrl) => {
|
|
||||||
if (req.session && typeof req.session.previousUrl === 'string') {
|
|
||||||
res.redirect(req.session.previousUrl);
|
|
||||||
}
|
|
||||||
else if (typeof defaultUrl === 'string') {
|
|
||||||
res.redirect(defaultUrl);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new ServerError('There is no previous url and no default redirection url was provided.');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
stop() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUmVkaXJlY3RCYWNrQ29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6Ii4vIiwic291cmNlcyI6WyJjb21wb25lbnRzL1JlZGlyZWN0QmFja0NvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFBQSxPQUFPLG9CQUFvQixNQUFNLHlCQUF5QixDQUFDO0FBRTNELE9BQU8sVUFBVSxNQUFNLGFBQWEsQ0FBQztBQUNyQyxPQUFPLE1BQU0sTUFBTSxXQUFXLENBQUM7QUFDL0IsT0FBTyxFQUFDLFdBQVcsRUFBQyxNQUFNLGNBQWMsQ0FBQztBQUV6QyxNQUFNLENBQUMsT0FBTyxPQUFPLHFCQUFzQixTQUFRLG9CQUEwQjtJQUM1RCxLQUFLLENBQUMsR0FBWSxFQUFFLE1BQWM7O1lBQzNDLE1BQU0sQ0FBQyxHQUFHLENBQUMsQ0FBQyxHQUFHLEVBQUUsR0FBRyxFQUFFLElBQUksRUFBRSxFQU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cbiAgICAgICAgICAgICAgICAgICAgcmVxLnNlc3Npb24hLnByZXZpb3VzVXJsID0gcmVxLm9yaWdpbmFsVXJsO1xuICAgICAgICAgICAgICAgICAgICBMb2dnZXIuZGVidWcoJ1ByZXYgdXJsIHNldCB0bycsIHJlcS5zZXNzaW9uIS5wcmV2aW91c1VybCk7XG4gICAgICAgICAgICAgICAgICAgIHJlcS5zZXNzaW9uIS5zYXZlKChlcnIpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBMb2dnZXIuZXJyb3IoZXJyLCAnRXJyb3Igd2hpbGUgc2F2aW5nIHNlc3Npb24nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIHJlcy5yZWRpcmVjdEJhY2sgPSAoZGVmYXVsdFVybD86IHN0cmluZykgPT4ge1xuICAgICAgICAgICAgICAgIGlmIChyZXEuc2Vzc2lvbiAmJiB0eXBlb2YgcmVxLnNlc3Npb24ucHJldmlvdXNVcmwgPT09ICdzdHJpbmcnKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlcy5yZWRpcmVjdChyZXEuc2Vzc2lvbi5wcmV2aW91c1VybCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgZGVmYXVsdFVybCA9PT0gJ3N0cmluZycpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzLnJlZGlyZWN0KGRlZmF1bHRVcmwpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBTZXJ2ZXJFcnJvcignVGhlcmUgaXMgbm8gcHJldmlvdXMgdXJsIGFuZCBubyBkZWZhdWx0IHJlZGlyZWN0aW9uIHVybCB3YXMgcHJvdmlkZWQuJyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgbmV4dCgpO1xuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBwdWJsaWMgYXN5bmMgc3RvcCgpOiBQcm9taXNlPHZvaWQ+IHtcbiAgICB9XG5cbn0iXX0=
|
|
11
dist/components/RedisComponent.d.ts
vendored
11
dist/components/RedisComponent.d.ts
vendored
@ -1,11 +0,0 @@
|
|||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import { Express, Router } from "express";
|
|
||||||
import { Store } from "express-session";
|
|
||||||
export default class RedisComponent extends ApplicationComponent<void> {
|
|
||||||
private redisClient?;
|
|
||||||
private store?;
|
|
||||||
start(app: Express, router: Router): Promise<void>;
|
|
||||||
stop(): Promise<void>;
|
|
||||||
getStore(): Store;
|
|
||||||
canServe(): boolean;
|
|
||||||
}
|
|
46
dist/components/RedisComponent.js
vendored
46
dist/components/RedisComponent.js
vendored
@ -1,46 +0,0 @@
|
|||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import redis from "redis";
|
|
||||||
import config from "config";
|
|
||||||
import Logger from "../Logger";
|
|
||||||
import session from "express-session";
|
|
||||||
import connect_redis from "connect-redis";
|
|
||||||
const RedisStore = connect_redis(session);
|
|
||||||
export default class RedisComponent extends ApplicationComponent {
|
|
||||||
start(app, router) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
this.redisClient = redis.createClient(config.get('redis.port'), config.get('redis.host'), {});
|
|
||||||
this.redisClient.on('error', (err) => {
|
|
||||||
Logger.error(err, 'An error occurred with redis.');
|
|
||||||
});
|
|
||||||
this.store = new RedisStore({
|
|
||||||
client: this.redisClient,
|
|
||||||
prefix: 'wms-sess:',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
stop() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
if (this.redisClient) {
|
|
||||||
yield this.close('Redis connection', this.redisClient, this.redisClient.quit);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getStore() {
|
|
||||||
if (!this.store)
|
|
||||||
throw `Redis store was not initialized.`;
|
|
||||||
return this.store;
|
|
||||||
}
|
|
||||||
canServe() {
|
|
||||||
return this.redisClient !== undefined && this.redisClient.connected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUmVkaXNDb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiLi8iLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvUmVkaXNDb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O0FBQUEsT0FBTyxvQkFBb0IsTUFBTSx5QkFBeUIsQ0FBQztBQUUzRCxPQUFPLEtBQW9CLE1BQU0sT0FBTyxDQUFDO0FBQ3pDLE9BQU8sTUFBTSxNQUFNLFFBQVEsQ0FBQztBQUM1QixPQUFPLE1BQU0sTUFBTSxXQUFXLENBQUM7QUFDL0IsT0FBTyxPQUFnQixNQUFNLGlCQUFpQixDQUFDO0FBQy9DLE9BQU8sYUFBYSxNQUFNLGVBQWUsQ0FBQztBQUUxQyxNQUFNLFVBQVUsR0FBRyxhQUFhLENBQUMsT0FBTyxDQUFDLENBQUM7QUFFMUMsTUFBTSxDQUF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G9nZ2VyLmVycm9yKGVyciwgJ0FuIGVycm9yIG9jY3VycmVkIHdpdGggcmVkaXMuJyk7XG4gICAgICAgIH0pO1xuICAgICAgICB0aGlzLnN0b3JlID0gbmV3IFJlZGlzU3RvcmUoe1xuICAgICAgICAgICAgY2xpZW50OiB0aGlzLnJlZGlzQ2xpZW50LFxuICAgICAgICAgICAgcHJlZml4OiAnd21zLXNlc3M6JyxcbiAgICAgICAgfSk7XG4gICAgfVxuXG4gICAgcHVibGljIGFzeW5jIHN0b3AoKTogUHJvbWlzZTx2b2lkPiB7XG4gICAgICAgIGlmICh0aGlzLnJlZGlzQ2xpZW50KSB7XG4gICAgICAgICAgICBhd2FpdCB0aGlzLmNsb3NlKCdSZWRpcyBjb25uZWN0aW9uJywgdGhpcy5yZWRpc0NsaWVudCwgdGhpcy5yZWRpc0NsaWVudC5xdWl0KTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHB1YmxpYyBnZXRTdG9yZSgpOiBTdG9yZSB7XG4gICAgICAgIGlmICghdGhpcy5zdG9yZSkgdGhyb3cgYFJlZGlzIHN0b3JlIHdhcyBub3QgaW5pdGlhbGl6ZWQuYDtcbiAgICAgICAgcmV0dXJuIHRoaXMuc3RvcmU7XG4gICAgfVxuXG4gICAgcHVibGljIGNhblNlcnZlKCk6IGJvb2xlYW4ge1xuICAgICAgICByZXR1cm4gdGhpcy5yZWRpc0NsaWVudCAhPT0gdW5kZWZpbmVkICYmIHRoaXMucmVkaXNDbGllbnQuY29ubmVjdGVkO1xuICAgIH1cbn0iXX0=
|
|
@ -1,10 +0,0 @@
|
|||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import { Express, Router } from "express";
|
|
||||||
import { PathParams } from "express-serve-static-core";
|
|
||||||
export default class ServeStaticDirectoryComponent extends ApplicationComponent<void> {
|
|
||||||
private readonly root;
|
|
||||||
private readonly path?;
|
|
||||||
constructor(root: string, routePath?: PathParams);
|
|
||||||
start(app: Express, router: Router): Promise<void>;
|
|
||||||
stop(): Promise<void>;
|
|
||||||
}
|
|
33
dist/components/ServeStaticDirectoryComponent.js
vendored
33
dist/components/ServeStaticDirectoryComponent.js
vendored
@ -1,33 +0,0 @@
|
|||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import express from "express";
|
|
||||||
export default class ServeStaticDirectoryComponent extends ApplicationComponent {
|
|
||||||
constructor(root, routePath) {
|
|
||||||
super();
|
|
||||||
this.root = root;
|
|
||||||
this.path = routePath;
|
|
||||||
}
|
|
||||||
start(app, router) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
if (typeof this.path !== 'undefined') {
|
|
||||||
router.use(this.path, express.static(this.root, { maxAge: 1000 * 3600 * 72 }));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
router.use(express.static(this.root, { maxAge: 1000 * 3600 * 72 }));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
stop() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2VydmVTdGF0aWNEaXJlY3RvcnlDb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiLi8iLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvU2VydmVTdGF0aWN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ZW50XCI7XG5pbXBvcnQgZXhwcmVzcywge0V4cHJlc3MsIFJvdXRlcn0gZnJvbSBcImV4cHJlc3NcIjtcbmltcG9ydCB7UGF0aFBhcmFtc30gZnJvbSBcImV4cHJlc3Mtc2VydmUtc3RhdGljLWNvcmVcIjtcblxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgU2VydmVTdGF0aWNEaXJlY3RvcnlDb21wb25lbnQgZXh0ZW5kcyBBcHBsaWNhdGlvbkNvbXBvbmVudDx2b2lkPiB7XG4gICAgcHJpdmF0ZSByZWFkb25seSByb290OiBzdHJpbmc7XG4gICAgcHJpdmF0ZSByZWFkb25seSBwYXRoPzogUGF0aFBhcmFtcztcblxuICAgIGNvbnN0cnVjdG9yKHJvb3Q6IHN0cmluZywgcm91dGVQYXRoPzogUGF0aFBhcmFtcykge1xuICAgICAgICBzdXBlcigpO1xuICAgICAgICB0aGlzLnJvb3QgPSByb290O1xuICAgICAgICB0aGlzLnBhdGggPSByb3V0ZVBhdGg7XG4gICAgfVxuXG4gICAgcHVibGljIGFzeW5jIHN0YXJ0KGFwcDogRXhwcmVzcywgcm91dGVyOiBSb3V0ZXIpOiBQcm9taXNlPHZvaWQ+IHtcbiAgICAgICAgaWYgKHR5cGVvZiB0aGlzLnBhdGggIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICByb3V0ZXIudXNlKHRoaXMucGF0aCwgZXhwcmVzcy5zdGF0aWModGhpcy5yb290LCB7bWF4QWdlOiAxMDAwICogMzYwMCAqIDcyfSkpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcm91dGVyLnVzZShleHByZXNzLnN0YXRpYyh0aGlzLnJvb3QsIHttYXhBZ2U6IDEwMDAgKiAzNjAwICogNzJ9KSk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBwdWJsaWMgYXN5bmMgc3RvcCgpOiBQcm9taXNlPHZvaWQ+IHtcbiAgICB9XG5cbn0iXX0=
|
|
9
dist/components/SessionComponent.d.ts
vendored
9
dist/components/SessionComponent.d.ts
vendored
@ -1,9 +0,0 @@
|
|||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import RedisComponent from "./RedisComponent";
|
|
||||||
import { Express, Router } from "express";
|
|
||||||
export default class SessionComponent extends ApplicationComponent<void> {
|
|
||||||
private readonly storeComponent;
|
|
||||||
constructor(storeComponent: RedisComponent);
|
|
||||||
start(app: Express, router: Router): Promise<void>;
|
|
||||||
stop(): Promise<void>;
|
|
||||||
}
|
|
59
dist/components/SessionComponent.js
vendored
59
dist/components/SessionComponent.js
vendored
@ -1,59 +0,0 @@
|
|||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import session from "express-session";
|
|
||||||
import config from "config";
|
|
||||||
import flash from "connect-flash";
|
|
||||||
export default class SessionComponent extends ApplicationComponent {
|
|
||||||
constructor(storeComponent) {
|
|
||||||
super();
|
|
||||||
this.storeComponent = storeComponent;
|
|
||||||
}
|
|
||||||
start(app, router) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
router.use(session({
|
|
||||||
saveUninitialized: true,
|
|
||||||
secret: config.get('session.secret'),
|
|
||||||
store: this.storeComponent.getStore(),
|
|
||||||
resave: true,
|
|
||||||
cookie: {
|
|
||||||
httpOnly: true,
|
|
||||||
secure: config.get('session.cookie.secure'),
|
|
||||||
},
|
|
||||||
rolling: true,
|
|
||||||
}));
|
|
||||||
router.use(flash());
|
|
||||||
router.use((req, res, next) => {
|
|
||||||
if (!req.session) {
|
|
||||||
throw new Error('Session is unavailable.');
|
|
||||||
}
|
|
||||||
res.locals.session = req.session;
|
|
||||||
let _flash = null;
|
|
||||||
res.locals.flash = () => {
|
|
||||||
if (!_flash) {
|
|
||||||
_flash = {
|
|
||||||
info: req.flash('info'),
|
|
||||||
success: req.flash('success'),
|
|
||||||
warning: req.flash('warning'),
|
|
||||||
error: req.flash('error'),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return _flash;
|
|
||||||
};
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
stop() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2Vzc2lvbkNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIuLyIsInNvdXJjZXMiOlsiY29tcG9uZW50cy9TZXNzaW9uQ29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7OztBQUFBLE9BQU8sb0JBQW9CLE1BQU0seUJBQXlCLENBQUM7QUFDM0QsT0FBTyxPQUFPLE1BQU0saUJBQWlCLENBQUM7QUFDdEMsT0FBTyxNQUFNLE1BQU0sUUFBUSxDQUFDO0FBRTVCLE9BQU8sS0FBSyxNQUFNLGVBQWUsQ0FBQztBQUdsQyxNQUFNLENBQUMsT0FBTyxPQUFPLGdCQUFpQixTQUFRLG9CQUEwQjtJQUlwRSxZQUFtQixjQUE4QjtRQUM3QyxLQUFLLEVBQUUsQ0FBQztRQUNSLElBQUksQ0FBQyxjQUFjLEdBQUcsY0FBYyxDQUFDO0lBQ3pDLENBQUM7SUFFWSxLQUFLLENBQUMsR0FBWSxFQUFFLE1BQWM7O1lBQzNDLE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XN5bmMgc3RhcnQoYXBwOiBFeHByZXNzLCByb3V0ZXI6IFJvdXRlcik6IFByb21pc2U8dm9pZD4ge1xuICAgICAgICByb3V0ZXIudXNlKHNlc3Npb24oe1xuICAgICAgICAgICAgc2F2ZVVuaW5pdGlhbGl6ZWQ6IHRydWUsXG4gICAgICAgICAgICBzZWNyZXQ6IGNvbmZpZy5nZXQoJ3Nlc3Npb24uc2VjcmV0JyksXG4gICAgICAgICAgICBzdG9yZTogdGhpcy5zdG9yZUNvbXBvbmVudC5nZXRTdG9yZSgpLFxuICAgICAgICAgICAgcmVzYXZlOiB0cnVlLFxuICAgICAgICAgICAgY29va2llOiB7XG4gICAgICAgICAgICAgICAgaHR0cE9ubHk6IHRydWUsXG4gICAgICAgICAgICAgICAgc2VjdXJlOiBjb25maWcuZ2V0KCdzZXNzaW9uLmNvb2tpZS5zZWN1cmUnKSxcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICByb2xsaW5nOiB0cnVlLFxuICAgICAgICB9KSk7XG5cbiAgICAgICAgcm91dGVyLnVzZShmbGFzaCgpKTtcblxuICAgICAgICByb3V0ZXIudXNlKChyZXEsIHJlcywgbmV4dCkgPT4ge1xuICAgICAgICAgICAgaWYgKCFyZXEuc2Vzc2lvbikge1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignU2Vzc2lvbiBpcyB1bmF2YWlsYWJsZS4nKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcmVzLmxvY2Fscy5zZXNzaW9uID0gcmVxLnNlc3Npb247XG5cbiAgICAgICAgICAgIGxldCBfZmxhc2g6IGFueSA9IG51bGw7XG4gICAgICAgICAgICByZXMubG9jYWxzLmZsYXNoID0gKCkgPT4ge1xuICAgICAgICAgICAgICAgIGlmICghX2ZsYXNoKSB7XG4gICAgICAgICAgICAgICAgICAgIF9mbGFzaCA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGluZm86IHJlcS5mbGFzaCgnaW5mbycpLFxuICAgICAgICAgICAgICAgICAgICAgICAgc3VjY2VzczogcmVxLmZsYXNoKCdzdWNjZXNzJyksXG4gICAgICAgICAgICAgICAgICAgICAgICB3YXJuaW5nOiByZXEuZmxhc2goJ3dhcm5pbmcnKSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yOiByZXEuZmxhc2goJ2Vycm9yJyksXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBfZmxhc2g7XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgbmV4dCgpO1xuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBwdWJsaWMgYXN5bmMgc3RvcCgpOiBQcm9taXNlPHZvaWQ+IHtcbiAgICB9XG59Il19
|
|
14
dist/components/WebSocketServerComponent.d.ts
vendored
14
dist/components/WebSocketServerComponent.d.ts
vendored
@ -1,14 +0,0 @@
|
|||||||
import ApplicationComponent from "../ApplicationComponent";
|
|
||||||
import { Express, Router } from "express";
|
|
||||||
import ExpressAppComponent from "./ExpressAppComponent";
|
|
||||||
import Application from "../Application";
|
|
||||||
import RedisComponent from "./RedisComponent";
|
|
||||||
export default class WebSocketServerComponent extends ApplicationComponent<void> {
|
|
||||||
private readonly application;
|
|
||||||
private readonly expressAppComponent;
|
|
||||||
private readonly storeComponent;
|
|
||||||
private wss?;
|
|
||||||
constructor(application: Application, expressAppComponent: ExpressAppComponent, storeComponent: RedisComponent);
|
|
||||||
start(app: Express, router: Router): Promise<void>;
|
|
||||||
stop(): Promise<void>;
|
|
||||||
}
|
|
73
dist/components/WebSocketServerComponent.js
vendored
73
dist/components/WebSocketServerComponent.js
vendored
File diff suppressed because one or more lines are too long
7
dist/db/Migration.d.ts
vendored
7
dist/db/Migration.d.ts
vendored
@ -1,7 +0,0 @@
|
|||||||
export default abstract class Migration {
|
|
||||||
readonly version: number;
|
|
||||||
constructor(version: number);
|
|
||||||
shouldRun(currentVersion: number): Promise<boolean>;
|
|
||||||
abstract install(): Promise<void>;
|
|
||||||
abstract rollback(): Promise<void>;
|
|
||||||
}
|
|
20
dist/db/Migration.js
vendored
20
dist/db/Migration.js
vendored
@ -1,20 +0,0 @@
|
|||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
export default class Migration {
|
|
||||||
constructor(version) {
|
|
||||||
this.version = version;
|
|
||||||
}
|
|
||||||
shouldRun(currentVersion) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.version > currentVersion;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWlncmF0aW9uLmpzIiwic291cmNlUm9vdCI6Ii4vIiwic291cmNlcyI6WyJkYi9NaWdyYXRpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O0FBQUEsTUFBTSxDQUFDLE9BQU8sT0FBZ0IsU0FBUztJQUduQyxZQUFZLE9BQWU7UUFDdkIsSUFBSSxDQUFDLE9BQU8sR0FBRyxPQUFPLENBQUM7SUFDM0IsQ0FBQztJQUVLLFNBQVMsQ0FBQyxjQUFzQjs7WUFDbEMsT0FBTyxJQUFJLENBQUMsT0FBTyxHQUFHLGNBQWMsQ0FBQztRQUN6QyxDQUFDO0tBQUE7Q0FLSiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IGFic3RyYWN0IGNsYXNzIE1pZ3JhdGlvbiB7XG4gICAgcHVibGljIHJlYWRvbmx5IHZlcnNpb246IG51bWJlcjtcblxuICAgIGNvbnN0cnVjdG9yKHZlcnNpb246IG51bWJlcikge1xuICAgICAgICB0aGlzLnZlcnNpb24gPSB2ZXJzaW9uO1xuICAgIH1cblxuICAgIGFzeW5jIHNob3VsZFJ1bihjdXJyZW50VmVyc2lvbjogbnVtYmVyKTogUHJvbWlzZTxib29sZWFuPiB7XG4gICAgICAgIHJldHVybiB0aGlzLnZlcnNpb24gPiBjdXJyZW50VmVyc2lvbjtcbiAgICB9XG5cbiAgICBhYnN0cmFjdCBhc3luYyBpbnN0YWxsKCk6IFByb21pc2U8dm9pZD47XG5cbiAgICBhYnN0cmFjdCBhc3luYyByb2xsYmFjaygpOiBQcm9taXNlPHZvaWQ+O1xufSJdfQ==
|
|
58
dist/db/Model.d.ts
vendored
58
dist/db/Model.d.ts
vendored
@ -1,58 +0,0 @@
|
|||||||
import Validator from "./Validator";
|
|
||||||
import { Connection } from "mysql";
|
|
||||||
import Query from "./Query";
|
|
||||||
import { Request } from "express";
|
|
||||||
export default abstract class Model {
|
|
||||||
static getById<T extends Model>(id: number): Promise<T | null>;
|
|
||||||
static paginate<T extends Model>(request: Request, perPage?: number): Promise<T[]>;
|
|
||||||
protected static select(...fields: string[]): Query;
|
|
||||||
protected static update(data: {
|
|
||||||
[key: string]: any;
|
|
||||||
}): Query;
|
|
||||||
protected static delete(): Query;
|
|
||||||
protected static models<T extends Model>(query: Query): Promise<T[]>;
|
|
||||||
static loadRelation<T extends Model>(models: T[], relation: string, model: Function, localField: string): Promise<void>;
|
|
||||||
private static getFactory;
|
|
||||||
protected readonly properties: ModelProperty<any>[];
|
|
||||||
private readonly relations;
|
|
||||||
id?: number;
|
|
||||||
[key: string]: any;
|
|
||||||
constructor(data: any);
|
|
||||||
protected abstract defineProperties(): void;
|
|
||||||
protected defineProperty<T>(name: string, validator?: Validator<T> | RegExp): void;
|
|
||||||
private updateWithData;
|
|
||||||
protected beforeSave(exists: boolean, connection: Connection): Promise<void>;
|
|
||||||
protected afterSave(): Promise<void>;
|
|
||||||
save(connection?: Connection, postHook?: (callback: () => Promise<void>) => void): Promise<void>;
|
|
||||||
private saveTransaction;
|
|
||||||
static get table(): string;
|
|
||||||
get table(): string;
|
|
||||||
exists(): Promise<boolean>;
|
|
||||||
delete(): Promise<void>;
|
|
||||||
validate(onlyFormat?: boolean, connection?: Connection): Promise<void[]>;
|
|
||||||
private cache;
|
|
||||||
protected relation<T extends Model>(name: string): T | null;
|
|
||||||
}
|
|
||||||
export interface ModelFactory<T extends Model> {
|
|
||||||
(data: any): T;
|
|
||||||
}
|
|
||||||
declare class ModelProperty<T> {
|
|
||||||
readonly name: string;
|
|
||||||
private readonly validator;
|
|
||||||
private val?;
|
|
||||||
constructor(name: string, validator: Validator<T>);
|
|
||||||
validate(onlyFormat: boolean, connection?: Connection): Promise<void>;
|
|
||||||
get value(): T | undefined;
|
|
||||||
set value(val: T | undefined);
|
|
||||||
}
|
|
||||||
export declare class ModelCache {
|
|
||||||
private static readonly caches;
|
|
||||||
static cache(instance: Model): void;
|
|
||||||
static forget(instance: Model): void;
|
|
||||||
static all(table: string): {
|
|
||||||
[key: number]: Model;
|
|
||||||
} | undefined;
|
|
||||||
static get(table: string, id: number): Model | undefined;
|
|
||||||
}
|
|
||||||
export declare const EMAIL_REGEX: RegExp;
|
|
||||||
export {};
|
|
291
dist/db/Model.js
vendored
291
dist/db/Model.js
vendored
File diff suppressed because one or more lines are too long
23
dist/db/MysqlConnectionManager.d.ts
vendored
23
dist/db/MysqlConnectionManager.d.ts
vendored
@ -1,23 +0,0 @@
|
|||||||
import { Connection, FieldInfo, Pool } from 'mysql';
|
|
||||||
import Migration from "./Migration";
|
|
||||||
export interface QueryResult {
|
|
||||||
readonly results: any[];
|
|
||||||
readonly fields: FieldInfo[];
|
|
||||||
readonly other?: any;
|
|
||||||
foundRows?: number;
|
|
||||||
}
|
|
||||||
export declare function query(queryString: string, values?: any, connection?: Connection): Promise<QueryResult>;
|
|
||||||
export default class MysqlConnectionManager {
|
|
||||||
private static currentPool?;
|
|
||||||
private static databaseReady;
|
|
||||||
private static readonly migrations;
|
|
||||||
static registerMigration(migration: (version: number) => Migration): void;
|
|
||||||
static prepare(): Promise<void>;
|
|
||||||
static get pool(): Pool;
|
|
||||||
private static createPool;
|
|
||||||
static endPool(): Promise<void>;
|
|
||||||
static query(queryString: string, values?: any, connection?: Connection): Promise<QueryResult>;
|
|
||||||
static wrapTransaction<T>(transaction: (connection: Connection) => Promise<T>): Promise<T>;
|
|
||||||
private static rejectAndRollback;
|
|
||||||
private static handleMigrations;
|
|
||||||
}
|
|
168
dist/db/MysqlConnectionManager.js
vendored
168
dist/db/MysqlConnectionManager.js
vendored
File diff suppressed because one or more lines are too long
47
dist/db/Query.d.ts
vendored
47
dist/db/Query.d.ts
vendored
@ -1,47 +0,0 @@
|
|||||||
import { QueryResult } from "./MysqlConnectionManager";
|
|
||||||
import { Connection } from "mysql";
|
|
||||||
export default class Query {
|
|
||||||
static select(table: string, ...fields: string[]): Query;
|
|
||||||
static update(table: string, data: {
|
|
||||||
[key: string]: any;
|
|
||||||
}): Query;
|
|
||||||
static delete(table: string): Query;
|
|
||||||
private readonly type;
|
|
||||||
private readonly table;
|
|
||||||
private readonly fields;
|
|
||||||
private _where;
|
|
||||||
private _limit?;
|
|
||||||
private _offset?;
|
|
||||||
private _sortBy?;
|
|
||||||
private _sortDirection?;
|
|
||||||
private _foundRows;
|
|
||||||
private constructor();
|
|
||||||
where(field: string, value: string | Date | Query | any, operator?: WhereOperator, test?: WhereTest): Query;
|
|
||||||
whereNot(field: string, value: string | Date | Query | any, operator?: WhereOperator): Query;
|
|
||||||
orWhere(field: string, value: string | Date | Query | any): Query;
|
|
||||||
whereIn(field: string, value: any[]): Query;
|
|
||||||
limit(limit: number, offset?: number): Query;
|
|
||||||
first(): Query;
|
|
||||||
sortBy(field: string, direction?: 'ASC' | 'DESC'): Query;
|
|
||||||
withTotalRowCount(): Query;
|
|
||||||
toString(final?: boolean): string;
|
|
||||||
build(): string;
|
|
||||||
get variables(): any[];
|
|
||||||
isCacheable(): boolean;
|
|
||||||
execute(connection?: Connection): Promise<QueryResult>;
|
|
||||||
}
|
|
||||||
export declare enum QueryType {
|
|
||||||
SELECT = 0,
|
|
||||||
UPDATE = 1,
|
|
||||||
DELETE = 2
|
|
||||||
}
|
|
||||||
declare enum WhereOperator {
|
|
||||||
AND = "AND",
|
|
||||||
OR = "OR"
|
|
||||||
}
|
|
||||||
declare enum WhereTest {
|
|
||||||
EQUALS = "=",
|
|
||||||
DIFFERENT = "!=",
|
|
||||||
IN = " IN "
|
|
||||||
}
|
|
||||||
export {};
|
|
176
dist/db/Query.js
vendored
176
dist/db/Query.js
vendored
File diff suppressed because one or more lines are too long
86
dist/db/Validator.d.ts
vendored
86
dist/db/Validator.d.ts
vendored
@ -1,86 +0,0 @@
|
|||||||
import Model from "./Model";
|
|
||||||
import Query from "./Query";
|
|
||||||
import { Connection } from "mysql";
|
|
||||||
export default class Validator<T> {
|
|
||||||
private readonly steps;
|
|
||||||
private readonly validationAttributes;
|
|
||||||
private _min?;
|
|
||||||
private _max?;
|
|
||||||
/**
|
|
||||||
* @param thingName The name of the thing to validate.
|
|
||||||
* @param value The value to verify.
|
|
||||||
* @param onlyFormat {@code true} to only validate format properties, {@code false} otherwise.
|
|
||||||
* @param connection A connection to use in case of wrapped transactions.
|
|
||||||
*/
|
|
||||||
execute(thingName: string, value: T | undefined, onlyFormat: boolean, connection?: Connection): Promise<void>;
|
|
||||||
defined(): Validator<T>;
|
|
||||||
acceptUndefined(): Validator<T>;
|
|
||||||
equals(other?: T): Validator<T>;
|
|
||||||
regexp(regexp: RegExp): Validator<T>;
|
|
||||||
length(length: number): Validator<T>;
|
|
||||||
/**
|
|
||||||
* @param minLength included
|
|
||||||
* @param maxLength included
|
|
||||||
*/
|
|
||||||
between(minLength: number, maxLength: number): Validator<T>;
|
|
||||||
/**
|
|
||||||
* @param min included
|
|
||||||
*/
|
|
||||||
min(min: number): Validator<T>;
|
|
||||||
/**
|
|
||||||
* @param max included
|
|
||||||
*/
|
|
||||||
max(max: number): Validator<T>;
|
|
||||||
unique(model: Model, querySupplier?: () => Query): Validator<T>;
|
|
||||||
exists(modelClass: Function, foreignKey?: string): Validator<T>;
|
|
||||||
private addStep;
|
|
||||||
getValidationAttributes(): string[];
|
|
||||||
step(step: number): Validator<T>;
|
|
||||||
}
|
|
||||||
export declare class ValidationBag extends Error {
|
|
||||||
private readonly messages;
|
|
||||||
addMessage(err: ValidationError): void;
|
|
||||||
hasMessages(): boolean;
|
|
||||||
getMessages(): {
|
|
||||||
[p: string]: ValidationError;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
export declare abstract class ValidationError extends Error {
|
|
||||||
thingName?: string;
|
|
||||||
value?: any;
|
|
||||||
get name(): string;
|
|
||||||
}
|
|
||||||
export declare class BadLengthValidationError extends ValidationError {
|
|
||||||
private readonly expectedLength;
|
|
||||||
private readonly maxLength?;
|
|
||||||
constructor(expectedLength: number, maxLength?: number);
|
|
||||||
get message(): string;
|
|
||||||
}
|
|
||||||
export declare class BadValueValidationError extends ValidationError {
|
|
||||||
private readonly expectedValue;
|
|
||||||
constructor(expectedValue: any);
|
|
||||||
get message(): string;
|
|
||||||
}
|
|
||||||
export declare class OutOfRangeValidationError extends ValidationError {
|
|
||||||
private readonly min?;
|
|
||||||
private readonly max?;
|
|
||||||
constructor(min?: number, max?: number);
|
|
||||||
get message(): string;
|
|
||||||
}
|
|
||||||
export declare class InvalidFormatValidationError extends ValidationError {
|
|
||||||
get message(): string;
|
|
||||||
}
|
|
||||||
export declare class UndefinedValueValidationError extends ValidationError {
|
|
||||||
get message(): string;
|
|
||||||
}
|
|
||||||
export declare class AlreadyExistsValidationError extends ValidationError {
|
|
||||||
private readonly table;
|
|
||||||
constructor(table: string);
|
|
||||||
get message(): string;
|
|
||||||
}
|
|
||||||
export declare class UnknownRelationValidationError extends ValidationError {
|
|
||||||
private readonly table;
|
|
||||||
private readonly foreignKey?;
|
|
||||||
constructor(table: string, foreignKey?: string);
|
|
||||||
get message(): string;
|
|
||||||
}
|
|
261
dist/db/Validator.js
vendored
261
dist/db/Validator.js
vendored
File diff suppressed because one or more lines are too long
0
dist/index.d.ts
vendored
0
dist/index.d.ts
vendored
2
dist/index.js
vendored
2
dist/index.js
vendored
@ -1,2 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiLi8iLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIiLCJzb3VyY2VzQ29udGVudCI6WyIiXX0=
|
|
8
dist/migrations/CreateLogsTable.d.ts
vendored
8
dist/migrations/CreateLogsTable.d.ts
vendored
@ -1,8 +0,0 @@
|
|||||||
import Migration from "../db/Migration";
|
|
||||||
/**
|
|
||||||
* Must be the first migration
|
|
||||||
*/
|
|
||||||
export default class CreateLogsTable extends Migration {
|
|
||||||
install(): Promise<void>;
|
|
||||||
rollback(): Promise<void>;
|
|
||||||
}
|
|
37
dist/migrations/CreateLogsTable.js
vendored
37
dist/migrations/CreateLogsTable.js
vendored
@ -1,37 +0,0 @@
|
|||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
import Migration from "../db/Migration";
|
|
||||||
import { query } from "../db/MysqlConnectionManager";
|
|
||||||
/**
|
|
||||||
* Must be the first migration
|
|
||||||
*/
|
|
||||||
export default class CreateLogsTable extends Migration {
|
|
||||||
install() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
yield query('CREATE TABLE logs(' +
|
|
||||||
'id INT NOT NULL AUTO_INCREMENT,' +
|
|
||||||
'level TINYINT UNSIGNED NOT NULL,' +
|
|
||||||
'message TEXT NOT NULL,' +
|
|
||||||
'log_id BINARY(16),' +
|
|
||||||
'error_name VARCHAR(128),' +
|
|
||||||
'error_message VARCHAR(512),' +
|
|
||||||
'error_stack TEXT,' +
|
|
||||||
'created_at DATETIME NOT NULL DEFAULT NOW(),' +
|
|
||||||
'PRIMARY KEY (id)' +
|
|
||||||
')');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
rollback() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
yield query('DROP TABLE logs');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ3JlYXRlTG9nc1RhYmxlLmpzIiwic291cmNlUm9vdCI6Ii4vIiwic291cmNlcyI6WyJtaWdyYXRpb25zL0NyZWF0ZUxvZ3NUYWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFBQSxPQUFPLFNBQVMsTUFBTSxpQkFBaUIsQ0FBQztBQUN4QyxPQUFPLEVBQUMsS0FBSyxFQUFDLE1BQU0sOEJBQThCLENBQUM7QUFFbkQ7O0dBRUc7QUFDSCxNQUFNLENBQUMsT0FBTyxPQUFPLGVBQWdCLFNBQVEsU0FBUztJQUM1QyxPQUFPOztZQUNULE1BQU0sS0FBSyxDQUFDLG9CQUFvQjtnQkFDNUIsaUNBQWlDO2dCQUNqQy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ayBURVhULCcgK1xuICAgICAgICAgICAgJ2NyZWF0ZWRfYXQgREFURVRJTUUgTk9UIE5VTEwgREVGQVVMVCBOT1coKSwnICtcbiAgICAgICAgICAgICdQUklNQVJZIEtFWSAoaWQpJyArXG4gICAgICAgICAgICAnKScpO1xuICAgIH1cblxuICAgIGFzeW5jIHJvbGxiYWNrKCk6IFByb21pc2U8dm9pZD4ge1xuICAgICAgICBhd2FpdCBxdWVyeSgnRFJPUCBUQUJMRSBsb2dzJyk7XG4gICAgfVxufSJdfQ==
|
|
9
dist/migrations/CreateMigrationsTable.d.ts
vendored
9
dist/migrations/CreateMigrationsTable.d.ts
vendored
@ -1,9 +0,0 @@
|
|||||||
import Migration from "../db/Migration";
|
|
||||||
/**
|
|
||||||
* Must be the first migration
|
|
||||||
*/
|
|
||||||
export default class CreateMigrationsTable extends Migration {
|
|
||||||
shouldRun(currentVersion: number): Promise<boolean>;
|
|
||||||
install(): Promise<void>;
|
|
||||||
rollback(): Promise<void>;
|
|
||||||
}
|
|
48
dist/migrations/CreateMigrationsTable.js
vendored
48
dist/migrations/CreateMigrationsTable.js
vendored
@ -1,48 +0,0 @@
|
|||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
import Migration from "../db/Migration";
|
|
||||||
import { query } from "../db/MysqlConnectionManager";
|
|
||||||
/**
|
|
||||||
* Must be the first migration
|
|
||||||
*/
|
|
||||||
export default class CreateMigrationsTable extends Migration {
|
|
||||||
shouldRun(currentVersion) {
|
|
||||||
const _super = Object.create(null, {
|
|
||||||
shouldRun: { get: () => super.shouldRun }
|
|
||||||
});
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
|
||||||
yield query('SELECT 1 FROM migrations LIMIT 1');
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
if (e.code !== 'ER_NO_SUCH_TABLE') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return yield _super.shouldRun.call(this, currentVersion);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
install() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
yield query('CREATE TABLE migrations(' +
|
|
||||||
'id INT NOT NULL,' +
|
|
||||||
'name VARCHAR(64) NOT NULL,' +
|
|
||||||
'migration_date DATE,' +
|
|
||||||
'PRIMARY KEY (id)' +
|
|
||||||
')');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
rollback() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
yield query('DROP TABLE migrations');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ3JlYXRlTWlncmF0aW9uc1RhYmxlLmpzIiwic291cmNlUm9vdCI6Ii4vIiwic291cmNlcyI6WyJtaWdyYXRpb25zL0NyZWF0ZU1pZ3JhdGlvbnNUYWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFBQSxPQUFPLFNBQVMsTUFBTSxpQkFBaUIsQ0FBQztBQUN4QyxPQUFPLEVBQUMsS0FBSyxFQUFDLE1BQU0sOEJBQThCLENBQUM7QUFFbkQ7O0dBRUc7QUFDSCxNQUFNLENBQUMsT0FBTyxPQUFPLHFCQUFzQixTQUFRLFNBQVM7SUFDbEQsU0FBUyxDQUFDLGNBQXNCOzs7OztZQU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jYXRjaCAoZSkge1xuICAgICAgICAgICAgaWYgKGUuY29kZSAhPT0gJ0VSX05PX1NVQ0hfVEFCTEUnKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGF3YWl0IHN1cGVyLnNob3VsZFJ1bihjdXJyZW50VmVyc2lvbik7XG4gICAgfVxuXG4gICAgYXN5bmMgaW5zdGFsbCgpOiBQcm9taXNlPHZvaWQ+IHtcbiAgICAgICAgYXdhaXQgcXVlcnkoJ0NSRUFURSBUQUJMRSBtaWdyYXRpb25zKCcgK1xuICAgICAgICAgICAgJ2lkIElOVCBOT1QgTlVMTCwnICtcbiAgICAgICAgICAgICduYW1lIFZBUkNIQVIoNjQpIE5PVCBOVUxMLCcgK1xuICAgICAgICAgICAgJ21pZ3JhdGlvbl9kYXRlIERBVEUsJyArXG4gICAgICAgICAgICAnUFJJTUFSWSBLRVkgKGlkKScgK1xuICAgICAgICAgICAgJyknKTtcbiAgICB9XG5cbiAgICBhc3luYyByb2xsYmFjaygpOiBQcm9taXNlPHZvaWQ+IHtcbiAgICAgICAgYXdhaXQgcXVlcnkoJ0RST1AgVEFCTEUgbWlncmF0aW9ucycpO1xuICAgIH1cbn0iXX0=
|
|
21
dist/models/Log.d.ts
vendored
21
dist/models/Log.d.ts
vendored
@ -1,21 +0,0 @@
|
|||||||
/// <reference types="node" />
|
|
||||||
import Model from "../db/Model";
|
|
||||||
import { LogLevelKeys } from "../Logger";
|
|
||||||
export default class Log extends Model {
|
|
||||||
private level?;
|
|
||||||
message?: string;
|
|
||||||
private log_id?;
|
|
||||||
private error_name?;
|
|
||||||
private error_message?;
|
|
||||||
private error_stack?;
|
|
||||||
private created_at?;
|
|
||||||
protected defineProperties(): void;
|
|
||||||
getLevel(): LogLevelKeys;
|
|
||||||
setLevel(level: LogLevelKeys): void;
|
|
||||||
getLogID(): string | null;
|
|
||||||
setLogID(buffer: Buffer): void;
|
|
||||||
getErrorName(): string;
|
|
||||||
getErrorMessage(): string;
|
|
||||||
getErrorStack(): string;
|
|
||||||
setError(error?: Error): void;
|
|
||||||
}
|
|
56
dist/models/Log.js
vendored
56
dist/models/Log.js
vendored
File diff suppressed because one or more lines are too long
49
dist/package.json
vendored
49
dist/package.json
vendored
@ -1,49 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "wms-core",
|
|
||||||
"version": "0.1.1",
|
|
||||||
"description": "Node web framework",
|
|
||||||
"repository": "git@gitlab.com:ArisuOngaku/wms-core.git",
|
|
||||||
"author": "Alice Gaudon <alice@gaudon.pro>",
|
|
||||||
"license": "MIT",
|
|
||||||
"publishConfig": {
|
|
||||||
"registry": "http://127.0.0.1:4873",
|
|
||||||
"access": "restricted"
|
|
||||||
},
|
|
||||||
"main": "dist/index.js",
|
|
||||||
"types": "dist/index.d.ts",
|
|
||||||
"scripts": {
|
|
||||||
"build": "rm -r dist && tsc && cp package.json dist/",
|
|
||||||
"publish_to_local": "yarn build && cd dist && yarn publish"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/config": "^0.0.36",
|
|
||||||
"@types/connect-flash": "^0.0.35",
|
|
||||||
"@types/connect-redis": "^0.0.13",
|
|
||||||
"@types/cookie": "^0.3.3",
|
|
||||||
"@types/cookie-parser": "^1.4.2",
|
|
||||||
"@types/express": "^4.17.6",
|
|
||||||
"@types/mjml": "^4.0.4",
|
|
||||||
"@types/mysql": "^2.15.10",
|
|
||||||
"@types/nodemailer": "^6.4.0",
|
|
||||||
"@types/nunjucks": "^3.1.3",
|
|
||||||
"@types/on-finished": "^2.3.1",
|
|
||||||
"@types/uuid": "^7.0.2",
|
|
||||||
"@types/ws": "^7.2.4",
|
|
||||||
"typescript": "^3.8.3"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"config": "^3.3.1",
|
|
||||||
"connect-flash": "^0.1.1",
|
|
||||||
"connect-redis": "^4.0.4",
|
|
||||||
"cookie": "^0.4.1",
|
|
||||||
"cookie-parser": "^1.4.5",
|
|
||||||
"express": "^4.17.1",
|
|
||||||
"mjml": "^4.6.2",
|
|
||||||
"mysql": "^2.18.1",
|
|
||||||
"nodemailer": "^6.4.6",
|
|
||||||
"nunjucks": "^3.2.1",
|
|
||||||
"on-finished": "^2.3.0",
|
|
||||||
"uuid": "^7.0.3",
|
|
||||||
"ws": "^7.2.3"
|
|
||||||
}
|
|
||||||
}
|
|
17
package.json
17
package.json
@ -1,21 +1,21 @@
|
|||||||
{
|
{
|
||||||
"name": "wms-core",
|
"name": "wms-core",
|
||||||
"version": "0.1.0",
|
"version": "0.1.5",
|
||||||
"description": "Node web framework",
|
"description": "Node web framework",
|
||||||
"repository": "git@gitlab.com:ArisuOngaku/wms-core.git",
|
"repository": "git@gitlab.com:ArisuOngaku/wms-core.git",
|
||||||
"author": "Alice Gaudon <alice@gaudon.pro>",
|
"author": "Alice Gaudon <alice@gaudon.pro>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": true,
|
"publishConfig": {
|
||||||
|
"registry": "http://127.0.0.1:4873",
|
||||||
|
"access": "restricted"
|
||||||
|
},
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rm -r dist && tsc",
|
"build": "rm -r dist && tsc && cp package.json dist/ && mkdir dist/types && cp src/types/* dist/types/",
|
||||||
"prepublishOnly": "yarn build"
|
"publish_to_local": "yarn build && cd dist && yarn publish"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^3.8.3"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@types/config": "^0.0.36",
|
"@types/config": "^0.0.36",
|
||||||
"@types/connect-flash": "^0.0.35",
|
"@types/connect-flash": "^0.0.35",
|
||||||
"@types/connect-redis": "^0.0.13",
|
"@types/connect-redis": "^0.0.13",
|
||||||
@ -29,6 +29,9 @@
|
|||||||
"@types/on-finished": "^2.3.1",
|
"@types/on-finished": "^2.3.1",
|
||||||
"@types/uuid": "^7.0.2",
|
"@types/uuid": "^7.0.2",
|
||||||
"@types/ws": "^7.2.4",
|
"@types/ws": "^7.2.4",
|
||||||
|
"typescript": "^3.8.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
"config": "^3.3.1",
|
"config": "^3.3.1",
|
||||||
"connect-flash": "^0.1.1",
|
"connect-flash": "^0.1.1",
|
||||||
"connect-redis": "^4.0.4",
|
"connect-redis": "^4.0.4",
|
||||||
|
24
src/types/Express.d.ts
vendored
24
src/types/Express.d.ts
vendored
@ -1,20 +1,22 @@
|
|||||||
import {Environment} from "nunjucks";
|
import {Environment} from "nunjucks";
|
||||||
import Model from "../db/Model";
|
import Model from "../db/Model";
|
||||||
|
|
||||||
declare module 'express-serve-static-core' {
|
declare global {
|
||||||
export interface Request {
|
namespace Express {
|
||||||
env: Environment;
|
export interface Request {
|
||||||
models: { [p: string]: Model | null };
|
env: Environment;
|
||||||
modelCollections: { [p: string]: Model[] | null };
|
models: { [p: string]: Model | null };
|
||||||
|
modelCollections: { [p: string]: Model[] | null };
|
||||||
|
|
||||||
flash(): { [key: string]: string[] };
|
flash(): { [key: string]: string[] };
|
||||||
|
|
||||||
flash(message: string): any;
|
flash(message: string): any;
|
||||||
|
|
||||||
flash(event: string, message: any): any;
|
flash(event: string, message: any): any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Response {
|
export interface Response {
|
||||||
redirectBack(defaultUrl?: string): any;
|
redirectBack(defaultUrl?: string): any;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES6",
|
"target": "ES2020",
|
||||||
|
"module": "CommonJS",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"stripInternal": true,
|
"stripInternal": true,
|
||||||
|
|
||||||
@ -11,9 +12,10 @@
|
|||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
|
|
||||||
"moduleResolution": "Node",
|
"moduleResolution": "Node",
|
||||||
"baseUrl": ".",
|
"esModuleInterop": true,
|
||||||
|
"baseUrl": "dist",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"sourceRoot": ".",
|
"sourceRoot": "src",
|
||||||
"inlineSourceMap": true,
|
"inlineSourceMap": true,
|
||||||
"inlineSources": true,
|
"inlineSources": true,
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
|
Loading…
Reference in New Issue
Block a user