@mingjue8888/express-plus 1.2.3 → 1.2.5

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.
Files changed (3) hide show
  1. package/index.ts +11 -10
  2. package/package.json +2 -2
  3. package/valid-send.ts +4 -3
package/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import "dotenv/config";
2
+ import {oneDay, oneSecond} from "@mingjue8888/base-dependencies/datetime";
2
3
  import logger from "@mingjue8888/base-dependencies/logger";
3
- import {AbstractAccount, oneDay, oneSecond} from "@mingjue8888/base-dependencies/ubiquitous-language";
4
+ import {RBAC0Account} from "@mingjue8888/base-dependencies/rbac0";
4
5
  import compression from "compression";
5
6
  import cors from "cors";
6
7
  import express from "express";
@@ -19,13 +20,6 @@ import ServerErrorResponseError from "./server-error-response-error";
19
20
  import TooManyRequestsResponseError from "./too-many-requests-response-error";
20
21
  import UnauthorizedResponseError from "./unauthorized-response-error";
21
22
 
22
- type DeepArray<T> =
23
- | T[]
24
- | DeepArray<T>[];
25
-
26
- type JWTPayload =
27
- Required<Pick<JwtPayload, "exp" | "sub" | "iat">>;
28
-
29
23
  type ResponseErrorConverter =
30
24
  (err: Error) => ResponseError | void;
31
25
 
@@ -69,7 +63,7 @@ function errorHandler(
69
63
 
70
64
  declare global {
71
65
  namespace Express {
72
- interface User extends AbstractAccount {}
66
+ interface User extends RBAC0Account {}
73
67
  interface Response {
74
68
  signToken: (sub: string) => void;
75
69
  body?: any;
@@ -86,8 +80,11 @@ interface EnvOptions {
86
80
  JWT_EXPIRE?: number;
87
81
  }
88
82
 
83
+ type JWTPayload =
84
+ Required<Pick<JwtPayload, "exp" | "sub" | "iat">>;
85
+
89
86
  interface StartupOptions extends EnvOptions {
90
- authenticate?: <T extends AbstractAccount>(token: JWTPayload) => Promise<T>;
87
+ authenticate?: <T extends RBAC0Account>(token: JWTPayload) => Promise<T>;
91
88
  middlewares?: Middleware[];
92
89
  onError?: ResponseErrorConverter;
93
90
  }
@@ -124,6 +121,10 @@ const optSchema = Joi.object<Required<StartupOptions>, StartupOptions>({
124
121
  }),
125
122
  });
126
123
 
124
+ type DeepArray<T> =
125
+ | T[]
126
+ | DeepArray<T>[];
127
+
127
128
  export default function app(routers: DeepArray<Router>, opt?: StartupOptions) {
128
129
  if (opt) {
129
130
  Reflect.ownKeys(process.env)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mingjue8888/express-plus",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "repository": "github:mingjue8888/express-plus",
5
5
  "keywords": [
6
6
  "web",
@@ -12,7 +12,7 @@
12
12
  "router"
13
13
  ],
14
14
  "dependencies": {
15
- "@mingjue8888/base-dependencies": "^1.5.2",
15
+ "@mingjue8888/base-dependencies": "^1.5.5",
16
16
  "compression": "^1.8.2",
17
17
  "cors": "^2.8.6",
18
18
  "express-rate-limit": "^8.7.4",
package/valid-send.ts CHANGED
@@ -8,9 +8,10 @@ export default function validSend(sch: Record<string, Joi.AnySchema>) {
8
8
  .object(sch)
9
9
  .validate(res.body);
10
10
 
11
- if (error) {
11
+ if (error)
12
12
  throw new ServerErrorResponseError("WrongResponseError", error.message);
13
- }
14
- res.status(200).send(value);
13
+
14
+ res.status(200)
15
+ .send(value);
15
16
  });
16
17
  }