@rwojpromise/common 1.1.1 → 1.1.2
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/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 +1 -1
|
@@ -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";
|
|
@@ -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 {};
|