@orkow/common 0.0.67 → 0.0.69

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.
@@ -0,0 +1,10 @@
1
+ import { CustomError } from './custom-error';
2
+ export declare class BadRequestError extends CustomError {
3
+ message: string;
4
+ statusCode: number;
5
+ constructor(message: string);
6
+ serializeErrors(): {
7
+ message: string;
8
+ }[];
9
+ }
10
+ //# sourceMappingURL=bad-request-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bad-request-error.d.ts","sourceRoot":"","sources":["../../src/errors/bad-request-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,qBAAa,eAAgB,SAAQ,WAAW;IAG3B,OAAO,EAAE,MAAM;IAFlC,UAAU,EAAE,MAAM,CAAM;gBAEL,OAAO,EAAE,MAAM;IAMlC,eAAe;;;CAGhB"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BadRequestError = void 0;
4
+ const custom_error_1 = require("./custom-error");
5
+ class BadRequestError extends custom_error_1.CustomError {
6
+ message;
7
+ statusCode = 400;
8
+ constructor(message) {
9
+ super(message);
10
+ this.message = message;
11
+ Object.setPrototypeOf(this, BadRequestError.prototype);
12
+ }
13
+ serializeErrors() {
14
+ return [{ message: this.message }];
15
+ }
16
+ }
17
+ exports.BadRequestError = BadRequestError;
@@ -0,0 +1,9 @@
1
+ export declare abstract class CustomError extends Error {
2
+ abstract statusCode: number;
3
+ constructor(message: string);
4
+ abstract serializeErrors(): {
5
+ message: string;
6
+ field?: string;
7
+ }[];
8
+ }
9
+ //# sourceMappingURL=custom-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-error.d.ts","sourceRoot":"","sources":["../../src/errors/custom-error.ts"],"names":[],"mappings":"AAAA,8BAAsB,WAAY,SAAQ,KAAK;IAC7C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;gBAEf,OAAO,EAAE,MAAM;IAO3B,QAAQ,CAAC,eAAe,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE;CAClE"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomError = void 0;
4
+ class CustomError extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ Object.setPrototypeOf(this, CustomError.prototype);
8
+ }
9
+ }
10
+ exports.CustomError = CustomError;
@@ -0,0 +1,9 @@
1
+ import { CustomError } from './custom-error';
2
+ export declare class NotAuthorizedError extends CustomError {
3
+ statusCode: number;
4
+ constructor();
5
+ serializeErrors(): {
6
+ message: string;
7
+ }[];
8
+ }
9
+ //# sourceMappingURL=not-authorized-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"not-authorized-error.d.ts","sourceRoot":"","sources":["../../src/errors/not-authorized-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,qBAAa,kBAAmB,SAAQ,WAAW;IACjD,UAAU,SAAM;;IAQhB,eAAe;;;CAGhB"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotAuthorizedError = void 0;
4
+ const custom_error_1 = require("./custom-error");
5
+ class NotAuthorizedError extends custom_error_1.CustomError {
6
+ statusCode = 401;
7
+ constructor() {
8
+ super('Not Authorized');
9
+ Object.setPrototypeOf(this, NotAuthorizedError.prototype);
10
+ }
11
+ serializeErrors() {
12
+ return [{ message: 'Not authorized' }];
13
+ }
14
+ }
15
+ exports.NotAuthorizedError = NotAuthorizedError;
@@ -0,0 +1,9 @@
1
+ import { CustomError } from './custom-error';
2
+ export declare class NotFoundError extends CustomError {
3
+ statusCode: number;
4
+ constructor();
5
+ serializeErrors(): {
6
+ message: string;
7
+ }[];
8
+ }
9
+ //# sourceMappingURL=not-found-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"not-found-error.d.ts","sourceRoot":"","sources":["../../src/errors/not-found-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,qBAAa,aAAc,SAAQ,WAAW;IAC5C,UAAU,SAAM;;IAQhB,eAAe;;;CAGhB"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotFoundError = void 0;
4
+ const custom_error_1 = require("./custom-error");
5
+ class NotFoundError extends custom_error_1.CustomError {
6
+ statusCode = 404;
7
+ constructor() {
8
+ super('Route not found');
9
+ Object.setPrototypeOf(this, NotFoundError.prototype);
10
+ }
11
+ serializeErrors() {
12
+ return [{ message: 'Not Found' }];
13
+ }
14
+ }
15
+ exports.NotFoundError = NotFoundError;
@@ -18,7 +18,7 @@ class Listener {
18
18
  durable_name: this.queueGroupName,
19
19
  ack_wait: (0, nats_1.nanos)(this.ackWait),
20
20
  });
21
- (0, __1.log)(`Listening to subject: ${this.subjectRoot}.${this.subject} / ${this.queueGroupName}`);
21
+ (0, __1.log)(`Consuming to subject: ${this.subjectRoot}.${this.subject} / ${this.queueGroupName}`);
22
22
  const c = await js.consumers.get(this.streamName, this.queueGroupName);
23
23
  const iter = await c.consume();
24
24
  for await (const m of iter) {
package/dist/index.d.ts CHANGED
@@ -3,6 +3,10 @@ export * from './utils/getRequestId';
3
3
  export * from './utils/getUserId';
4
4
  export * from './utils/getUserType';
5
5
  export * from './utils/hashPassword';
6
+ export * from './errors/custom-error';
7
+ export * from './errors/bad-request-error';
8
+ export * from './errors/not-authorized-error';
9
+ export * from './errors/not-found-error';
6
10
  export * from './events/base-listener';
7
11
  export * from './events/base-publisher';
8
12
  export * from './events/subjects';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AAEpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAGhC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,6BAA6B,CAAA;AAE3C,eAAO,MAAM,GAAG,GAAI,KAAK,GAAG,SAE3B,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,KAAK,GAAG,WAE7B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AAEpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,0BAA0B,CAAA;AAExC,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAGhC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,6BAA6B,CAAA;AAE3C,eAAO,MAAM,GAAG,GAAI,KAAK,GAAG,SAE3B,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,KAAK,GAAG,WAE7B,CAAA"}
package/dist/index.js CHANGED
@@ -20,6 +20,10 @@ __exportStar(require("./utils/getRequestId"), exports);
20
20
  __exportStar(require("./utils/getUserId"), exports);
21
21
  __exportStar(require("./utils/getUserType"), exports);
22
22
  __exportStar(require("./utils/hashPassword"), exports);
23
+ __exportStar(require("./errors/custom-error"), exports);
24
+ __exportStar(require("./errors/bad-request-error"), exports);
25
+ __exportStar(require("./errors/not-authorized-error"), exports);
26
+ __exportStar(require("./errors/not-found-error"), exports);
23
27
  __exportStar(require("./events/base-listener"), exports);
24
28
  __exportStar(require("./events/base-publisher"), exports);
25
29
  __exportStar(require("./events/subjects"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orkow/common",
3
- "version": "0.0.67",
3
+ "version": "0.0.69",
4
4
  "description": "Common utils.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",