@stonyx/rest-server 0.2.1-beta.39 → 0.2.1-beta.40
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/dist/main.js +2 -1
- package/dist/request.d.ts +1 -1
- package/dist/request.js +6 -5
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -54,7 +54,8 @@ export default class RestServer {
|
|
|
54
54
|
catch (error) {
|
|
55
55
|
if (config.debug)
|
|
56
56
|
console.log(error);
|
|
57
|
-
|
|
57
|
+
log.error(`Unable to dynamically configure routes from files in ${dir}`);
|
|
58
|
+
throw new Error(`Unable to dynamically configure routes from files in ${dir}`);
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
setupGlobalMiddleware() {
|
package/dist/request.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type AuthHandler = (req: ExpressRequest, state: RequestState) => number |
|
|
|
5
5
|
export type RouteHandlers = Record<string, Record<string, RequestHandler | RequestHandler[]>>;
|
|
6
6
|
export default class Request {
|
|
7
7
|
static stateProp: string;
|
|
8
|
-
static getState(req:
|
|
8
|
+
static getState(req: ExpressRequest): RequestState;
|
|
9
9
|
static sendStatusResponse(res: ExpressResponse, status: number): void;
|
|
10
10
|
expressInstance: Express;
|
|
11
11
|
handlers: RouteHandlers;
|
package/dist/request.js
CHANGED
|
@@ -6,13 +6,14 @@ export default class Request {
|
|
|
6
6
|
static stateProp = '__stonyxState';
|
|
7
7
|
static getState(req) {
|
|
8
8
|
const { stateProp } = Request;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const record = req;
|
|
10
|
+
if (record[stateProp] !== undefined)
|
|
11
|
+
return record[stateProp];
|
|
12
|
+
record[stateProp] = {};
|
|
13
|
+
return record[stateProp];
|
|
13
14
|
}
|
|
14
15
|
static sendStatusResponse(res, status) {
|
|
15
|
-
const statusMap = config.restServer?.statusMap
|
|
16
|
+
const statusMap = config.restServer?.statusMap ?? {};
|
|
16
17
|
const message = statusMap[status] || '';
|
|
17
18
|
if (message) {
|
|
18
19
|
res.status(status).send(message);
|