@solidstarters/solid-core 1.2.123 → 1.2.124

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidstarters/solid-core",
3
- "version": "1.2.123",
3
+ "version": "1.2.124",
4
4
  "description": "This module is a NestJS module containing all the required core providers required by a Solid application",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,28 @@
1
+ export enum Environment {
2
+ Production = 'prod',
3
+ Development = 'dev',
4
+ }
5
+
6
+ export function DisallowInProduction(action?: string) {
7
+ return function (
8
+ target: any,
9
+ propertyKey: string,
10
+ descriptor: PropertyDescriptor,
11
+ ) {
12
+ const originalMethod = descriptor.value;
13
+
14
+ descriptor.value = function (...args: any[]) {
15
+ const currentEnv = process.env.ENV as Environment;
16
+
17
+ if (currentEnv === Environment.Production) {
18
+ const className = target.constructor.name;
19
+ const methodName = action || propertyKey;
20
+ throw new Error(`❌ Cannot execute "${className}.${methodName}" in production`);
21
+ }
22
+
23
+ return originalMethod.apply(this, args);
24
+ };
25
+
26
+ return descriptor;
27
+ };
28
+ }
@@ -27,6 +27,7 @@ import { RoleMetadataService } from './role-metadata.service';
27
27
  import { GenerateCodePublisher } from 'src/jobs/database/generate-code-publisher.service';
28
28
  import { PermissionMetadata } from 'src/entities/permission-metadata.entity';
29
29
  import { classify, dasherize } from '@angular-devkit/core/src/utils/strings';
30
+ import { DisallowInProduction } from 'src/decorators/disallow-in-production.decorator';
30
31
 
31
32
  @Injectable()
32
33
  export class ModelMetadataService {
@@ -711,6 +712,7 @@ export class ModelMetadataService {
711
712
 
712
713
  }
713
714
 
715
+ @DisallowInProduction()
714
716
  async handleGenerateCode(options: CodeGenerationOptions): Promise<any> {
715
717
  // // see if the model record exists.
716
718
  // const model = await this.modelMetadataRepo.findOne({
@@ -21,6 +21,7 @@ import { CodeGenerationOptions, ModuleMetadataConfiguration } from '../interface
21
21
  import { CrudHelperService } from './crud-helper.service';
22
22
  import { ModelMetadataService } from './model-metadata.service';
23
23
  import { ModuleMetadataHelperService } from 'src/helpers/module-metadata-helper.service';
24
+ import { DisallowInProduction } from 'src/decorators/disallow-in-production.decorator';
24
25
 
25
26
  @Injectable()
26
27
  export class ModuleMetadataService {
@@ -349,6 +350,7 @@ export class ModuleMetadataService {
349
350
  return true
350
351
  }
351
352
 
353
+ @DisallowInProduction()
352
354
  async generateCode(options: CodeGenerationOptions): Promise<string> {
353
355
  if (!options.moduleId && !options.moduleUserKey) {
354
356
  throw new BadRequestException('Module ID or Module Name is required for generating code');