@sharangyawali/sg-app 0.0.5 → 0.0.6

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.

Potentially problematic release.


This version of @sharangyawali/sg-app might be problematic. Click here for more details.

package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sharangyawali/sg-app",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "keywords": [],
5
5
  "author": "Sharan Gyawali",
6
6
  "license": "ISC",
@@ -8,7 +8,7 @@ export declare class RoutRegister {
8
8
  private app;
9
9
  constructor();
10
10
  register(app: Express, globalPrefix?: string, prefixOptions?: GlobalPrefixOptions): Promise<void>;
11
- private registerClasses;
11
+ private registerCLS;
12
12
  private registerMiddleWares;
13
13
  private doContains;
14
14
  private registerControllerCLasses;
package/routes-config.js CHANGED
@@ -6,7 +6,6 @@ const common_1 = require("./common");
6
6
  const class_transformer_1 = require("class-transformer");
7
7
  const class_validator_1 = require("class-validator");
8
8
  const cls_1 = require("./cls");
9
- const config_1 = require("./config");
10
9
  const di_container_1 = require("./di-container");
11
10
  class RoutRegister {
12
11
  logger;
@@ -22,21 +21,11 @@ class RoutRegister {
22
21
  this.router = app.router;
23
22
  this.prefix = globalPrefix;
24
23
  this.prefixOptions = prefixOptions;
25
- this.registerClasses();
24
+ this.registerCLS();
26
25
  this.registerMiddleWares();
27
26
  this.registerControllerCLasses();
28
27
  }
29
- registerClasses() {
30
- di_container_1.container.register({
31
- scope: common_1.Scope.SINGLETON,
32
- token: config_1.ConfigService,
33
- useClass: config_1.ConfigService
34
- });
35
- di_container_1.container.register({
36
- scope: common_1.Scope.SINGLETON,
37
- token: logger_1.AppLogger,
38
- useClass: logger_1.AppLogger
39
- });
28
+ registerCLS() {
40
29
  di_container_1.container.register({
41
30
  scope: common_1.Scope.SINGLETON,
42
31
  token: cls_1.CLSService,
package/sg-factory.d.ts CHANGED
@@ -3,4 +3,5 @@ export declare class SGFactory implements ISGFactory {
3
3
  private app;
4
4
  constructor();
5
5
  create(_: any, options?: FactoryOptions): ISGApplication;
6
+ private registerClasses;
6
7
  }
package/sg-factory.js CHANGED
@@ -9,7 +9,9 @@ const _1 = require(".");
9
9
  const cors_1 = __importDefault(require("cors"));
10
10
  class SGFactory {
11
11
  app;
12
- constructor() { }
12
+ constructor() {
13
+ this.registerClasses();
14
+ }
13
15
  create(_, options) {
14
16
  this.app = (0, express_1.default)();
15
17
  this.app.use(express_1.default.json());
@@ -18,5 +20,17 @@ class SGFactory {
18
20
  typeof options.cors === 'boolean' ? this.app.use((0, cors_1.default)()) : this.app.use((0, cors_1.default)({ ...options.cors }));
19
21
  return new _1.SGApplication(this.app);
20
22
  }
23
+ registerClasses() {
24
+ _1.container.register({
25
+ scope: _1.Scope.SINGLETON,
26
+ token: _1.ConfigService,
27
+ useClass: _1.ConfigService
28
+ });
29
+ _1.container.register({
30
+ scope: _1.Scope.SINGLETON,
31
+ token: _1.AppLogger,
32
+ useClass: _1.AppLogger
33
+ });
34
+ }
21
35
  }
22
36
  exports.SGFactory = SGFactory;
@@ -12,7 +12,6 @@ import {
12
12
  HttpException,
13
13
  MiddlewareOptions,
14
14
  middlewares,
15
- REQUEST,
16
15
  RequestMethodEnum,
17
16
  RequestParameters,
18
17
  RouteInfo,
@@ -25,7 +24,6 @@ import {
25
24
  import { plainToInstance } from "class-transformer";
26
25
  import { validate } from "class-validator";
27
26
  import { CLSService } from "./cls";
28
- import { ConfigService } from "./config";
29
27
  import { container } from "./di-container";
30
28
 
31
29
  export class RoutRegister {
@@ -47,21 +45,11 @@ export class RoutRegister {
47
45
  this.router = app.router;
48
46
  this.prefix = globalPrefix;
49
47
  this.prefixOptions = prefixOptions;
50
- this.registerClasses();
48
+ this.registerCLS();
51
49
  this.registerMiddleWares();
52
50
  this.registerControllerCLasses();
53
51
  }
54
- private registerClasses() {
55
- container.register({
56
- scope: Scope.SINGLETON,
57
- token: ConfigService,
58
- useClass: ConfigService
59
- });
60
- container.register({
61
- scope: Scope.SINGLETON,
62
- token: AppLogger,
63
- useClass: AppLogger
64
- });
52
+ private registerCLS() {
65
53
  container.register({
66
54
  scope: Scope.SINGLETON,
67
55
  token: CLSService,
package/src/sg-factory.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import express from "express";
2
- import { FactoryOptions, ISGApplication, ISGFactory, SGApplication } from ".";
2
+ import { AppLogger, ConfigService, container, FactoryOptions, ISGApplication, ISGFactory, Scope, SGApplication } from ".";
3
3
  import cors from 'cors';
4
4
  export class SGFactory implements ISGFactory {
5
5
  private app;
6
- constructor() { }
6
+ constructor() {
7
+ this.registerClasses()
8
+ }
7
9
  create(_: any, options?: FactoryOptions): ISGApplication {
8
10
  this.app = express();
9
11
  this.app.use(express.json())
@@ -12,4 +14,16 @@ export class SGFactory implements ISGFactory {
12
14
  typeof options.cors === 'boolean' ? this.app.use(cors()) : this.app.use(cors({ ...options.cors }))
13
15
  return new SGApplication(this.app);
14
16
  }
17
+ private registerClasses() {
18
+ container.register({
19
+ scope: Scope.SINGLETON,
20
+ token: ConfigService,
21
+ useClass: ConfigService
22
+ });
23
+ container.register({
24
+ scope: Scope.SINGLETON,
25
+ token: AppLogger,
26
+ useClass: AppLogger
27
+ });
28
+ }
15
29
  }