@rwojpromise/common 1.1.1 → 1.1.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.
- package/build/errors/bad-request-error.d.ts +9 -0
- package/build/errors/custom-error.d.ts +8 -0
- package/build/errors/database-connection-error.d.ts +9 -0
- package/build/errors/not-authorized-error.d.ts +8 -0
- package/build/errors/not-found-error.d.ts +8 -0
- package/build/errors/request-validation-error.d.ts +11 -0
- package/build/events/base-listener.d.ts +18 -0
- package/build/events/base-publisher.d.ts +13 -0
- package/build/events/invest-created-event.d.ts +11 -0
- package/build/events/subjects.d.ts +5 -0
- package/build/events/token-created-event.d.ts +13 -0
- package/build/events/user-created-event.d.ts +11 -0
- package/build/index.d.ts +16 -0
- package/build/index.js +5 -1
- package/build/middlewares/current-user.d.ts +14 -0
- package/build/middlewares/error-handler.d.ts +2 -0
- package/build/middlewares/require-auth.d.ts +2 -0
- package/build/middlewares/validate-request.d.ts +2 -0
- package/package.json +31 -31
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ValidationError } from 'express-validator';
|
|
2
|
+
import { CustomError } from './custom-error';
|
|
3
|
+
export declare class RequestValidationError extends CustomError {
|
|
4
|
+
errors: ValidationError[];
|
|
5
|
+
statusCode: number;
|
|
6
|
+
constructor(errors: ValidationError[]);
|
|
7
|
+
serializeErrors(): {
|
|
8
|
+
message: any;
|
|
9
|
+
field: string;
|
|
10
|
+
}[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Message, Stan } from "node-nats-streaming";
|
|
2
|
+
import { Subjects } from "./subjects";
|
|
3
|
+
interface Event {
|
|
4
|
+
subject: Subjects;
|
|
5
|
+
data: any;
|
|
6
|
+
}
|
|
7
|
+
export declare abstract class Listener<T extends Event> {
|
|
8
|
+
abstract subject: T["subject"];
|
|
9
|
+
abstract queueGroupName: string;
|
|
10
|
+
abstract onMessage(data: T["data"], msg: Message): void;
|
|
11
|
+
protected client: Stan;
|
|
12
|
+
protected ackWait: number;
|
|
13
|
+
constructor(client: Stan);
|
|
14
|
+
subscriptionOptions(): import("node-nats-streaming").SubscriptionOptions;
|
|
15
|
+
listen(): void;
|
|
16
|
+
parseMessage(msg: Message): any;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Stan } from "node-nats-streaming";
|
|
2
|
+
import { Subjects } from "./subjects";
|
|
3
|
+
interface Event {
|
|
4
|
+
subject: Subjects;
|
|
5
|
+
data: any;
|
|
6
|
+
}
|
|
7
|
+
export declare abstract class Publisher<T extends Event> {
|
|
8
|
+
abstract subject: T["subject"];
|
|
9
|
+
protected client: Stan;
|
|
10
|
+
constructor(client: Stan);
|
|
11
|
+
publish(data: T["data"]): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Subjects } from "./subjects";
|
|
2
|
+
export interface TokenCreatedEvent {
|
|
3
|
+
subject: Subjects.TokenCreated;
|
|
4
|
+
data: {
|
|
5
|
+
id: string;
|
|
6
|
+
invId: string;
|
|
7
|
+
name: string;
|
|
8
|
+
symbol: string;
|
|
9
|
+
tokenAddr: string;
|
|
10
|
+
tokenOwner: string;
|
|
11
|
+
initialAmount: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from "./errors/bad-request-error";
|
|
2
|
+
export * from "./errors/custom-error";
|
|
3
|
+
export * from "./errors/database-connection-error";
|
|
4
|
+
export * from "./errors/not-authorized-error";
|
|
5
|
+
export * from "./errors/not-found-error";
|
|
6
|
+
export * from "./errors/request-validation-error";
|
|
7
|
+
export * from "./middlewares/current-user";
|
|
8
|
+
export * from "./middlewares/error-handler";
|
|
9
|
+
export * from "./middlewares/require-auth";
|
|
10
|
+
export * from "./middlewares/validate-request";
|
|
11
|
+
export * from "./events/base-listener";
|
|
12
|
+
export * from "./events/base-publisher";
|
|
13
|
+
export * from "./events/subjects";
|
|
14
|
+
export * from "./events/user-created-event";
|
|
15
|
+
export * from "./events/invest-created-event";
|
|
16
|
+
export * from "./events/token-created-event";
|
package/build/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from "express";
|
|
2
|
+
interface UserPayload {
|
|
3
|
+
id: string;
|
|
4
|
+
email: string;
|
|
5
|
+
}
|
|
6
|
+
declare global {
|
|
7
|
+
namespace Express {
|
|
8
|
+
interface Request {
|
|
9
|
+
currentUser?: UserPayload;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export declare const currentUser: (req: Request, res: Response, next: NextFunction) => void;
|
|
14
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@rwojpromise/common",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "./build/index.js",
|
|
6
|
-
"types": "./build/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"build/**/*"
|
|
9
|
-
],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"clean": "rm -rf ./build/*",
|
|
12
|
-
"build": "npm run clean && tsc",
|
|
13
|
-
"pub": "git add . && git commit -m \"Updates\" && npm version patch && npm run build && npm publish"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [],
|
|
16
|
-
"author": "",
|
|
17
|
-
"license": "ISC",
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"@types/cookie-session": "^2.0.43",
|
|
20
|
-
"@types/express": "^4.17.13",
|
|
21
|
-
"@types/jsonwebtoken": "^8.5.6",
|
|
22
|
-
"express": "^4.17.2",
|
|
23
|
-
"express-validator": "^6.14.0",
|
|
24
|
-
"jsonwebtoken": "^8.5.1",
|
|
25
|
-
"node-nats-streaming": "^0.3.2",
|
|
26
|
-
"patch": "^0.0.1"
|
|
27
|
-
},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"typescript": "^4.
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@rwojpromise/common",
|
|
3
|
+
"version": "1.1.6",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./build/index.js",
|
|
6
|
+
"types": "./build/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"build/**/*"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"clean": "rm -rf ./build/*",
|
|
12
|
+
"build": "npm run clean && tsc",
|
|
13
|
+
"pub": "git add . && git commit -m \"Updates\" && npm version patch && npm run build && npm publish"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [],
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@types/cookie-session": "^2.0.43",
|
|
20
|
+
"@types/express": "^4.17.13",
|
|
21
|
+
"@types/jsonwebtoken": "^8.5.6",
|
|
22
|
+
"express": "^4.17.2",
|
|
23
|
+
"express-validator": "^6.14.0",
|
|
24
|
+
"jsonwebtoken": "^8.5.1",
|
|
25
|
+
"node-nats-streaming": "^0.3.2",
|
|
26
|
+
"patch": "^0.0.1"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"typescript": "^4.8.4"
|
|
30
|
+
}
|
|
31
|
+
}
|