@ticatec/common-express-server 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -21
- package/dist/AppConf.d.ts +0 -31
- package/dist/AppConf.js +0 -57
- package/dist/AppConf.js.map +0 -1
- package/dist/BaseServer.d.ts +0 -125
- package/dist/BaseServer.js +0 -155
- package/dist/BaseServer.js.map +0 -1
- package/dist/CommonRouterHelper.d.ts +0 -64
- package/dist/CommonRouterHelper.js +0 -134
- package/dist/CommonRouterHelper.js.map +0 -1
- package/dist/CommonRoutes.d.ts +0 -33
- package/dist/CommonRoutes.js +0 -57
- package/dist/CommonRoutes.js.map +0 -1
- package/dist/LoggedUser.d.ts +0 -33
- package/dist/LoggedUser.js +0 -3
- package/dist/LoggedUser.js.map +0 -1
- package/dist/common/AdminBaseController.d.ts +0 -30
- package/dist/common/AdminBaseController.js +0 -41
- package/dist/common/AdminBaseController.js.map +0 -1
- package/dist/common/AdminSearchController.d.ts +0 -13
- package/dist/common/AdminSearchController.js +0 -26
- package/dist/common/AdminSearchController.js.map +0 -1
- package/dist/common/BaseController.d.ts +0 -28
- package/dist/common/BaseController.js +0 -35
- package/dist/common/BaseController.js.map +0 -1
- package/dist/common/CommonController.d.ts +0 -96
- package/dist/common/CommonController.js +0 -129
- package/dist/common/CommonController.js.map +0 -1
- package/dist/common/TenantBaseController.d.ts +0 -30
- package/dist/common/TenantBaseController.js +0 -41
- package/dist/common/TenantBaseController.js.map +0 -1
- package/dist/common/TenantSearchController.d.ts +0 -13
- package/dist/common/TenantSearchController.js +0 -27
- package/dist/common/TenantSearchController.js.map +0 -1
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -30
- package/dist/index.js.map +0 -1
- package/dist/lib/CommonProcessor.d.ts +0 -49
- package/dist/lib/CommonProcessor.js +0 -99
- package/dist/lib/CommonProcessor.js.map +0 -1
- package/dist/lib/ProcessorManager.d.ts +0 -14
- package/dist/lib/ProcessorManager.js +0 -30
- package/dist/lib/ProcessorManager.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,32 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ticatec/common-express-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A comprehensive TypeScript library providing common classes, controllers, and middleware for building scalable Express.js applications with multi-tenant support.",
|
|
5
|
-
"main": "
|
|
6
|
-
"types": "
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"require": "./dist/index.js"
|
|
12
|
-
},
|
|
13
|
-
"./*": {
|
|
14
|
-
"types": "./dist/*.d.ts",
|
|
15
|
-
"import": "./dist/*.js",
|
|
16
|
-
"require": "./dist/*.js"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"types": "./index.d.ts",
|
|
19
7
|
"scripts": {
|
|
20
|
-
"build": "rm -rf ./dist && tsc",
|
|
21
|
-
"build:watch": "tsc --watch",
|
|
22
8
|
"clean": "rm -rf ./dist",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
9
|
+
"build": "npm run clean && tsc",
|
|
10
|
+
"build:watch": "tsc --watch",
|
|
11
|
+
"move-files": "cp .npmignore ./dist/ 2>/dev/null || : && cp *.md ./dist/ && cp package.json ./dist/",
|
|
12
|
+
"prepublish-only": "npm run build && npm run move-files",
|
|
13
|
+
"publish-public": "npm run prepublish-only && cd ./dist && npm publish --access public",
|
|
25
14
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
26
15
|
"lint": "echo \"No linting configured\"",
|
|
27
16
|
"typecheck": "tsc --noEmit",
|
|
28
|
-
"dev": "tsc --watch"
|
|
29
|
-
"publish-public": "npm run build && npm publish --access public"
|
|
17
|
+
"dev": "tsc --watch"
|
|
30
18
|
},
|
|
31
19
|
"keywords": [
|
|
32
20
|
"express",
|
package/dist/AppConf.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Application configuration singleton class
|
|
3
|
-
*/
|
|
4
|
-
export default class AppConf {
|
|
5
|
-
/** Configuration object */
|
|
6
|
-
private readonly conf;
|
|
7
|
-
/** Singleton instance */
|
|
8
|
-
static instance: AppConf;
|
|
9
|
-
/**
|
|
10
|
-
* Private constructor for singleton pattern
|
|
11
|
-
* @param conf Configuration object
|
|
12
|
-
*/
|
|
13
|
-
private constructor();
|
|
14
|
-
/**
|
|
15
|
-
* Gets the singleton instance
|
|
16
|
-
* @returns AppConf instance or null if not initialized
|
|
17
|
-
*/
|
|
18
|
-
static getInstance(): AppConf;
|
|
19
|
-
/**
|
|
20
|
-
* Initializes the configuration singleton
|
|
21
|
-
* @param config Configuration object
|
|
22
|
-
* @returns AppConf instance
|
|
23
|
-
*/
|
|
24
|
-
static init(config: any): AppConf;
|
|
25
|
-
/**
|
|
26
|
-
* Gets configuration value by key (supports dot notation)
|
|
27
|
-
* @param key Configuration key (can use dot notation like 'server.port')
|
|
28
|
-
* @returns Configuration value or undefined if not found
|
|
29
|
-
*/
|
|
30
|
-
get(key: string): any;
|
|
31
|
-
}
|
package/dist/AppConf.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Application configuration singleton class
|
|
5
|
-
*/
|
|
6
|
-
class AppConf {
|
|
7
|
-
/**
|
|
8
|
-
* Private constructor for singleton pattern
|
|
9
|
-
* @param conf Configuration object
|
|
10
|
-
*/
|
|
11
|
-
constructor(conf) {
|
|
12
|
-
this.conf = conf;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Gets the singleton instance
|
|
16
|
-
* @returns AppConf instance or null if not initialized
|
|
17
|
-
*/
|
|
18
|
-
static getInstance() {
|
|
19
|
-
return AppConf.instance;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Initializes the configuration singleton
|
|
23
|
-
* @param config Configuration object
|
|
24
|
-
* @returns AppConf instance
|
|
25
|
-
*/
|
|
26
|
-
static init(config) {
|
|
27
|
-
console.debug('Initializing configuration center', config);
|
|
28
|
-
if (AppConf.instance == null) {
|
|
29
|
-
AppConf.instance = new AppConf(config);
|
|
30
|
-
}
|
|
31
|
-
return AppConf.instance;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Gets configuration value by key (supports dot notation)
|
|
35
|
-
* @param key Configuration key (can use dot notation like 'server.port')
|
|
36
|
-
* @returns Configuration value or undefined if not found
|
|
37
|
-
*/
|
|
38
|
-
get(key) {
|
|
39
|
-
if (!key)
|
|
40
|
-
return undefined;
|
|
41
|
-
const keys = key.split('.');
|
|
42
|
-
let result = this.conf;
|
|
43
|
-
for (const k of keys) {
|
|
44
|
-
if (result && typeof result === 'object' && k in result) {
|
|
45
|
-
result = result[k];
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/** Singleton instance */
|
|
55
|
-
AppConf.instance = null;
|
|
56
|
-
exports.default = AppConf;
|
|
57
|
-
//# sourceMappingURL=AppConf.js.map
|
package/dist/AppConf.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AppConf.js","sourceRoot":"src/","sources":["AppConf.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,MAAqB,OAAO;IAOxB;;;OAGG;IACH,YAAoB,IAAS;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,WAAW;QACd,OAAO,OAAO,CAAC,QAAQ,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAC,MAAW;QACnB,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;QAC3D,IAAI,OAAO,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;YAC3B,OAAO,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,OAAO,CAAC,QAAQ,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,GAAW;QACX,IAAI,CAAC,GAAG;YAAE,OAAO,SAAS,CAAC;QAE3B,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC;QAEvB,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;YACnB,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,IAAI,MAAM,EAAE,CAAC;gBACtD,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACvB,CAAC;iBAAM,CAAC;gBACJ,OAAO,SAAS,CAAC;YACrB,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;;AApDD,yBAAyB;AAClB,gBAAQ,GAAY,IAAI,CAAC;kBALf,OAAO"}
|
package/dist/BaseServer.d.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { Express } from 'express';
|
|
2
|
-
import CommonRouterHelper from "./CommonRouterHelper";
|
|
3
|
-
import http from "http";
|
|
4
|
-
import { Logger } from "log4js";
|
|
5
|
-
/**
|
|
6
|
-
* Function signature for module loader
|
|
7
|
-
*/
|
|
8
|
-
export type moduleLoader = () => Promise<any>;
|
|
9
|
-
/**
|
|
10
|
-
* Abstract base server class providing common functionality for Express servers
|
|
11
|
-
* @template T The type of CommonRouterHelper this server uses
|
|
12
|
-
*/
|
|
13
|
-
export default abstract class BaseServer<T extends CommonRouterHelper> {
|
|
14
|
-
/** Logger instance for this server */
|
|
15
|
-
protected logger: Logger;
|
|
16
|
-
/** Router helper instance */
|
|
17
|
-
protected helper: T;
|
|
18
|
-
/** Context root path for the server */
|
|
19
|
-
protected contextRoot: string;
|
|
20
|
-
/**
|
|
21
|
-
* Protected constructor for base server
|
|
22
|
-
* @protected
|
|
23
|
-
*/
|
|
24
|
-
protected constructor();
|
|
25
|
-
/**
|
|
26
|
-
* Gets the router helper instance for this server
|
|
27
|
-
* @returns RouterHelper instance
|
|
28
|
-
* @protected
|
|
29
|
-
* @abstract
|
|
30
|
-
*/
|
|
31
|
-
protected abstract getHelper(): T;
|
|
32
|
-
/**
|
|
33
|
-
* Loads configuration file
|
|
34
|
-
* @returns Promise that resolves when configuration is loaded
|
|
35
|
-
* @protected
|
|
36
|
-
* @abstract
|
|
37
|
-
*/
|
|
38
|
-
protected abstract loadConfigFile(): Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Writes the listening port to check.dat file
|
|
41
|
-
* @param port The port number to write
|
|
42
|
-
* @param fileName The file name to write to (default: './check.dat')
|
|
43
|
-
* @protected
|
|
44
|
-
*/
|
|
45
|
-
protected writeCheckFile(port: number, fileName?: string): void;
|
|
46
|
-
/**
|
|
47
|
-
* Starts up the server
|
|
48
|
-
* @returns Promise that resolves when server startup is complete
|
|
49
|
-
*/
|
|
50
|
-
startup(): Promise<void>;
|
|
51
|
-
/**
|
|
52
|
-
* Interceptor function called after web server is created
|
|
53
|
-
* @param server The HTTP server instance
|
|
54
|
-
* @returns Promise that resolves when post-creation setup is complete
|
|
55
|
-
* @protected
|
|
56
|
-
*/
|
|
57
|
-
protected postServerCreated(server: http.Server): Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Gets web configuration
|
|
60
|
-
* @returns Web configuration object
|
|
61
|
-
* @protected
|
|
62
|
-
* @abstract
|
|
63
|
-
*/
|
|
64
|
-
protected abstract getWebConf(): any;
|
|
65
|
-
/**
|
|
66
|
-
* Interceptor function called before startup
|
|
67
|
-
* @returns Promise that resolves when pre-startup setup is complete
|
|
68
|
-
* @protected
|
|
69
|
-
*/
|
|
70
|
-
protected beforeStart(): Promise<void>;
|
|
71
|
-
/**
|
|
72
|
-
* Gets the health check endpoint path
|
|
73
|
-
* @returns The health check path
|
|
74
|
-
* @protected
|
|
75
|
-
*/
|
|
76
|
-
protected getHealthCheckPath(): string;
|
|
77
|
-
/**
|
|
78
|
-
* Adds health check endpoint to the Express app
|
|
79
|
-
* @param app Express application instance
|
|
80
|
-
* @protected
|
|
81
|
-
*/
|
|
82
|
-
protected addHealthCheck(app: Express): void;
|
|
83
|
-
/**
|
|
84
|
-
* Starts the web server with given configuration
|
|
85
|
-
* @param webConf Web server configuration
|
|
86
|
-
* @returns Promise that resolves to the HTTP server instance
|
|
87
|
-
* @protected
|
|
88
|
-
*/
|
|
89
|
-
protected startWebServer(webConf: any): Promise<unknown>;
|
|
90
|
-
/**
|
|
91
|
-
* Binds static site resources
|
|
92
|
-
* @param app Express application instance
|
|
93
|
-
* @returns Promise that resolves when static binding is complete
|
|
94
|
-
* @protected
|
|
95
|
-
*/
|
|
96
|
-
protected bindStaticSite(app: Express): Promise<void>;
|
|
97
|
-
/**
|
|
98
|
-
* Initializes Express application
|
|
99
|
-
* @param app Express application instance
|
|
100
|
-
* @protected
|
|
101
|
-
*/
|
|
102
|
-
protected setupExpress(app: Express): void;
|
|
103
|
-
/**
|
|
104
|
-
* Binds a route to the Express application
|
|
105
|
-
* @param app Express application instance
|
|
106
|
-
* @param path The route path
|
|
107
|
-
* @param loader Module loader function that returns the route class
|
|
108
|
-
* @returns Promise that resolves when route binding is complete
|
|
109
|
-
* @protected
|
|
110
|
-
*/
|
|
111
|
-
protected bindRoutes(app: Express, path: string, loader: moduleLoader): Promise<void>;
|
|
112
|
-
/**
|
|
113
|
-
* Sets up routes for the application
|
|
114
|
-
* @param app Express application instance
|
|
115
|
-
* @returns Promise that resolves when all routes are set up
|
|
116
|
-
* @protected
|
|
117
|
-
* @abstract
|
|
118
|
-
*/
|
|
119
|
-
protected abstract setupRoutes(app: Express): Promise<void>;
|
|
120
|
-
/**
|
|
121
|
-
* Static method to start a server instance
|
|
122
|
-
* @param server The server instance to start
|
|
123
|
-
*/
|
|
124
|
-
static startup(server: BaseServer<any>): void;
|
|
125
|
-
}
|
package/dist/BaseServer.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const express_1 = __importDefault(require("express"));
|
|
7
|
-
const express_exception_1 = require("@ticatec/express-exception");
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
/**
|
|
10
|
-
* Abstract base server class providing common functionality for Express servers
|
|
11
|
-
* @template T The type of CommonRouterHelper this server uses
|
|
12
|
-
*/
|
|
13
|
-
class BaseServer {
|
|
14
|
-
/**
|
|
15
|
-
* Protected constructor for base server
|
|
16
|
-
* @protected
|
|
17
|
-
*/
|
|
18
|
-
constructor() {
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Writes the listening port to check.dat file
|
|
22
|
-
* @param port The port number to write
|
|
23
|
-
* @param fileName The file name to write to (default: './check.dat')
|
|
24
|
-
* @protected
|
|
25
|
-
*/
|
|
26
|
-
writeCheckFile(port, fileName = './check.dat') {
|
|
27
|
-
try {
|
|
28
|
-
this.logger.debug('Port', port);
|
|
29
|
-
fs_1.default.writeFileSync(fileName, `${port}`);
|
|
30
|
-
}
|
|
31
|
-
catch (err) {
|
|
32
|
-
this.logger.error('Error writing port file', err);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Starts up the server
|
|
37
|
-
* @returns Promise that resolves when server startup is complete
|
|
38
|
-
*/
|
|
39
|
-
async startup() {
|
|
40
|
-
await this.loadConfigFile();
|
|
41
|
-
try {
|
|
42
|
-
await this.beforeStart();
|
|
43
|
-
this.helper = this.getHelper();
|
|
44
|
-
let webConf = this.getWebConf();
|
|
45
|
-
this.writeCheckFile(webConf.port);
|
|
46
|
-
this.contextRoot = webConf.contextRoot;
|
|
47
|
-
await this.startWebServer(webConf);
|
|
48
|
-
}
|
|
49
|
-
catch (err) {
|
|
50
|
-
this.logger.error('Startup failed, reason:', err);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Interceptor function called after web server is created
|
|
55
|
-
* @param server The HTTP server instance
|
|
56
|
-
* @returns Promise that resolves when post-creation setup is complete
|
|
57
|
-
* @protected
|
|
58
|
-
*/
|
|
59
|
-
async postServerCreated(server) {
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Interceptor function called before startup
|
|
63
|
-
* @returns Promise that resolves when pre-startup setup is complete
|
|
64
|
-
* @protected
|
|
65
|
-
*/
|
|
66
|
-
async beforeStart() {
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Gets the health check endpoint path
|
|
70
|
-
* @returns The health check path
|
|
71
|
-
* @protected
|
|
72
|
-
*/
|
|
73
|
-
getHealthCheckPath() {
|
|
74
|
-
return '/health-check';
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Adds health check endpoint to the Express app
|
|
78
|
-
* @param app Express application instance
|
|
79
|
-
* @protected
|
|
80
|
-
*/
|
|
81
|
-
addHealthCheck(app) {
|
|
82
|
-
let path = this.getHealthCheckPath();
|
|
83
|
-
this.logger.debug('Loading system health check', path);
|
|
84
|
-
if (path) {
|
|
85
|
-
app.get(path, (req, res) => { res.send(''); });
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Starts the web server with given configuration
|
|
90
|
-
* @param webConf Web server configuration
|
|
91
|
-
* @returns Promise that resolves to the HTTP server instance
|
|
92
|
-
* @protected
|
|
93
|
-
*/
|
|
94
|
-
async startWebServer(webConf) {
|
|
95
|
-
let app = (0, express_1.default)();
|
|
96
|
-
app.disable("x-powered-by");
|
|
97
|
-
app.use(this.helper.setNoCache);
|
|
98
|
-
this.addHealthCheck(app);
|
|
99
|
-
this.setupExpress(app);
|
|
100
|
-
await this.bindStaticSite(app);
|
|
101
|
-
await this.setupRoutes(app);
|
|
102
|
-
app.use(this.helper.actionNotFound());
|
|
103
|
-
app.use((err, req, res, next) => {
|
|
104
|
-
this.logger.debug("application error: ", err);
|
|
105
|
-
(0, express_exception_1.handleError)(err, req, res);
|
|
106
|
-
});
|
|
107
|
-
return new Promise(resolve => {
|
|
108
|
-
let server = app.listen(webConf.port, webConf.ip, () => {
|
|
109
|
-
this.logger.info(`Web service started successfully, listening on IP: ${webConf.ip}, port: ${webConf.port}`);
|
|
110
|
-
this.postServerCreated(server);
|
|
111
|
-
resolve(server);
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Binds static site resources
|
|
117
|
-
* @param app Express application instance
|
|
118
|
-
* @returns Promise that resolves when static binding is complete
|
|
119
|
-
* @protected
|
|
120
|
-
*/
|
|
121
|
-
async bindStaticSite(app) {
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Initializes Express application
|
|
125
|
-
* @param app Express application instance
|
|
126
|
-
* @protected
|
|
127
|
-
*/
|
|
128
|
-
setupExpress(app) {
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Binds a route to the Express application
|
|
132
|
-
* @param app Express application instance
|
|
133
|
-
* @param path The route path
|
|
134
|
-
* @param loader Module loader function that returns the route class
|
|
135
|
-
* @returns Promise that resolves when route binding is complete
|
|
136
|
-
* @protected
|
|
137
|
-
*/
|
|
138
|
-
async bindRoutes(app, path, loader) {
|
|
139
|
-
let clazz = (await loader()).default;
|
|
140
|
-
let router = new clazz(this.helper);
|
|
141
|
-
router.bindRouter(app, `${this.contextRoot}${path}`);
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Static method to start a server instance
|
|
145
|
-
* @param server The server instance to start
|
|
146
|
-
*/
|
|
147
|
-
static startup(server) {
|
|
148
|
-
server.startup().then(() => {
|
|
149
|
-
}).catch(ex => {
|
|
150
|
-
console.error('Server startup error', ex);
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
exports.default = BaseServer;
|
|
155
|
-
//# sourceMappingURL=BaseServer.js.map
|
package/dist/BaseServer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseServer.js","sourceRoot":"src/","sources":["BaseServer.ts"],"names":[],"mappings":";;;;;AAAA,sDAA0E;AAE1E,kEAAuD;AACvD,4CAAoB;AAapB;;;GAGG;AACH,MAA8B,UAAU;IASpC;;;OAGG;IACH;IAEA,CAAC;IAkBD;;;;;OAKG;IACO,cAAc,CAAC,IAAY,EAAE,WAAmB,aAAa;QACnE,IAAI,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAChC,YAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;QACtD,CAAC;IACL,CAAC;IAGD;;;OAGG;IACH,KAAK,CAAC,OAAO;QACT,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,IAAI,CAAC;YACD,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;YACzB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YAC/B,IAAI,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YAChC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAClC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,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E,CAAC,IAAI,CAAC,GAAG,EAAE;QAE3B,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAA;IACN,CAAC;CACJ;AArMD,6BAqMC"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { NextFunction, Request, Response } from "express";
|
|
2
|
-
import log4js from "log4js";
|
|
3
|
-
/**
|
|
4
|
-
* Function signature for RESTful API handlers
|
|
5
|
-
*/
|
|
6
|
-
export type RestfulFunction = (req: Request) => any;
|
|
7
|
-
/**
|
|
8
|
-
* Function signature for control handlers
|
|
9
|
-
*/
|
|
10
|
-
export type ControlFunction = (req: Request, res: Response) => any;
|
|
11
|
-
/**
|
|
12
|
-
* Common router helper class providing middleware and utilities for Express routing
|
|
13
|
-
*/
|
|
14
|
-
export default class CommonRouterHelper {
|
|
15
|
-
/** Logger instance for this router helper */
|
|
16
|
-
protected readonly logger: log4js.Logger;
|
|
17
|
-
/**
|
|
18
|
-
* Sets HTTP response header to JSON format
|
|
19
|
-
* @param req Express request object
|
|
20
|
-
* @param res Express response object
|
|
21
|
-
* @param next Express next function
|
|
22
|
-
*/
|
|
23
|
-
setJsonHeader(req: Request, res: Response, next: NextFunction): void;
|
|
24
|
-
/**
|
|
25
|
-
* Sets response headers to disable caching
|
|
26
|
-
* @param req Express request object
|
|
27
|
-
* @param res Express response object
|
|
28
|
-
* @param next Express next function
|
|
29
|
-
*/
|
|
30
|
-
setNoCache(req: Request, res: Response, next: NextFunction): void;
|
|
31
|
-
/**
|
|
32
|
-
* Invokes a RESTful operation and wraps the result in JSON format for the client
|
|
33
|
-
* @param func The RESTful function to execute
|
|
34
|
-
* @returns Express middleware function
|
|
35
|
-
*/
|
|
36
|
-
invokeRestfulAction(func: RestfulFunction): any;
|
|
37
|
-
/**
|
|
38
|
-
* Invokes an asynchronous controller function with error handling
|
|
39
|
-
* @param func The controller function to execute
|
|
40
|
-
* @returns Express middleware function
|
|
41
|
-
*/
|
|
42
|
-
invokeController(func: ControlFunction): (req: Request, res: Response) => Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Handles invalid request paths by throwing ActionNotFoundError
|
|
45
|
-
* @returns Express middleware function for handling 404 errors
|
|
46
|
-
*/
|
|
47
|
-
actionNotFound(): (req: Request, res: Response, next: NextFunction) => void;
|
|
48
|
-
/**
|
|
49
|
-
* Retrieves user information from request headers
|
|
50
|
-
* @param req Express request object
|
|
51
|
-
* @protected
|
|
52
|
-
*/
|
|
53
|
-
protected retrieveUserFormHeader(req: Request): void;
|
|
54
|
-
/**
|
|
55
|
-
* Middleware to retrieve user information from headers
|
|
56
|
-
* @returns Express middleware function
|
|
57
|
-
*/
|
|
58
|
-
retrieveUser(): (req: Request, res: Response, next: any) => void;
|
|
59
|
-
/**
|
|
60
|
-
* Middleware to check if user is authenticated
|
|
61
|
-
* @returns Express middleware function that validates user authentication
|
|
62
|
-
*/
|
|
63
|
-
checkLoggedUser(): (req: Request, res: Response, next: any) => void;
|
|
64
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const express_exception_1 = require("@ticatec/express-exception");
|
|
7
|
-
const log4js_1 = __importDefault(require("log4js"));
|
|
8
|
-
/**
|
|
9
|
-
* Common router helper class providing middleware and utilities for Express routing
|
|
10
|
-
*/
|
|
11
|
-
class CommonRouterHelper {
|
|
12
|
-
constructor() {
|
|
13
|
-
/** Logger instance for this router helper */
|
|
14
|
-
this.logger = log4js_1.default.getLogger(this.constructor.name);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Sets HTTP response header to JSON format
|
|
18
|
-
* @param req Express request object
|
|
19
|
-
* @param res Express response object
|
|
20
|
-
* @param next Express next function
|
|
21
|
-
*/
|
|
22
|
-
setJsonHeader(req, res, next) {
|
|
23
|
-
res.header('Content-Type', 'application/json');
|
|
24
|
-
next();
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Sets response headers to disable caching
|
|
28
|
-
* @param req Express request object
|
|
29
|
-
* @param res Express response object
|
|
30
|
-
* @param next Express next function
|
|
31
|
-
*/
|
|
32
|
-
setNoCache(req, res, next) {
|
|
33
|
-
res.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
|
|
34
|
-
res.header('Expires', '-1');
|
|
35
|
-
res.header('Pragma', 'no-cache');
|
|
36
|
-
next();
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Invokes a RESTful operation and wraps the result in JSON format for the client
|
|
40
|
-
* @param func The RESTful function to execute
|
|
41
|
-
* @returns Express middleware function
|
|
42
|
-
*/
|
|
43
|
-
invokeRestfulAction(func) {
|
|
44
|
-
return async (req, res) => {
|
|
45
|
-
try {
|
|
46
|
-
let result = await func(req);
|
|
47
|
-
if (result != null) {
|
|
48
|
-
res.json(result);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
res.status(204).send();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
catch (ex) {
|
|
55
|
-
(0, express_exception_1.handleError)(ex, req, res);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Invokes an asynchronous controller function with error handling
|
|
61
|
-
* @param func The controller function to execute
|
|
62
|
-
* @returns Express middleware function
|
|
63
|
-
*/
|
|
64
|
-
invokeController(func) {
|
|
65
|
-
return async (req, res) => {
|
|
66
|
-
try {
|
|
67
|
-
await func(req, res);
|
|
68
|
-
}
|
|
69
|
-
catch (ex) {
|
|
70
|
-
(0, express_exception_1.handleError)(ex, req, res);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Handles invalid request paths by throwing ActionNotFoundError
|
|
76
|
-
* @returns Express middleware function for handling 404 errors
|
|
77
|
-
*/
|
|
78
|
-
actionNotFound() {
|
|
79
|
-
return (req, res, next) => {
|
|
80
|
-
(0, express_exception_1.handleError)(new express_exception_1.ActionNotFoundError(), req, res);
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Retrieves user information from request headers
|
|
85
|
-
* @param req Express request object
|
|
86
|
-
* @protected
|
|
87
|
-
*/
|
|
88
|
-
retrieveUserFormHeader(req) {
|
|
89
|
-
let userStr = req.headers['user'];
|
|
90
|
-
if (userStr != null) {
|
|
91
|
-
try {
|
|
92
|
-
const user = JSON.parse(decodeURIComponent(userStr));
|
|
93
|
-
let language = req.headers['x-language'];
|
|
94
|
-
if (language) {
|
|
95
|
-
if (user.actAs) {
|
|
96
|
-
user.actAs['language'] = language;
|
|
97
|
-
}
|
|
98
|
-
user['language'] = language;
|
|
99
|
-
}
|
|
100
|
-
req['user'] = user;
|
|
101
|
-
}
|
|
102
|
-
catch (ex) {
|
|
103
|
-
this.logger.debug('Invalid user header', userStr);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Middleware to retrieve user information from headers
|
|
109
|
-
* @returns Express middleware function
|
|
110
|
-
*/
|
|
111
|
-
retrieveUser() {
|
|
112
|
-
return (req, res, next) => {
|
|
113
|
-
this.retrieveUserFormHeader(req);
|
|
114
|
-
next();
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Middleware to check if user is authenticated
|
|
119
|
-
* @returns Express middleware function that validates user authentication
|
|
120
|
-
*/
|
|
121
|
-
checkLoggedUser() {
|
|
122
|
-
return (req, res, next) => {
|
|
123
|
-
this.retrieveUserFormHeader(req);
|
|
124
|
-
if (req['user'] == null) {
|
|
125
|
-
(0, express_exception_1.handleError)(new express_exception_1.UnauthenticatedError(), req, res);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
next();
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
exports.default = CommonRouterHelper;
|
|
134
|
-
//# sourceMappingURL=CommonRouterHelper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CommonRouterHelper.js","sourceRoot":"src/","sources":["CommonRouterHelper.ts"],"names":[],"mappings":";;;;;AACA,kEAAkG;AAClG,oDAA4B;AAa5B;;GAEG;AACH,MAAqB,kBAAkB;IAAvC;QAEI,6CAA6C;QAC1B,WAAM,GAAG,gBAAM,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IA4HxE,CAAC;IA1HG;;;;;OAKG;IACH,aAAa,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB;QACzD,GAAG,CAAC,MAAM,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAC/C,IAAI,EAAE,CAAC;IACX,CAAC;IAGD;;;;;OAKG;IACH,UAAU,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB;QACtD,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,8CAA8C,CAAC,CAAC;QAC5E,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC5B,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACjC,IAAI,EAAE,CAAC;IACX,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CAAC,IAAqB;QACrC,OAAO,KAAK,EAAE,GAAY,EAAE,GAAa,EAAiB,EAAE;YACxD,IAAI,CAAC;gBACD,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC7B,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;oBACjB,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACrB,CAAC;qBAAM,CAAC;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C,UAAU,CAAC,GAAG,QAAQ,CAAA;gBAC/B,CAAC;gBACD,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;YACvB,CAAC;YAAC,OAAO,EAAE,EAAE,CAAC;gBACV,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;YACtD,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,YAAY;QACR,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAS,EAAE,EAAE;YAC9C,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;YACjC,IAAI,EAAE,CAAC;QACX,CAAC,CAAA;IACL,CAAC;IAGD;;;OAGG;IACH,eAAe;QACX,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAS,EAAE,EAAE;YAC9C,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;YACjC,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;gBACtB,IAAA,+BAAW,EAAC,IAAI,wCAAoB,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;YACtD,CAAC;iBAAM,CAAC;gBACJ,IAAI,EAAE,CAAC;YACX,CAAC;QACL,CAAC,CAAA;IACL,CAAC;CAEJ;AA/HD,qCA+HC"}
|
package/dist/CommonRoutes.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Express, Router, Request } from "express";
|
|
2
|
-
import CommonRouterHelper from "./CommonRouterHelper";
|
|
3
|
-
import { Logger } from "log4js";
|
|
4
|
-
/**
|
|
5
|
-
* 当前用户检查
|
|
6
|
-
*/
|
|
7
|
-
export type UserChecker = (req: Request) => boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Abstract base class for defining common routes
|
|
10
|
-
* @template T The type of CommonRouterHelper this routes class uses
|
|
11
|
-
*/
|
|
12
|
-
export default abstract class CommonRoutes<T extends CommonRouterHelper> {
|
|
13
|
-
/** Express router instance */
|
|
14
|
-
readonly router: Router;
|
|
15
|
-
/** Router helper instance */
|
|
16
|
-
protected helper: T;
|
|
17
|
-
/** Logger instance for this routes class */
|
|
18
|
-
protected logger: Logger;
|
|
19
|
-
/**
|
|
20
|
-
* Constructor for common routes
|
|
21
|
-
* @param helper Router helper instance
|
|
22
|
-
* @param checkUser Whether to check user authentication (default: true)
|
|
23
|
-
* @param mergeParams Whether to merge params (default: false)
|
|
24
|
-
* @protected
|
|
25
|
-
*/
|
|
26
|
-
protected constructor(helper: T, checkUser?: boolean | UserChecker, mergeParams?: boolean);
|
|
27
|
-
/**
|
|
28
|
-
* Binds this router to the Express application
|
|
29
|
-
* @param app Express application instance
|
|
30
|
-
* @param path The path prefix for this router
|
|
31
|
-
*/
|
|
32
|
-
bindRouter(app: Express, path: string): void;
|
|
33
|
-
}
|