UNPKG

2.76 kBTypeScriptView Raw
1import { Express } from "express";
2import * as express from "express";
3import * as nunjucks from "nunjucks";
4import "reflect-metadata";
5import * as multer from "multer";
6import Config from "./config";
7import BaseModule from "./base.module";
8import ErrorController from "./error.controller";
9import User from "./entities/user.entity";
10import { APIResponseWrapper } from "./api-response-wrapper";
11/**
12 * Utility function to check if we are in the production environment.
13 * @return true if the NODE_ENV is set to "production", false otherwise
14 */
15export declare function isProduction(): boolean;
16/**
17 * Retrieve the preferred language from an express request, using the accepts-languages
18 * header value.
19 * @param req the express request
20 * @return the two letter lower-cased language, or "*" (wildcard), or null
21 */
22export declare function getLanguageFromRequest(req: express.Request): string;
23export declare let app: App;
24/**
25 * The App class contains the initialization code for a Lynx application.
26 */
27export default class App {
28 express: Express;
29 httpServer: any;
30 private readonly _config;
31 private readonly _nunjucksEnvironment;
32 private readonly _upload;
33 private _templateMap;
34 private _modules;
35 private _errorController;
36 apiResponseWrapper: APIResponseWrapper;
37 get config(): Config;
38 get templateMap(): any;
39 get nunjucksEnvironment(): nunjucks.Environment;
40 get upload(): multer.Instance;
41 /**
42 * This property allow the customization of the standard error controller.
43 * You need to create the controller using its standard constructor:
44 * new MyCustomErrorController(app)
45 */
46 set customErrorController(ctrl: ErrorController);
47 constructor(config: Config, modules?: BaseModule[]);
48 private recursiveGenerateTemplateMap;
49 private generateTemplateMap;
50 private recursiveExecuteMigrations;
51 /**
52 * This method will execute the migrations.
53 * By default, this method will be executed automatically during the app
54 * startup. In some scenario, like hight-scalability, this behaviour could
55 * be unwanted. Thus, it is possibly otherwise to explicitly call this method
56 * in some other way (for example, connecting it to a standard http route).
57 */
58 executeMigrations(): Promise<void>;
59 private loadTranslations;
60 private loadMiddlewares;
61 private loadControllers;
62 startServer(port: number): void;
63 route(name: string, parameters?: any): string;
64 translate(str: string, req: express.Request): string;
65 generateTokenForUser(user: User): string;
66}
67declare global {
68 interface Array<T> {
69 serialize(): Array<any>;
70 removeHiddenField(field: string): void;
71 addHiddenField(field: string): void;
72 }
73}