rlz-engine 1.0.31 → 1.0.33
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/back/server.js +4 -4
- package/dist/client/api/api.d.ts +14 -4
- package/dist/client/api/api.js +30 -9
- package/package.json +1 -1
package/dist/back/server.js
CHANGED
|
@@ -16,7 +16,7 @@ export async function runServer({ production, domain, certDir, staticDir, init }
|
|
|
16
16
|
L.info({ production }, 'runServer');
|
|
17
17
|
const httpServer = fastify({
|
|
18
18
|
loggerInstance: logger('http'),
|
|
19
|
-
ajv: { plugins: [formatsPlugin] }
|
|
19
|
+
ajv: { plugins: [formatsPlugin], customOptions: { useDefaults: false } }
|
|
20
20
|
});
|
|
21
21
|
if (!production) {
|
|
22
22
|
await httpServer.register(fastifyCors, {
|
|
@@ -25,7 +25,7 @@ export async function runServer({ production, domain, certDir, staticDir, init }
|
|
|
25
25
|
await httpServer.register(fastifyCompress);
|
|
26
26
|
await httpServer.register(fastifySensible);
|
|
27
27
|
await httpServer.register(fastifyResponseValidation, {
|
|
28
|
-
ajv: { plugins: [formatsPlugin] }
|
|
28
|
+
ajv: { plugins: [formatsPlugin], useDefaults: false }
|
|
29
29
|
});
|
|
30
30
|
await init(httpServer);
|
|
31
31
|
httpServer.all('/api/*', async () => {
|
|
@@ -48,7 +48,7 @@ export async function runServer({ production, domain, certDir, staticDir, init }
|
|
|
48
48
|
key: certAndKey.pkey
|
|
49
49
|
},
|
|
50
50
|
loggerInstance: logger('https'),
|
|
51
|
-
ajv: { plugins: [formatsPlugin] }
|
|
51
|
+
ajv: { plugins: [formatsPlugin], customOptions: { useDefaults: false } }
|
|
52
52
|
});
|
|
53
53
|
await httpsServer.register(fastifyAcmeSecurePlugin, {
|
|
54
54
|
certDir,
|
|
@@ -59,7 +59,7 @@ export async function runServer({ production, domain, certDir, staticDir, init }
|
|
|
59
59
|
});
|
|
60
60
|
await httpsServer.register(fastifyCompress);
|
|
61
61
|
await httpsServer.register(fastifySensible);
|
|
62
|
-
await httpsServer.register(fastifyResponseValidation, { ajv: { plugins: [formatsPlugin] } });
|
|
62
|
+
await httpsServer.register(fastifyResponseValidation, { ajv: { plugins: [formatsPlugin], useDefaults: false } });
|
|
63
63
|
await init(httpsServer);
|
|
64
64
|
httpsServer.all('/api/*', async () => {
|
|
65
65
|
return httpErrors.notFound();
|
package/dist/client/api/api.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import z, { ZodType } from 'zod';
|
|
2
|
-
export declare class
|
|
3
|
-
|
|
2
|
+
export declare class HttpError extends Error {
|
|
3
|
+
readonly method: string;
|
|
4
|
+
readonly url: string;
|
|
5
|
+
readonly status: number;
|
|
6
|
+
readonly statusText: string;
|
|
7
|
+
constructor(method: string, url: string, status: number, statusText: string);
|
|
4
8
|
}
|
|
5
|
-
export declare class
|
|
6
|
-
constructor(url: string);
|
|
9
|
+
export declare class Unauthorized extends HttpError {
|
|
10
|
+
constructor(method: string, url: string, statusText: string);
|
|
11
|
+
}
|
|
12
|
+
export declare class Forbidden extends HttpError {
|
|
13
|
+
constructor(method: string, url: string, statusText: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class NotFound extends HttpError {
|
|
16
|
+
constructor(method: string, url: string, statusText: string);
|
|
7
17
|
}
|
|
8
18
|
export interface AuthParam {
|
|
9
19
|
userId: string;
|
package/dist/client/api/api.js
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
import { getFrontConfig } from '../config';
|
|
2
|
-
export class
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export class HttpError extends Error {
|
|
3
|
+
method;
|
|
4
|
+
url;
|
|
5
|
+
status;
|
|
6
|
+
statusText;
|
|
7
|
+
constructor(method, url, status, statusText) {
|
|
8
|
+
super(`Not ok resp (${status} ${statusText}): ${method} ${url}`);
|
|
9
|
+
this.method = method;
|
|
10
|
+
this.url = url;
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.statusText = statusText;
|
|
5
13
|
}
|
|
6
14
|
}
|
|
7
|
-
export class
|
|
8
|
-
constructor(url) {
|
|
9
|
-
super(
|
|
15
|
+
export class Unauthorized extends HttpError {
|
|
16
|
+
constructor(method, url, statusText) {
|
|
17
|
+
super(method, url, 401, statusText);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class Forbidden extends HttpError {
|
|
21
|
+
constructor(method, url, statusText) {
|
|
22
|
+
super(method, url, 403, statusText);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class NotFound extends HttpError {
|
|
26
|
+
constructor(method, url, statusText) {
|
|
27
|
+
super(method, url, 404, statusText);
|
|
10
28
|
}
|
|
11
29
|
}
|
|
12
30
|
function url(version, path, queryString) {
|
|
@@ -50,12 +68,15 @@ export async function apiCall(method, version, path, auth, queryString, request,
|
|
|
50
68
|
});
|
|
51
69
|
if (!resp.ok) {
|
|
52
70
|
if (resp.status === 401) {
|
|
53
|
-
throw new Unauthorized(u);
|
|
71
|
+
throw new Unauthorized(method, u, resp.statusText);
|
|
54
72
|
}
|
|
55
73
|
if (resp.status === 403) {
|
|
56
|
-
throw new Forbidden(u);
|
|
74
|
+
throw new Forbidden(method, u, resp.statusText);
|
|
75
|
+
}
|
|
76
|
+
if (resp.status === 404) {
|
|
77
|
+
throw new NotFound(method, u, resp.statusText);
|
|
57
78
|
}
|
|
58
|
-
throw
|
|
79
|
+
throw new HttpError(method, u, resp.status, resp.statusText);
|
|
59
80
|
}
|
|
60
81
|
if (resp.status === 204) {
|
|
61
82
|
return validator.parse(undefined);
|