vona-core 5.0.90 → 5.0.93

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.
@@ -61,7 +61,7 @@ export class AppLogger extends BeanSimple {
61
61
  }, Winston);
62
62
  }
63
63
  createTransportFile(fileName, clientInfo, options) {
64
- const dirname = this.app.config.server.loggerDir;
64
+ const dirname = this.app.config.logger.baseDir;
65
65
  if (!fse.existsSync(dirname)) {
66
66
  const [_, err] = catchErrorSync(() => {
67
67
  fse.ensureDirSync(dirname);
@@ -15,7 +15,6 @@ export interface IExecuteBeanCallback {
15
15
  (params: IExecuteBeanCallbackParams): Promise<any>;
16
16
  }
17
17
  export interface IModuleAssetSceneRecord {
18
- cli: never;
19
18
  static: never;
20
19
  templates: never;
21
20
  site: never;
@@ -32,11 +31,11 @@ export declare class AppUtil extends BeanSimple {
32
31
  combineApiPathControllerAndActionRaw(moduleName: ModuleInfo.IModuleInfo | string, controllerPath: string | undefined, actionPath: RegExp | string | undefined, simplify?: boolean): string;
33
32
  combineApiPathControllerAndAction(moduleName: ModuleInfo.IModuleInfo | string, controllerPath: string | undefined, actionPath: RegExp | string | undefined, prefix?: string | boolean, simplify?: boolean): string;
34
33
  combineApiPath(path: string | undefined, moduleName?: ModuleInfo.IModuleInfo | string, prefix?: string | boolean, simplify?: boolean): string;
35
- combineStaticPath(path: string | undefined, moduleName?: ModuleInfo.IModuleInfo | string): string;
34
+ combineStaticPath(staticPath: string | undefined, moduleName?: ModuleInfo.IModuleInfo | string): string;
36
35
  combineResourceName(resourceName: string | undefined, moduleName: ModuleInfo.IModuleInfo | string, simplify?: boolean, simplifyProviderId?: boolean): string;
37
36
  getPublicPathPhysical(subdir?: string, ensure?: boolean): Promise<string>;
38
37
  get prodRootPath(): string;
39
- getAssetPathPhysical(moduleName: ModuleInfo.IModuleInfo | string, scene: keyof IModuleAssetSceneRecord, assetPath?: string): string | undefined;
38
+ getAssetPathPhysical(moduleName: ModuleInfo.IModuleInfo | string, scene: keyof IModuleAssetSceneRecord, assetPath?: string): string;
40
39
  createError(data: any, returnObject?: boolean): any;
41
40
  monkeyModule(ebAppMonkey: any, ebModulesMonkey: any, monkeyName: TypeMonkeyName, moduleTarget?: IModule, ...monkeyData: any[]): Promise<void>;
42
41
  monkeyModuleSync(ebAppMonkey: any, ebModulesMonkey: any, monkeyName: TypeMonkeyName, moduleTarget?: IModule, ...monkeyData: any[]): void;
@@ -62,5 +61,5 @@ export declare function prepareEnv(env: Partial<NodeJS.ProcessEnv>): VonaConfigE
62
61
  export declare function beanFullNameFromOnionName(onionName: string, sceneName: keyof IBeanSceneRecord): keyof IBeanRecord;
63
62
  export declare function onionNameFromBeanFullName(beanFullName: string, sceneName: keyof IBeanSceneRecord): string;
64
63
  export declare function filterHeaders(headers: object | undefined, whitelist: string[]): {} | undefined;
65
- export declare function combineFilePathSafe(dir: string, file: string): string | undefined;
64
+ export declare function combineFilePathSafe(dir: string, file: string): string;
66
65
  export {};
@@ -40,16 +40,20 @@ export class AppUtil extends BeanSimple {
40
40
  combineApiPath(path, moduleName, prefix, simplify) {
41
41
  return combineApiPath(path, moduleName, prefix, simplify, this.app.config.server.globalPrefix);
42
42
  }
43
- combineStaticPath(path, moduleName) {
43
+ combineStaticPath(staticPath, moduleName) {
44
44
  const globalPrefix = '/api/static';
45
- if (!path)
46
- path = '';
45
+ if (!staticPath)
46
+ staticPath = '';
47
+ // safe
48
+ staticPath = path.normalize(staticPath);
49
+ if (staticPath.includes('..'))
50
+ throw new Error(`unsafe path: ${staticPath}`);
47
51
  // ignore globalPrefix
48
- if (path.startsWith('//'))
49
- return path.substring(1);
52
+ if (staticPath.startsWith('//'))
53
+ return staticPath.substring(1);
50
54
  // ignore module path
51
- if (path.startsWith('/'))
52
- return `${globalPrefix}${path}`;
55
+ if (staticPath.startsWith('/'))
56
+ return `${globalPrefix}${staticPath}`;
53
57
  // globalPrefix + module path + arg
54
58
  if (!moduleName)
55
59
  throw new Error('should specify the moduleName');
@@ -57,7 +61,7 @@ export class AppUtil extends BeanSimple {
57
61
  moduleName = moduleName.relativeName;
58
62
  const parts = moduleName.split('-');
59
63
  // path
60
- return `${globalPrefix}/${parts[0]}/${parts[1]}/${path}`;
64
+ return `${globalPrefix}/${parts[0]}/${parts[1]}/${staticPath}`;
61
65
  }
62
66
  combineResourceName(resourceName, moduleName, simplify, simplifyProviderId) {
63
67
  return combineResourceName(resourceName, moduleName, simplify, simplifyProviderId);
@@ -91,7 +95,7 @@ export class AppUtil extends BeanSimple {
91
95
  const module = this.app.meta.modules[moduleName];
92
96
  if (!module)
93
97
  throw new Error('module not found');
94
- return combineFilePathSafe(path.join(module.root, scene), assetPath || '');
98
+ return combineFilePathSafe(path.join(module.root, 'assets', scene), assetPath || '');
95
99
  }
96
100
  }
97
101
  createError(data, returnObject) {
@@ -300,6 +304,6 @@ export function combineFilePathSafe(dir, file) {
300
304
  const fullPath = path.normalize(path.join(dir, file));
301
305
  // files that can be accessd should be under options.dir
302
306
  if (fullPath.indexOf(dir) !== 0)
303
- return;
307
+ throw new Error(`unsafe dir: ${dir}`);
304
308
  return fullPath;
305
309
  }
@@ -7,7 +7,6 @@ export interface VonaConfig {
7
7
  keys: string[];
8
8
  globalPrefix: string;
9
9
  publicDir: string;
10
- loggerDir: string;
11
10
  subdomainOffset: number;
12
11
  workers: number;
13
12
  listen: {
@@ -16,6 +16,7 @@ export interface ILoggerRotateConfig {
16
16
  options: TypeLoggerRotateOptions;
17
17
  }
18
18
  export interface ConfigLogger {
19
+ baseDir: string;
19
20
  base: TypeLoggerOptions;
20
21
  clients: Record<keyof ILoggerClientRecord, TypeLoggerOptions>;
21
22
  rotate: ILoggerRotateConfig;
@@ -6,13 +6,13 @@ export interface VonaConfigEnv {
6
6
  SERVER_KEYS: string | undefined;
7
7
  SERVER_GLOBALPREFIX: string | undefined;
8
8
  SERVER_PUBLICDIR: string | undefined;
9
- SERVER_LOGGERDIR: string | undefined;
10
9
  SERVER_SUBDOMAINOFFSET: string | undefined;
11
10
  SERVER_WORKERS: string | undefined;
12
11
  SERVER_LISTEN_HOSTNAME: string | undefined;
13
12
  SERVER_LISTEN_PORT: string | undefined;
14
13
  SERVER_LISTEN_DISABLE: 'true' | 'false' | undefined;
15
14
  TEST_WHYISNODERUNNING: string | undefined;
15
+ LOGGER_DIR: string | undefined;
16
16
  LOGGER_DUMMY: 'true' | 'false' | undefined;
17
17
  LOGGER_ROTATE_ENABLE: 'true' | 'false' | undefined;
18
18
  LOGGER_ROTATE_FILENAME: string | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-core",
3
3
  "type": "module",
4
- "version": "5.0.90",
4
+ "version": "5.0.93",
5
5
  "description": "vona",
6
6
  "publishConfig": {
7
7
  "access": "public"