@nattyjs/common 0.0.1-beta.63 → 0.0.1-beta.64

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/dist/index.cjs CHANGED
@@ -48,11 +48,19 @@ const commonContainer = new class {
48
48
  }
49
49
  }
50
50
  };
51
- const secureConfig = { sensitiveProps: ["password", "mobileNo", "email"] };
51
+ const secureConfig = {};
52
52
  this.nattyConfig = { ...{ api: { rootPath: "api" }, ...{ static: { enabled: true } }, autoGeneratePort: true, modelBinding, globalConfig: {}, secure: secureConfig }, ...config };
53
53
  }
54
54
  setupBuildOptions(options) {
55
- this.buildOptions = options;
55
+ this.buildOptions = {
56
+ commandName: options.commandName || "dev",
57
+ mode: options.mode || "dev",
58
+ port: options.port ?? 0,
59
+ rootDir: options.rootDir || process.cwd(),
60
+ outDir: options.outDir || "dist",
61
+ startupFilePath: options.startupFilePath || "dist/index.js",
62
+ clearScreen: options.clearScreen ?? false
63
+ };
56
64
  }
57
65
  setEnvTsDefinition(tsDefinition) {
58
66
  this.envTsDefinition = tsDefinition;
@@ -132,6 +140,8 @@ const typeContainer = new class {
132
140
  const routes = {};
133
141
  for (const key of this.controllerInfo.keys()) {
134
142
  const classInfo = this.controllerInfo.get(key);
143
+ if (!classInfo?.filePath)
144
+ continue;
135
145
  let templateInfo = {
136
146
  path: `.${classInfo.filePath.replace(TS_EXTENSION, BLANK).replace(BACK_SLASH_REGEX, RIGHT_SLASH)}`,
137
147
  route: this.getControllerRouteName(classInfo),
@@ -252,12 +262,12 @@ function resolvePath(path$1) {
252
262
  }
253
263
 
254
264
  async function readEnv() {
255
- const envConfig = commonContainer.nattyCliConfig.env;
265
+ const envConfig = commonContainer.nattyCliConfig?.env;
256
266
  let filePath = envConfig?.dictionary ? void 0 : getPath([ENVIRONMENTS, commonContainer.buildOptions.mode && commonContainer.buildOptions.mode !== "dev" ? `.env.${commonContainer.buildOptions.mode}` : `.env`]);
257
267
  if (envConfig && envConfig.path)
258
268
  filePath = resolvePath(envConfig.path);
259
269
  let parsedEnvTsDefinition = {};
260
- let parsedEnv = commonContainer.nattyCliConfig.env?.dictionary;
270
+ let parsedEnv = envConfig?.dictionary;
261
271
  if (!parsedEnv && filePath && fs.existsSync(filePath)) {
262
272
  const { parsed, error } = dotenv__namespace.config({
263
273
  debug: !!process.env.DEBUG || void 0,
package/dist/index.d.ts CHANGED
@@ -48,7 +48,7 @@ interface IAuthorizationContext extends IActionExecutingContext {
48
48
  }
49
49
 
50
50
  declare abstract class AuthorizationFilter {
51
- abstract onAuthorization(httpContext: IAuthorizationContext): Promise<boolean>;
51
+ abstract onAuthorization(httpContext: IAuthorizationContext, permissionRequirement: any): Promise<boolean>;
52
52
  onFailedAuthorization(): ProblemDetail;
53
53
  }
54
54
 
@@ -77,6 +77,7 @@ interface PayloadConfig {
77
77
 
78
78
  interface SecureConfig {
79
79
  sensitiveProps?: String[];
80
+ denyByDefault?: boolean;
80
81
  }
81
82
 
82
83
  interface PreInitEventConfig {
@@ -122,6 +123,12 @@ declare abstract class AbstractRunner {
122
123
  protected exec(command: string, args: any[], cwd?: string): Promise<null | string>;
123
124
  }
124
125
 
126
+ interface DiTransformConfig {
127
+ decoratorName?: string;
128
+ markerName?: string;
129
+ stripPathPrefixes?: string[];
130
+ }
131
+
125
132
  interface EnvConfig {
126
133
  path: string;
127
134
  dictionary: {
@@ -140,6 +147,7 @@ interface LibraryConfig {
140
147
  interface NattyCliConfig {
141
148
  library?: Partial<LibraryConfig>;
142
149
  env?: Partial<EnvConfig>;
150
+ di?: DiTransformConfig;
143
151
  runner?: ClassType<AbstractRunner>;
144
152
  port?: number;
145
153
  openapi?: GenerateOpenApiOptions;
@@ -151,7 +159,7 @@ interface NattyCliConfig {
151
159
  declare const commonContainer: {
152
160
  setupConfig(config?: NattyConfig): void;
153
161
  setupCliConfig(config: NattyCliConfig): void;
154
- setupBuildOptions(options: BuildOptions): any;
162
+ setupBuildOptions(options: Partial<BuildOptions>): void;
155
163
  get nattyConfig(): NattyConfig;
156
164
  get nattyCliConfig(): NattyCliConfig;
157
165
  get buildOptions(): BuildOptions;
@@ -327,4 +335,4 @@ declare function typed(): <T extends {
327
335
  new (...args: any[]): {};
328
336
  }>(OriginalClass: T) => T;
329
337
 
330
- export { ALLOW_METHODS, AbstractRunner, ActionFilter, AuthenticationFilter, AuthorizationFilter, BACK_SLASH_REGEX, BLANK, CONTROLLER, Claim, ClassType, ConsoleLogger, DEFAULT_ACTIONS, DEFAULT_CHILD_PATH, DELETE, ENVIRONMENTS, ExceptionFilter, FrameworkType, GET, GlobalConfig, HTTP_METHOD_ROUTES, IActionExecutedContext, IActionExecutingContext, IAuthorizationContext, IExecutionContext, IGNORE_METHODS, List, MetaConfigProps, Middleware, NattyAppConfig, NattyCliConfig, NattyConfig, POST, PUT, RIGHT_SLASH, ROUTE_INSTANCES, ROUTE_METHODS, ROUTE_PATHS, TS_EXTENSION, UserIdentity, WebScheduleConfig, commonContainer, createPath, createTestServer, getPath, getPort, isConstructor, isEqual, isFunction, isObject, readEnv, readEnvKey, registerType, typeContainer, typed };
338
+ export { ALLOW_METHODS, AbstractRunner, ActionFilter, AuthenticationFilter, AuthorizationFilter, BACK_SLASH_REGEX, BLANK, CONTROLLER, Claim, ClassType, ConsoleLogger, DEFAULT_ACTIONS, DEFAULT_CHILD_PATH, DELETE, DiTransformConfig, ENVIRONMENTS, ExceptionFilter, FrameworkType, GET, GlobalConfig, HTTP_METHOD_ROUTES, IActionExecutedContext, IActionExecutingContext, IAuthorizationContext, IExecutionContext, IGNORE_METHODS, List, MetaConfigProps, Middleware, NattyAppConfig, NattyCliConfig, NattyConfig, POST, PUT, RIGHT_SLASH, ROUTE_INSTANCES, ROUTE_METHODS, ROUTE_PATHS, TS_EXTENSION, UserIdentity, WebScheduleConfig, commonContainer, createPath, createTestServer, getPath, getPort, isConstructor, isEqual, isFunction, isObject, readEnv, readEnvKey, registerType, typeContainer, typed };
package/dist/index.mjs CHANGED
@@ -31,11 +31,19 @@ const commonContainer = new class {
31
31
  }
32
32
  }
33
33
  };
34
- const secureConfig = { sensitiveProps: ["password", "mobileNo", "email"] };
34
+ const secureConfig = {};
35
35
  this.nattyConfig = { ...{ api: { rootPath: "api" }, ...{ static: { enabled: true } }, autoGeneratePort: true, modelBinding, globalConfig: {}, secure: secureConfig }, ...config };
36
36
  }
37
37
  setupBuildOptions(options) {
38
- this.buildOptions = options;
38
+ this.buildOptions = {
39
+ commandName: options.commandName || "dev",
40
+ mode: options.mode || "dev",
41
+ port: options.port ?? 0,
42
+ rootDir: options.rootDir || process.cwd(),
43
+ outDir: options.outDir || "dist",
44
+ startupFilePath: options.startupFilePath || "dist/index.js",
45
+ clearScreen: options.clearScreen ?? false
46
+ };
39
47
  }
40
48
  setEnvTsDefinition(tsDefinition) {
41
49
  this.envTsDefinition = tsDefinition;
@@ -115,6 +123,8 @@ const typeContainer = new class {
115
123
  const routes = {};
116
124
  for (const key of this.controllerInfo.keys()) {
117
125
  const classInfo = this.controllerInfo.get(key);
126
+ if (!classInfo?.filePath)
127
+ continue;
118
128
  let templateInfo = {
119
129
  path: `.${classInfo.filePath.replace(TS_EXTENSION, BLANK).replace(BACK_SLASH_REGEX, RIGHT_SLASH)}`,
120
130
  route: this.getControllerRouteName(classInfo),
@@ -235,12 +245,12 @@ function resolvePath(path) {
235
245
  }
236
246
 
237
247
  async function readEnv() {
238
- const envConfig = commonContainer.nattyCliConfig.env;
248
+ const envConfig = commonContainer.nattyCliConfig?.env;
239
249
  let filePath = envConfig?.dictionary ? void 0 : getPath([ENVIRONMENTS, commonContainer.buildOptions.mode && commonContainer.buildOptions.mode !== "dev" ? `.env.${commonContainer.buildOptions.mode}` : `.env`]);
240
250
  if (envConfig && envConfig.path)
241
251
  filePath = resolvePath(envConfig.path);
242
252
  let parsedEnvTsDefinition = {};
243
- let parsedEnv = commonContainer.nattyCliConfig.env?.dictionary;
253
+ let parsedEnv = envConfig?.dictionary;
244
254
  if (!parsedEnv && filePath && existsSync(filePath)) {
245
255
  const { parsed, error } = dotenv.config({
246
256
  debug: !!process.env.DEBUG || void 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nattyjs/common",
3
- "version": "0.0.1-beta.63",
3
+ "version": "0.0.1-beta.64",
4
4
  "description": "Now I’m the model of a modern major general / The venerated Virginian veteran whose men are all / Lining up, to put me up on a pedestal / Writin’ letters to relatives / Embellishin’ my elegance and eloquence / But the elephant is in the room / The truth is in ya face when ya hear the British cannons go / BOOM",
5
5
  "keywords": [],
6
6
  "author": "ajayojha <ojhaajay@outlook.com>",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/node": "20.3.1",
24
- "@nattyjs/types": "0.0.1-beta.63",
24
+ "@nattyjs/types": "0.0.1-beta.64",
25
25
  "unbuild": "1.2.1"
26
26
  }
27
27
  }