lupine.api 1.1.58 → 1.1.60
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/README.md +3 -3
- package/admin/admin-about.tsx +12 -16
- package/admin/admin-config.tsx +47 -44
- package/admin/admin-css.tsx +3 -3
- package/admin/admin-db.tsx +75 -75
- package/admin/admin-frame-helper.tsx +364 -364
- package/admin/admin-frame.tsx +164 -164
- package/admin/admin-index.tsx +65 -65
- package/admin/admin-login.tsx +111 -111
- package/admin/admin-menu-edit.tsx +637 -637
- package/admin/admin-menu-list.tsx +87 -87
- package/admin/admin-page-edit.tsx +564 -564
- package/admin/admin-page-list.tsx +83 -83
- package/admin/admin-performance.tsx +28 -28
- package/admin/admin-release.tsx +427 -426
- package/admin/admin-resources.tsx +382 -382
- package/admin/admin-shell.tsx +89 -89
- package/admin/admin-table-data.tsx +146 -146
- package/admin/admin-table-list.tsx +230 -230
- package/admin/admin-test-animations.tsx +395 -395
- package/admin/admin-test-component.tsx +823 -808
- package/admin/admin-test-edit.tsx +319 -319
- package/admin/admin-test-themes.tsx +56 -56
- package/admin/admin-tokens.tsx +338 -338
- package/admin/design/admin-design.tsx +174 -174
- package/admin/design/block-grid.tsx +36 -36
- package/admin/design/block-grid1.tsx +21 -21
- package/admin/design/block-paragraph.tsx +19 -19
- package/admin/design/block-title.tsx +19 -19
- package/admin/design/design-block-box.tsx +140 -140
- package/admin/design/drag-data.tsx +24 -24
- package/admin/index.ts +9 -9
- package/admin/package.json +15 -15
- package/admin/tsconfig.json +127 -127
- package/dev/copy-folder.js +32 -32
- package/dev/cp-index-html.js +69 -69
- package/dev/file-utils.js +12 -12
- package/dev/index.js +18 -19
- package/dev/package.json +12 -12
- package/dev/plugin-ifelse.js +168 -168
- package/dev/plugin-ifelse.test.js +37 -37
- package/dev/run-cmd.js +14 -14
- package/dev/send-request.js +12 -12
- package/package.json +55 -55
- package/src/admin-api/admin-api-helper.ts +210 -205
- package/src/admin-api/admin-api.ts +65 -65
- package/src/admin-api/admin-auth.ts +152 -146
- package/src/admin-api/admin-config.ts +94 -84
- package/src/admin-api/admin-csv.ts +94 -94
- package/src/admin-api/admin-db.ts +269 -269
- package/src/admin-api/admin-menu.ts +135 -135
- package/src/admin-api/admin-page.ts +135 -135
- package/src/admin-api/admin-performance.ts +128 -128
- package/src/admin-api/admin-release.ts +706 -700
- package/src/admin-api/admin-resources.ts +318 -318
- package/src/admin-api/admin-token-helper.ts +82 -79
- package/src/admin-api/admin-tokens.ts +90 -90
- package/src/admin-api/index.ts +2 -2
- package/src/admin-api/web-config-api.ts +19 -19
- package/src/api/api-cache.ts +103 -103
- package/src/api/api-helper.ts +44 -44
- package/src/api/api-module.ts +67 -60
- package/src/api/api-router.ts +177 -177
- package/src/api/api-shared-storage.ts +64 -64
- package/src/api/async-storage.ts +5 -5
- package/src/api/debug-service.ts +56 -56
- package/src/api/encode-html.ts +27 -27
- package/src/api/handle-status.ts +75 -75
- package/src/api/index.ts +15 -16
- package/src/api/mini-web-socket.ts +270 -270
- package/src/api/server-content-type.ts +82 -82
- package/src/api/server-render.ts +235 -215
- package/src/api/shell-service.ts +74 -74
- package/src/api/simple-storage.ts +80 -80
- package/src/api/static-server.ts +128 -125
- package/src/api/to-client-delivery.ts +26 -26
- package/src/app/app-cache.ts +55 -55
- package/src/app/app-helper.ts +62 -62
- package/src/app/app-message.ts +109 -109
- package/src/app/app-shared-storage.ts +363 -363
- package/src/app/app-start.ts +136 -136
- package/src/app/cleanup-exit.ts +16 -16
- package/src/app/host-to-path.ts +38 -38
- package/src/app/index.ts +11 -11
- package/src/app/process-dev-requests.ts +130 -130
- package/src/app/web-listener.ts +294 -294
- package/src/app/web-processor.ts +47 -42
- package/src/app/web-server.ts +100 -100
- package/src/common-js/web-env.js +104 -104
- package/src/index.ts +7 -7
- package/src/lang/api-lang-en.ts +26 -26
- package/src/lang/api-lang-zh-cn.ts +27 -27
- package/src/lang/index.ts +2 -2
- package/src/lang/lang-helper.ts +76 -76
- package/src/lang/lang-props.ts +6 -6
- package/src/lib/db/db-helper.ts +23 -23
- package/src/lib/db/db-mysql.ts +249 -250
- package/src/lib/db/db-sqlite.ts +101 -101
- package/src/lib/db/db.spec.ts +28 -28
- package/src/lib/db/db.ts +325 -325
- package/src/lib/db/index.ts +5 -5
- package/src/lib/index.ts +3 -3
- package/src/lib/logger.spec.ts +214 -214
- package/src/lib/logger.ts +281 -281
- package/src/lib/runtime-require.ts +37 -37
- package/src/lib/utils/cookie-util.ts +34 -34
- package/src/lib/utils/crypto.ts +58 -58
- package/src/lib/utils/date-utils.ts +317 -317
- package/src/lib/utils/deep-merge.ts +37 -37
- package/src/lib/utils/delay.ts +12 -12
- package/src/lib/utils/file-setting.ts +55 -55
- package/src/lib/utils/format-bytes.ts +11 -11
- package/src/lib/utils/fs-utils.ts +158 -158
- package/src/lib/utils/get-env.ts +27 -27
- package/src/lib/utils/index.ts +12 -12
- package/src/lib/utils/is-type.ts +48 -48
- package/src/lib/utils/load-env.ts +14 -14
- package/src/lib/utils/pad.ts +6 -6
- package/src/models/api-base.ts +5 -5
- package/src/models/api-module-props.ts +10 -11
- package/src/models/api-router-props.ts +26 -26
- package/src/models/app-cache-props.ts +33 -33
- package/src/models/app-data-props.ts +10 -10
- package/src/models/app-helper-props.ts +6 -6
- package/src/models/app-shared-storage-props.ts +38 -38
- package/src/models/app-start-props.ts +18 -18
- package/src/models/async-storage-props.ts +13 -13
- package/src/models/db-config.ts +30 -30
- package/src/models/host-to-path-props.ts +12 -12
- package/src/models/index.ts +16 -16
- package/src/models/json-object.ts +8 -8
- package/src/models/locals-props.ts +36 -36
- package/src/models/logger-props.ts +84 -84
- package/src/models/simple-storage-props.ts +13 -14
- package/src/models/to-client-delivery-props.ts +6 -6
- package/tsconfig.json +115 -115
- package/dev/plugin-gen-versions.js +0 -20
package/src/lib/utils/is-type.ts
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
export class IsType {
|
|
2
|
-
static getType(obj: any) {
|
|
3
|
-
var type = typeof obj;
|
|
4
|
-
if (type === 'undefined') return 'undefined';
|
|
5
|
-
else if (type === 'string' || obj instanceof String) return 'string';
|
|
6
|
-
else if (type === 'number' || obj instanceof Number) return 'number';
|
|
7
|
-
else if (type === 'function' || obj instanceof Function) return 'function';
|
|
8
|
-
else if (!!obj && obj.constructor === Array) return 'array';
|
|
9
|
-
else if (obj && obj.nodeType === 1) return 'element';
|
|
10
|
-
else if (type === 'object') return 'object';
|
|
11
|
-
else return 'unknown';
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static isArray(input: any) {
|
|
15
|
-
return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static isObject(input: any) {
|
|
19
|
-
// null is not object
|
|
20
|
-
return input !== null && Object.prototype.toString.call(input) === '[object Object]';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static isObjectEmpty(obj: any) {
|
|
24
|
-
if (Object.getOwnPropertyNames) {
|
|
25
|
-
return Object.getOwnPropertyNames(obj).length === 0;
|
|
26
|
-
} else {
|
|
27
|
-
var k;
|
|
28
|
-
for (k in obj) {
|
|
29
|
-
if (obj.hasOwnProperty(k)) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static isUndefined(input: any) {
|
|
38
|
-
return input === void 0;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static isNumber(input: any) {
|
|
42
|
-
return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
static isDate(input: any) {
|
|
46
|
-
return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
|
|
47
|
-
}
|
|
48
|
-
}
|
|
1
|
+
export class IsType {
|
|
2
|
+
static getType(obj: any) {
|
|
3
|
+
var type = typeof obj;
|
|
4
|
+
if (type === 'undefined') return 'undefined';
|
|
5
|
+
else if (type === 'string' || obj instanceof String) return 'string';
|
|
6
|
+
else if (type === 'number' || obj instanceof Number) return 'number';
|
|
7
|
+
else if (type === 'function' || obj instanceof Function) return 'function';
|
|
8
|
+
else if (!!obj && obj.constructor === Array) return 'array';
|
|
9
|
+
else if (obj && obj.nodeType === 1) return 'element';
|
|
10
|
+
else if (type === 'object') return 'object';
|
|
11
|
+
else return 'unknown';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static isArray(input: any) {
|
|
15
|
+
return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static isObject(input: any) {
|
|
19
|
+
// null is not object
|
|
20
|
+
return input !== null && Object.prototype.toString.call(input) === '[object Object]';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static isObjectEmpty(obj: any) {
|
|
24
|
+
if (Object.getOwnPropertyNames) {
|
|
25
|
+
return Object.getOwnPropertyNames(obj).length === 0;
|
|
26
|
+
} else {
|
|
27
|
+
var k;
|
|
28
|
+
for (k in obj) {
|
|
29
|
+
if (obj.hasOwnProperty(k)) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static isUndefined(input: any) {
|
|
38
|
+
return input === void 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static isNumber(input: any) {
|
|
42
|
+
return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static isDate(input: any) {
|
|
46
|
+
return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import * as webEnv from '../../common-js/web-env.js';
|
|
2
|
-
|
|
3
|
-
export const loadEnv = async (envFile: string, overrideEnv: boolean = false) => {
|
|
4
|
-
return webEnv.loadEnv(envFile, overrideEnv);
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const getWebEnv = (appName: string): { [k: string]: string } => {
|
|
8
|
-
return webEnv.getWebEnv(appName) as { [k: string]: string };
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
// // Replace <!--META-ENV-START-->...<!--META-ENV-END--> for mobile app and replace it again for web app
|
|
12
|
-
// export const replaceWebEnv = (html: string, appName: string, addMetaTag: boolean) => {
|
|
13
|
-
// return webEnv.replaceWebEnv(html, appName, addMetaTag);
|
|
14
|
-
// }
|
|
1
|
+
import * as webEnv from '../../common-js/web-env.js';
|
|
2
|
+
|
|
3
|
+
export const loadEnv = async (envFile: string, overrideEnv: boolean = false) => {
|
|
4
|
+
return webEnv.loadEnv(envFile, overrideEnv);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const getWebEnv = (appName: string): { [k: string]: string } => {
|
|
8
|
+
return webEnv.getWebEnv(appName) as { [k: string]: string };
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// // Replace <!--META-ENV-START-->...<!--META-ENV-END--> for mobile app and replace it again for web app
|
|
12
|
+
// export const replaceWebEnv = (html: string, appName: string, addMetaTag: boolean) => {
|
|
13
|
+
// return webEnv.replaceWebEnv(html, appName, addMetaTag);
|
|
14
|
+
// }
|
package/src/lib/utils/pad.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const padRight = (str: string, length: number, fillString: string) => {
|
|
2
|
-
return str.padEnd(length, fillString);
|
|
3
|
-
};
|
|
4
|
-
export const padLeft = (str: string, length: number, fillString: string) => {
|
|
5
|
-
return str.padStart(length, fillString);
|
|
6
|
-
};
|
|
1
|
+
export const padRight = (str: string, length: number, fillString: string) => {
|
|
2
|
+
return str.padEnd(length, fillString);
|
|
3
|
+
};
|
|
4
|
+
export const padLeft = (str: string, length: number, fillString: string) => {
|
|
5
|
+
return str.padStart(length, fillString);
|
|
6
|
+
};
|
package/src/models/api-base.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IApiRouter } from './api-router-props';
|
|
2
|
-
|
|
3
|
-
export interface IApiBase {
|
|
4
|
-
getRouter(): IApiRouter;
|
|
5
|
-
}
|
|
1
|
+
import { IApiRouter } from './api-router-props';
|
|
2
|
+
|
|
3
|
+
export interface IApiBase {
|
|
4
|
+
getRouter(): IApiRouter;
|
|
5
|
+
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { ServerResponse } from 'http';
|
|
2
|
-
import { AsyncStorageProps } from './async-storage-props';
|
|
3
|
-
import { ServerRequest } from './locals-props';
|
|
4
|
-
import { HostToPathProps } from './host-to-path-props';
|
|
5
|
-
import { IAppCache } from './app-cache-props';
|
|
6
|
-
import { IAppSharedStorage } from './app-shared-storage-props';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
1
|
+
import { ServerResponse } from 'http';
|
|
2
|
+
import { AsyncStorageProps } from './async-storage-props';
|
|
3
|
+
import { ServerRequest } from './locals-props';
|
|
4
|
+
import { HostToPathProps } from './host-to-path-props';
|
|
5
|
+
import { IAppCache } from './app-cache-props';
|
|
6
|
+
import { IAppSharedStorage } from './app-shared-storage-props';
|
|
7
|
+
export interface IApiModule {
|
|
8
|
+
processApi(store: AsyncStorageProps, url: string, req: ServerRequest, res: ServerResponse): Promise<boolean>;
|
|
9
|
+
initApi(appConfig: HostToPathProps, appCache: IAppCache, appStorage: IAppSharedStorage): Promise<void>;
|
|
10
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { ServerResponse } from 'http';
|
|
2
|
-
import { ServerRequest } from './locals-props';
|
|
3
|
-
|
|
4
|
-
export type ApiRouterCallback = (req: ServerRequest, res: ServerResponse, rootUrl?: string) => Promise<boolean>;
|
|
5
|
-
|
|
6
|
-
export enum ApiRouterMethod {
|
|
7
|
-
ALL = 'ALL',
|
|
8
|
-
GET = 'GET',
|
|
9
|
-
POST = 'POST',
|
|
10
|
-
}
|
|
11
|
-
export type ApiRouterData = {
|
|
12
|
-
path: string;
|
|
13
|
-
handler: (ApiRouterCallback | IApiRouter)[];
|
|
14
|
-
method: ApiRouterMethod;
|
|
15
|
-
parameterVariables: string[];
|
|
16
|
-
parameterLength: number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export interface IApiRouter {
|
|
20
|
-
get(path: string, ...handler: (ApiRouterCallback | IApiRouter)[]): void;
|
|
21
|
-
post(path: string, ...handler: (ApiRouterCallback | IApiRouter)[]): void;
|
|
22
|
-
use(path: string, ...handler: (ApiRouterCallback | IApiRouter)[]): void;
|
|
23
|
-
setFilter(filter: ApiRouterCallback): void;
|
|
24
|
-
findRoute(url: string, req: ServerRequest, res: ServerResponse, handleNotFound: boolean): Promise<boolean>;
|
|
25
|
-
handleRequest(url: string, req: ServerRequest, res: ServerResponse): Promise<boolean>;
|
|
26
|
-
}
|
|
1
|
+
import { ServerResponse } from 'http';
|
|
2
|
+
import { ServerRequest } from './locals-props';
|
|
3
|
+
|
|
4
|
+
export type ApiRouterCallback = (req: ServerRequest, res: ServerResponse, rootUrl?: string) => Promise<boolean>;
|
|
5
|
+
|
|
6
|
+
export enum ApiRouterMethod {
|
|
7
|
+
ALL = 'ALL',
|
|
8
|
+
GET = 'GET',
|
|
9
|
+
POST = 'POST',
|
|
10
|
+
}
|
|
11
|
+
export type ApiRouterData = {
|
|
12
|
+
path: string;
|
|
13
|
+
handler: (ApiRouterCallback | IApiRouter)[];
|
|
14
|
+
method: ApiRouterMethod;
|
|
15
|
+
parameterVariables: string[];
|
|
16
|
+
parameterLength: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export interface IApiRouter {
|
|
20
|
+
get(path: string, ...handler: (ApiRouterCallback | IApiRouter)[]): void;
|
|
21
|
+
post(path: string, ...handler: (ApiRouterCallback | IApiRouter)[]): void;
|
|
22
|
+
use(path: string, ...handler: (ApiRouterCallback | IApiRouter)[]): void;
|
|
23
|
+
setFilter(filter: ApiRouterCallback): void;
|
|
24
|
+
findRoute(url: string, req: ServerRequest, res: ServerResponse, handleNotFound: boolean): Promise<boolean>;
|
|
25
|
+
handleRequest(url: string, req: ServerRequest, res: ServerResponse): Promise<boolean>;
|
|
26
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
// interface of AppCache
|
|
2
|
-
|
|
3
|
-
export const AppCacheGlobal = 'APP_GLOBAL';
|
|
4
|
-
|
|
5
|
-
export enum AppCacheKeys {
|
|
6
|
-
APP_DEBUG = 'APP_DEBUG',
|
|
7
|
-
// APP_ENV_FILE = 'APP_ENV_FILE', // app's env file, for api to reload
|
|
8
|
-
APP_LIST = 'APP_LIST', // all app names list
|
|
9
|
-
TEMPLATE = 'TEMPLATE',
|
|
10
|
-
APP_DATA = 'APP_DATA',
|
|
11
|
-
NODE_ENV = 'NODE_ENV',
|
|
12
|
-
API_MODULE = 'API_MODULE',
|
|
13
|
-
API_CONFIG = 'API_CONFIG',
|
|
14
|
-
RENDER_PAGE_FUNCTIONS = 'RENDER_PAGE_FUNCTIONS',
|
|
15
|
-
|
|
16
|
-
START_TIME = 'START_TIME',
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface IAppCache {
|
|
20
|
-
clear(appName: string | undefined): void;
|
|
21
|
-
get(appName: string, key: string): any;
|
|
22
|
-
set(appName: string, key: string, value: any): void;
|
|
23
|
-
clearTemplateCache(): void;
|
|
24
|
-
}
|
|
25
|
-
const _savedCache: { appCache: IAppCache | null } = {
|
|
26
|
-
appCache: null,
|
|
27
|
-
};
|
|
28
|
-
export const getAppCache = (): IAppCache => {
|
|
29
|
-
return _savedCache.appCache!;
|
|
30
|
-
};
|
|
31
|
-
export const setAppCache = (cache: IAppCache) => {
|
|
32
|
-
_savedCache.appCache = cache;
|
|
33
|
-
};
|
|
1
|
+
// interface of AppCache
|
|
2
|
+
|
|
3
|
+
export const AppCacheGlobal = 'APP_GLOBAL';
|
|
4
|
+
|
|
5
|
+
export enum AppCacheKeys {
|
|
6
|
+
APP_DEBUG = 'APP_DEBUG',
|
|
7
|
+
// APP_ENV_FILE = 'APP_ENV_FILE', // app's env file, for api to reload
|
|
8
|
+
APP_LIST = 'APP_LIST', // all app names list
|
|
9
|
+
TEMPLATE = 'TEMPLATE',
|
|
10
|
+
APP_DATA = 'APP_DATA',
|
|
11
|
+
NODE_ENV = 'NODE_ENV',
|
|
12
|
+
API_MODULE = 'API_MODULE',
|
|
13
|
+
API_CONFIG = 'API_CONFIG',
|
|
14
|
+
RENDER_PAGE_FUNCTIONS = 'RENDER_PAGE_FUNCTIONS',
|
|
15
|
+
|
|
16
|
+
START_TIME = 'START_TIME',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface IAppCache {
|
|
20
|
+
clear(appName: string | undefined): void;
|
|
21
|
+
get(appName: string, key: string): any;
|
|
22
|
+
set(appName: string, key: string, value: any): void;
|
|
23
|
+
clearTemplateCache(): void;
|
|
24
|
+
}
|
|
25
|
+
const _savedCache: { appCache: IAppCache | null } = {
|
|
26
|
+
appCache: null,
|
|
27
|
+
};
|
|
28
|
+
export const getAppCache = (): IAppCache => {
|
|
29
|
+
return _savedCache.appCache!;
|
|
30
|
+
};
|
|
31
|
+
export const setAppCache = (cache: IAppCache) => {
|
|
32
|
+
_savedCache.appCache = cache;
|
|
33
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Db } from '../lib/db';
|
|
2
|
-
|
|
3
|
-
export type AppDataProps = {
|
|
4
|
-
db: Db;
|
|
5
|
-
dbType: string;
|
|
6
|
-
dbFilename: string;
|
|
7
|
-
config: any;
|
|
8
|
-
dataPath: string;
|
|
9
|
-
webPath: string;
|
|
10
|
-
};
|
|
1
|
+
import { Db } from '../lib/db';
|
|
2
|
+
|
|
3
|
+
export type AppDataProps = {
|
|
4
|
+
db: Db;
|
|
5
|
+
dbType: string;
|
|
6
|
+
dbFilename: string;
|
|
7
|
+
config: any;
|
|
8
|
+
dataPath: string;
|
|
9
|
+
webPath: string;
|
|
10
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HostToPathProps } from './host-to-path-props';
|
|
2
|
-
|
|
3
|
-
export type AppLoaderProps = {
|
|
4
|
-
serverRoot: string;
|
|
5
|
-
webHostMap: HostToPathProps[];
|
|
6
|
-
};
|
|
1
|
+
import { HostToPathProps } from './host-to-path-props';
|
|
2
|
+
|
|
3
|
+
export type AppLoaderProps = {
|
|
4
|
+
serverRoot: string;
|
|
5
|
+
webHostMap: HostToPathProps[];
|
|
6
|
+
};
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { ISimpleStorage, SimpleStorageDataProps } from './simple-storage-props';
|
|
2
|
-
|
|
3
|
-
// interface of AppSharedStorage
|
|
4
|
-
export const AppSharedStorageMessageId = 'AppSharedStorage';
|
|
5
|
-
export type StorageMessageAction = 'get' | 'set' | 'load'
|
|
6
|
-
export interface StorageMessageFromSubProcess {
|
|
7
|
-
id: string;
|
|
8
|
-
pid: number | undefined;
|
|
9
|
-
workerId: number;
|
|
10
|
-
action: StorageMessageAction;
|
|
11
|
-
key: string;
|
|
12
|
-
prefixKey?: string;
|
|
13
|
-
value?: any;
|
|
14
|
-
uniqueKey?: string;
|
|
15
|
-
appName: string;
|
|
16
|
-
rootPath?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// also used in packages\lupine.api\src\common-js\web-env.js
|
|
20
|
-
export const AppSharedStorageWebPrefix = 'WEB.';
|
|
21
|
-
export const AppSharedStorageApiPrefix = 'API.';
|
|
22
|
-
|
|
23
|
-
export interface IAppSharedStorage {
|
|
24
|
-
// this is a worker and msg is from Primary (but when debug is on, it's primary)
|
|
25
|
-
messageFromPrimaryProcess(msgObject: any): void;
|
|
26
|
-
// this is primary, msg is from a client
|
|
27
|
-
messageFromSubProcess(msgObject: any): void;
|
|
28
|
-
load(appName: string, rootPath: string): Promise<void>;
|
|
29
|
-
save(appName?: string, exit?: boolean): Promise<void>;
|
|
30
|
-
get(appName: string, key: string): Promise<string>;
|
|
31
|
-
getWeb(appName: string, key: string): Promise<string>;
|
|
32
|
-
getApi(appName: string, key: string): Promise<string>;
|
|
33
|
-
getWebAll(appName: string): Promise<SimpleStorageDataProps>;
|
|
34
|
-
getWithPrefix(appName: string, prefixKey: string): Promise<SimpleStorageDataProps>;
|
|
35
|
-
set(appName: string, key: string, value: any): void;
|
|
36
|
-
setWeb(appName: string, key: string, value: any): void;
|
|
37
|
-
setApi(appName: string, key: string, value: any): void;
|
|
38
|
-
}
|
|
1
|
+
import { ISimpleStorage, SimpleStorageDataProps } from './simple-storage-props';
|
|
2
|
+
|
|
3
|
+
// interface of AppSharedStorage
|
|
4
|
+
export const AppSharedStorageMessageId = 'AppSharedStorage';
|
|
5
|
+
export type StorageMessageAction = 'get' | 'set' | 'load' | 'save' | 'getWithPrefix';
|
|
6
|
+
export interface StorageMessageFromSubProcess {
|
|
7
|
+
id: string;
|
|
8
|
+
pid: number | undefined;
|
|
9
|
+
workerId: number;
|
|
10
|
+
action: StorageMessageAction;
|
|
11
|
+
key: string;
|
|
12
|
+
prefixKey?: string;
|
|
13
|
+
value?: any;
|
|
14
|
+
uniqueKey?: string;
|
|
15
|
+
appName: string;
|
|
16
|
+
rootPath?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// also used in packages\lupine.api\src\common-js\web-env.js
|
|
20
|
+
export const AppSharedStorageWebPrefix = 'WEB.';
|
|
21
|
+
export const AppSharedStorageApiPrefix = 'API.';
|
|
22
|
+
|
|
23
|
+
export interface IAppSharedStorage {
|
|
24
|
+
// this is a worker and msg is from Primary (but when debug is on, it's primary)
|
|
25
|
+
messageFromPrimaryProcess(msgObject: any): void;
|
|
26
|
+
// this is primary, msg is from a client
|
|
27
|
+
messageFromSubProcess(msgObject: any): void;
|
|
28
|
+
load(appName: string, rootPath: string): Promise<void>;
|
|
29
|
+
save(appName?: string, exit?: boolean): Promise<void>;
|
|
30
|
+
get(appName: string, key: string): Promise<string>;
|
|
31
|
+
getWeb(appName: string, key: string): Promise<string>;
|
|
32
|
+
getApi(appName: string, key: string): Promise<string>;
|
|
33
|
+
getWebAll(appName: string): Promise<SimpleStorageDataProps>;
|
|
34
|
+
getWithPrefix(appName: string, prefixKey: string): Promise<SimpleStorageDataProps>;
|
|
35
|
+
set(appName: string, key: string, value: any): void;
|
|
36
|
+
setWeb(appName: string, key: string, value: any): void;
|
|
37
|
+
setApi(appName: string, key: string, value: any): void;
|
|
38
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { RenderPageFunctionsType } from '../api';
|
|
2
|
-
import { AppLoaderProps } from './app-helper-props';
|
|
3
|
-
|
|
4
|
-
export type InitStartProps = {
|
|
5
|
-
bindIp: string;
|
|
6
|
-
httpPort: number;
|
|
7
|
-
httpsPort: number;
|
|
8
|
-
sslKeyPath: string;
|
|
9
|
-
sslCrtPath: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type AppStartProps = {
|
|
13
|
-
debug: boolean;
|
|
14
|
-
appEnvFile: string;
|
|
15
|
-
apiConfig: AppLoaderProps;
|
|
16
|
-
serverConfig: InitStartProps;
|
|
17
|
-
renderPageFunctions: RenderPageFunctionsType;
|
|
18
|
-
};
|
|
1
|
+
import { RenderPageFunctionsType } from '../api';
|
|
2
|
+
import { AppLoaderProps } from './app-helper-props';
|
|
3
|
+
|
|
4
|
+
export type InitStartProps = {
|
|
5
|
+
bindIp: string;
|
|
6
|
+
httpPort: number;
|
|
7
|
+
httpsPort: number;
|
|
8
|
+
sslKeyPath: string;
|
|
9
|
+
sslCrtPath: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type AppStartProps = {
|
|
13
|
+
debug: boolean;
|
|
14
|
+
appEnvFile: string;
|
|
15
|
+
apiConfig: AppLoaderProps;
|
|
16
|
+
serverConfig: InitStartProps;
|
|
17
|
+
renderPageFunctions: RenderPageFunctionsType;
|
|
18
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { LocalsProps } from './locals-props';
|
|
2
|
-
import { HostToPathProps } from './host-to-path-props';
|
|
3
|
-
|
|
4
|
-
// language code: https://www.andiamo.co.uk/resources/iso-language-codes/
|
|
5
|
-
// English: en, Chinese (PRC): zh-cn, Chinese (Hong Kong): zh-hk, Chinese (Taiwan): zh-tw, Japanese: ja, Korean: ko
|
|
6
|
-
export type AsyncStorageProps = {
|
|
7
|
-
uuid: string;
|
|
8
|
-
appName: string;
|
|
9
|
-
hostPath: HostToPathProps;
|
|
10
|
-
locals: LocalsProps;
|
|
11
|
-
lang: string;
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
};
|
|
1
|
+
import { LocalsProps } from './locals-props';
|
|
2
|
+
import { HostToPathProps } from './host-to-path-props';
|
|
3
|
+
|
|
4
|
+
// language code: https://www.andiamo.co.uk/resources/iso-language-codes/
|
|
5
|
+
// English: en, Chinese (PRC): zh-cn, Chinese (Hong Kong): zh-hk, Chinese (Taiwan): zh-tw, Japanese: ja, Korean: ko
|
|
6
|
+
export type AsyncStorageProps = {
|
|
7
|
+
uuid: string;
|
|
8
|
+
appName: string;
|
|
9
|
+
hostPath: HostToPathProps;
|
|
10
|
+
locals: LocalsProps;
|
|
11
|
+
lang: string;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
package/src/models/db-config.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
export interface DbConfig {
|
|
2
|
-
type: string;
|
|
3
|
-
host: string;
|
|
4
|
-
port: number;
|
|
5
|
-
user: string;
|
|
6
|
-
password: string;
|
|
7
|
-
database: string;
|
|
8
|
-
poolMin: number;
|
|
9
|
-
poolMax: number;
|
|
10
|
-
connectionTimeout: number;
|
|
11
|
-
tablePrefix: string;
|
|
12
|
-
filename?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const getDefaultDbConfig = (): DbConfig => {
|
|
16
|
-
// process.env may not be initialized at script starting
|
|
17
|
-
return {
|
|
18
|
-
type: process.env['DB_TYPE'] || 'sqlite',
|
|
19
|
-
host: '',
|
|
20
|
-
port: 0,
|
|
21
|
-
user: '',
|
|
22
|
-
password: '',
|
|
23
|
-
database: '',
|
|
24
|
-
poolMin: 1,
|
|
25
|
-
poolMax: 5,
|
|
26
|
-
connectionTimeout: 10000,
|
|
27
|
-
tablePrefix: '',
|
|
28
|
-
filename: process.env['DB_FILENAME'] || 'sqlite3.db',
|
|
29
|
-
};
|
|
30
|
-
};
|
|
1
|
+
export interface DbConfig {
|
|
2
|
+
type: string;
|
|
3
|
+
host: string;
|
|
4
|
+
port: number;
|
|
5
|
+
user: string;
|
|
6
|
+
password: string;
|
|
7
|
+
database: string;
|
|
8
|
+
poolMin: number;
|
|
9
|
+
poolMax: number;
|
|
10
|
+
connectionTimeout: number;
|
|
11
|
+
tablePrefix: string;
|
|
12
|
+
filename?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const getDefaultDbConfig = (): DbConfig => {
|
|
16
|
+
// process.env may not be initialized at script starting
|
|
17
|
+
return {
|
|
18
|
+
type: process.env['DB_TYPE'] || 'sqlite',
|
|
19
|
+
host: '',
|
|
20
|
+
port: 0,
|
|
21
|
+
user: '',
|
|
22
|
+
password: '',
|
|
23
|
+
database: '',
|
|
24
|
+
poolMin: 1,
|
|
25
|
+
poolMax: 5,
|
|
26
|
+
connectionTimeout: 10000,
|
|
27
|
+
tablePrefix: '',
|
|
28
|
+
filename: process.env['DB_FILENAME'] || 'sqlite3.db',
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { DbConfig } from './db-config';
|
|
2
|
-
|
|
3
|
-
export type HostToPathProps = {
|
|
4
|
-
hosts: string[];
|
|
5
|
-
// path: string;
|
|
6
|
-
webPath: string;
|
|
7
|
-
dataPath: string;
|
|
8
|
-
apiPath: string;
|
|
9
|
-
appName: string;
|
|
10
|
-
dbType: string;
|
|
11
|
-
dbConfig: DbConfig;
|
|
12
|
-
};
|
|
1
|
+
import { DbConfig } from './db-config';
|
|
2
|
+
|
|
3
|
+
export type HostToPathProps = {
|
|
4
|
+
hosts: string[];
|
|
5
|
+
// path: string;
|
|
6
|
+
webPath: string;
|
|
7
|
+
dataPath: string;
|
|
8
|
+
apiPath: string;
|
|
9
|
+
appName: string;
|
|
10
|
+
dbType: string;
|
|
11
|
+
dbConfig: DbConfig;
|
|
12
|
+
};
|
package/src/models/index.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export * from './api-base';
|
|
2
|
-
export * from './api-module-props';
|
|
3
|
-
export * from './api-router-props';
|
|
4
|
-
export * from './app-cache-props';
|
|
5
|
-
export * from './app-data-props';
|
|
6
|
-
export * from './app-helper-props';
|
|
7
|
-
export * from './app-shared-storage-props';
|
|
8
|
-
export * from './app-start-props';
|
|
9
|
-
export * from './async-storage-props';
|
|
10
|
-
export * from './db-config';
|
|
11
|
-
export * from './host-to-path-props';
|
|
12
|
-
export * from './json-object';
|
|
13
|
-
export * from './locals-props';
|
|
14
|
-
export * from './logger-props';
|
|
15
|
-
export * from './simple-storage-props';
|
|
16
|
-
export * from './to-client-delivery-props';
|
|
1
|
+
export * from './api-base';
|
|
2
|
+
export * from './api-module-props';
|
|
3
|
+
export * from './api-router-props';
|
|
4
|
+
export * from './app-cache-props';
|
|
5
|
+
export * from './app-data-props';
|
|
6
|
+
export * from './app-helper-props';
|
|
7
|
+
export * from './app-shared-storage-props';
|
|
8
|
+
export * from './app-start-props';
|
|
9
|
+
export * from './async-storage-props';
|
|
10
|
+
export * from './db-config';
|
|
11
|
+
export * from './host-to-path-props';
|
|
12
|
+
export * from './json-object';
|
|
13
|
+
export * from './locals-props';
|
|
14
|
+
export * from './logger-props';
|
|
15
|
+
export * from './simple-storage-props';
|
|
16
|
+
export * from './to-client-delivery-props';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export type JsonKeyValue = {
|
|
2
|
-
[key: string]: string | number | boolean | null | undefined | string[] | number[] | JsonKeyValue | JsonKeyValue[];
|
|
3
|
-
};
|
|
4
|
-
export type JsonObject =
|
|
5
|
-
| JsonKeyValue[]
|
|
6
|
-
| {
|
|
7
|
-
[key: string]: string | number | boolean | null | undefined | string[] | number[] | JsonKeyValue | JsonKeyValue[];
|
|
8
|
-
};
|
|
1
|
+
export type JsonKeyValue = {
|
|
2
|
+
[key: string]: string | number | boolean | null | undefined | string[] | number[] | JsonKeyValue | JsonKeyValue[];
|
|
3
|
+
};
|
|
4
|
+
export type JsonObject =
|
|
5
|
+
| JsonKeyValue[]
|
|
6
|
+
| {
|
|
7
|
+
[key: string]: string | number | boolean | null | undefined | string[] | number[] | JsonKeyValue | JsonKeyValue[];
|
|
8
|
+
};
|