rlz-engine 1.0.45 → 1.0.47
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/rpc/gen.js +9 -6
- package/dist/back/server.d.ts +3 -1
- package/dist/back/server.js +4 -4
- package/package.json +1 -1
package/dist/back/rpc/gen.js
CHANGED
|
@@ -19,7 +19,7 @@ export function generateClient(fileName, ...rpcBuilders) {
|
|
|
19
19
|
}
|
|
20
20
|
const props = rpcBuilders.map((b) => {
|
|
21
21
|
const calls = b.endpoints.map((e) => {
|
|
22
|
-
return F.createPropertyAssignment(F.createIdentifier(e.name), F.createArrowFunction([F.createToken(ts.SyntaxKind.AsyncKeyword)], undefined, e.anonimous
|
|
22
|
+
return F.createPropertyAssignment(F.createIdentifier(kebabToPascalCase(e.name)), F.createArrowFunction([F.createToken(ts.SyntaxKind.AsyncKeyword)], undefined, e.anonimous
|
|
23
23
|
? [
|
|
24
24
|
F.createParameterDeclaration(undefined, undefined, F.createIdentifier('body'), undefined, F.createTypeReferenceNode(F.createIdentifier(createBodyTypeName(b.name, e)), undefined), undefined)
|
|
25
25
|
]
|
|
@@ -34,7 +34,7 @@ export function generateClient(fileName, ...rpcBuilders) {
|
|
|
34
34
|
F.createIdentifier('body')
|
|
35
35
|
])))], true)));
|
|
36
36
|
});
|
|
37
|
-
return F.createPropertyAssignment(F.createIdentifier(b.name), F.createObjectLiteralExpression(calls, false));
|
|
37
|
+
return F.createPropertyAssignment(F.createIdentifier(kebabToPascalCase(b.name)), F.createObjectLiteralExpression(calls, false));
|
|
38
38
|
});
|
|
39
39
|
const rpcClientNode = F.createVariableStatement([F.createToken(ts.SyntaxKind.ExportKeyword)], F.createVariableDeclarationList([F.createVariableDeclaration(F.createIdentifier('RPC_CLIENT'), undefined, undefined, F.createObjectLiteralExpression(props, false))], ts.NodeFlags.Const));
|
|
40
40
|
fileContent.push(p(rpcClientNode));
|
|
@@ -53,12 +53,15 @@ function generateTypes(rpcName, e, p) {
|
|
|
53
53
|
resp.push(p(respTypeAlias));
|
|
54
54
|
return resp;
|
|
55
55
|
}
|
|
56
|
-
function firstLetterUp
|
|
57
|
-
|
|
56
|
+
function kebabToPascalCase(input, firstLetterUp = false) {
|
|
57
|
+
if (firstLetterUp) {
|
|
58
|
+
return input.replace(/(^|-)([a-z])/g, (_, __, c) => c.toUpperCase());
|
|
59
|
+
}
|
|
60
|
+
return input.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
58
61
|
}
|
|
59
62
|
function createBodyTypeName(rpcName, e) {
|
|
60
|
-
return `RpcBody${
|
|
63
|
+
return `RpcBody${kebabToPascalCase(rpcName, true)}${kebabToPascalCase(e.name, true)}V${e.v}`;
|
|
61
64
|
}
|
|
62
65
|
function createRespTypeName(rpcName, e) {
|
|
63
|
-
return `RpcResp${
|
|
66
|
+
return `RpcResp${kebabToPascalCase(rpcName, true)}${kebabToPascalCase(e.name, true)}V${e.v}`;
|
|
64
67
|
}
|
package/dist/back/server.d.ts
CHANGED
|
@@ -3,9 +3,11 @@ import { Logger } from 'pino';
|
|
|
3
3
|
export type InitServerFuncType = <S extends RawServerBase>(server: FastifyInstance<S, RawRequestDefaultExpression<S>, RawReplyDefaultExpression<S>, Logger>) => Promise<void>;
|
|
4
4
|
export interface RunServerParams {
|
|
5
5
|
production: boolean;
|
|
6
|
+
unsecurePort?: number;
|
|
7
|
+
securePort?: number;
|
|
6
8
|
domain: string;
|
|
7
9
|
certDir: string;
|
|
8
10
|
staticDir: string;
|
|
9
11
|
init: InitServerFuncType;
|
|
10
12
|
}
|
|
11
|
-
export declare function runServer({ production, domain, certDir, staticDir, init }: RunServerParams): Promise<() => Promise<void>>;
|
|
13
|
+
export declare function runServer({ production, domain, certDir, staticDir, securePort, unsecurePort, init }: RunServerParams): Promise<() => Promise<void>>;
|
package/dist/back/server.js
CHANGED
|
@@ -12,7 +12,7 @@ import path from 'path';
|
|
|
12
12
|
import { logger } from './logger.js';
|
|
13
13
|
installIntoGlobal();
|
|
14
14
|
const L = logger('init');
|
|
15
|
-
export async function runServer({ production, domain, certDir, staticDir, init }) {
|
|
15
|
+
export async function runServer({ production, domain, certDir, staticDir, securePort, unsecurePort, init }) {
|
|
16
16
|
L.info({ production }, 'runServer');
|
|
17
17
|
const httpServer = fastify({
|
|
18
18
|
loggerInstance: logger('http'),
|
|
@@ -32,13 +32,13 @@ export async function runServer({ production, domain, certDir, staticDir, init }
|
|
|
32
32
|
return httpErrors.notFound();
|
|
33
33
|
});
|
|
34
34
|
addStaticEndpoints(httpServer, staticDir);
|
|
35
|
-
await httpServer.listen({ port: 8080 });
|
|
35
|
+
await httpServer.listen({ port: unsecurePort ?? 8080 });
|
|
36
36
|
return async () => {
|
|
37
37
|
await httpServer.close();
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
httpServer.register(fastifyAcmeUnsecurePlugin, { redirectDomain: domain });
|
|
41
|
-
await httpServer.listen({ port: 80, host: '::' });
|
|
41
|
+
await httpServer.listen({ port: unsecurePort ?? 80, host: '::' });
|
|
42
42
|
L.info('Get certificates');
|
|
43
43
|
const certAndKey = await getCertAndKey(certDir, domain);
|
|
44
44
|
L.info('Init secure server');
|
|
@@ -67,7 +67,7 @@ export async function runServer({ production, domain, certDir, staticDir, init }
|
|
|
67
67
|
return httpErrors.notFound();
|
|
68
68
|
});
|
|
69
69
|
addStaticEndpoints(httpsServer, staticDir);
|
|
70
|
-
await httpsServer.listen({ port: 443, host: '::' });
|
|
70
|
+
await httpsServer.listen({ port: securePort ?? 443, host: '::' });
|
|
71
71
|
L.info('runServer done');
|
|
72
72
|
return async () => {
|
|
73
73
|
await Promise.all([
|