@rvoh/psychic 2.3.6 → 2.3.8
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/cjs/src/openapi-renderer/endpoint.js +1 -1
- package/dist/cjs/src/psychic-app/index.js +7 -0
- package/dist/cjs/src/server/helpers/startPsychicServer.js +3 -1
- package/dist/esm/src/openapi-renderer/endpoint.js +1 -1
- package/dist/esm/src/psychic-app/index.js +7 -0
- package/dist/esm/src/server/helpers/startPsychicServer.js +3 -1
- package/dist/types/src/psychic-app/index.d.ts +6 -3
- package/package.json +1 -1
|
@@ -317,7 +317,7 @@ export default class OpenapiEndpointRenderer {
|
|
|
317
317
|
return (controllerRouteConf.controller === this.controllerClass && controllerRouteConf.action === this.action);
|
|
318
318
|
});
|
|
319
319
|
const route = this.action === 'update'
|
|
320
|
-
? filteredRoutes.find(routeConfig => routeConfig.httpMethod === 'patch')
|
|
320
|
+
? filteredRoutes.find(routeConfig => routeConfig.httpMethod === 'patch') || filteredRoutes.at(0)
|
|
321
321
|
: filteredRoutes.at(0);
|
|
322
322
|
if (!route)
|
|
323
323
|
throw new MissingControllerActionPairingInRoutes(this.controllerClass, this.action);
|
|
@@ -246,6 +246,10 @@ Try setting it to something valid, like:
|
|
|
246
246
|
get port() {
|
|
247
247
|
return this._port;
|
|
248
248
|
}
|
|
249
|
+
_httpServerOptions = {};
|
|
250
|
+
get httpServerOptions() {
|
|
251
|
+
return this._httpServerOptions;
|
|
252
|
+
}
|
|
249
253
|
_corsOptions = {};
|
|
250
254
|
get corsOptions() {
|
|
251
255
|
return this._corsOptions;
|
|
@@ -485,6 +489,9 @@ Try setting it to something valid, like:
|
|
|
485
489
|
case 'apiOnly':
|
|
486
490
|
this._apiOnly = value;
|
|
487
491
|
break;
|
|
492
|
+
case 'httpServerOptions':
|
|
493
|
+
this._httpServerOptions = value;
|
|
494
|
+
break;
|
|
488
495
|
case 'apiRoot':
|
|
489
496
|
this._apiRoot = value;
|
|
490
497
|
break;
|
|
@@ -16,16 +16,18 @@ export default async function startPsychicServer({ app, port, sslCredentials, })
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
export function createPsychicHttpInstance(app, sslCredentials) {
|
|
19
|
+
const psychicApp = PsychicApp.getOrFail();
|
|
19
20
|
if (sslCredentials?.key && sslCredentials?.cert) {
|
|
20
21
|
return https.createServer({
|
|
21
22
|
key: fs.readFileSync(sslCredentials.key),
|
|
22
23
|
cert: fs.readFileSync(sslCredentials.cert),
|
|
23
24
|
ca: sslCredentials.ca?.map(filePath => fs.readFileSync(filePath)),
|
|
24
25
|
rejectUnauthorized: sslCredentials?.rejectUnauthorized,
|
|
26
|
+
...psychicApp.httpServerOptions,
|
|
25
27
|
}, app);
|
|
26
28
|
}
|
|
27
29
|
else {
|
|
28
|
-
return http.createServer(app);
|
|
30
|
+
return http.createServer(psychicApp.httpServerOptions, app);
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
function welcomeMessage({ port }) {
|
|
@@ -317,7 +317,7 @@ export default class OpenapiEndpointRenderer {
|
|
|
317
317
|
return (controllerRouteConf.controller === this.controllerClass && controllerRouteConf.action === this.action);
|
|
318
318
|
});
|
|
319
319
|
const route = this.action === 'update'
|
|
320
|
-
? filteredRoutes.find(routeConfig => routeConfig.httpMethod === 'patch')
|
|
320
|
+
? filteredRoutes.find(routeConfig => routeConfig.httpMethod === 'patch') || filteredRoutes.at(0)
|
|
321
321
|
: filteredRoutes.at(0);
|
|
322
322
|
if (!route)
|
|
323
323
|
throw new MissingControllerActionPairingInRoutes(this.controllerClass, this.action);
|
|
@@ -246,6 +246,10 @@ Try setting it to something valid, like:
|
|
|
246
246
|
get port() {
|
|
247
247
|
return this._port;
|
|
248
248
|
}
|
|
249
|
+
_httpServerOptions = {};
|
|
250
|
+
get httpServerOptions() {
|
|
251
|
+
return this._httpServerOptions;
|
|
252
|
+
}
|
|
249
253
|
_corsOptions = {};
|
|
250
254
|
get corsOptions() {
|
|
251
255
|
return this._corsOptions;
|
|
@@ -485,6 +489,9 @@ Try setting it to something valid, like:
|
|
|
485
489
|
case 'apiOnly':
|
|
486
490
|
this._apiOnly = value;
|
|
487
491
|
break;
|
|
492
|
+
case 'httpServerOptions':
|
|
493
|
+
this._httpServerOptions = value;
|
|
494
|
+
break;
|
|
488
495
|
case 'apiRoot':
|
|
489
496
|
this._apiRoot = value;
|
|
490
497
|
break;
|
|
@@ -16,16 +16,18 @@ export default async function startPsychicServer({ app, port, sslCredentials, })
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
export function createPsychicHttpInstance(app, sslCredentials) {
|
|
19
|
+
const psychicApp = PsychicApp.getOrFail();
|
|
19
20
|
if (sslCredentials?.key && sslCredentials?.cert) {
|
|
20
21
|
return https.createServer({
|
|
21
22
|
key: fs.readFileSync(sslCredentials.key),
|
|
22
23
|
cert: fs.readFileSync(sslCredentials.cert),
|
|
23
24
|
ca: sslCredentials.ca?.map(filePath => fs.readFileSync(filePath)),
|
|
24
25
|
rejectUnauthorized: sslCredentials?.rejectUnauthorized,
|
|
26
|
+
...psychicApp.httpServerOptions,
|
|
25
27
|
}, app);
|
|
26
28
|
}
|
|
27
29
|
else {
|
|
28
|
-
return http.createServer(app);
|
|
30
|
+
return http.createServer(psychicApp.httpServerOptions, app);
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
function welcomeMessage({ port }) {
|
|
@@ -7,6 +7,7 @@ import { Command } from 'commander';
|
|
|
7
7
|
import { CorsOptions } from 'cors';
|
|
8
8
|
import { Express, Request, RequestHandler, Response } from 'express';
|
|
9
9
|
import * as http from 'node:http';
|
|
10
|
+
import * as https from 'node:https';
|
|
10
11
|
import { OpenapiValidateTarget } from '../openapi-renderer/defaults.js';
|
|
11
12
|
import { OpenapiContent, OpenapiHeaders, OpenapiResponses, OpenapiSecurity, OpenapiSecuritySchemes, OpenapiServer, OpenapiValidateOption } from '../openapi-renderer/endpoint.js';
|
|
12
13
|
import PsychicRouter from '../router/index.js';
|
|
@@ -34,7 +35,7 @@ export default class PsychicApp {
|
|
|
34
35
|
/**
|
|
35
36
|
* @internal
|
|
36
37
|
*/
|
|
37
|
-
static getPsychicHttpInstance(app: Express, sslCredentials: PsychicSslCredentials | undefined): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse> |
|
|
38
|
+
static getPsychicHttpInstance(app: Express, sslCredentials: PsychicSslCredentials | undefined): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse> | https.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
38
39
|
/**
|
|
39
40
|
* Builds the routes cache if it does not already
|
|
40
41
|
* exist. This is called during PsychicApp.init,
|
|
@@ -139,6 +140,8 @@ export default class PsychicApp {
|
|
|
139
140
|
get appName(): string;
|
|
140
141
|
private _port;
|
|
141
142
|
get port(): number;
|
|
143
|
+
private _httpServerOptions;
|
|
144
|
+
get httpServerOptions(): http.ServerOptions<typeof http.IncomingMessage, typeof http.ServerResponse> | https.ServerOptions<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
142
145
|
private _corsOptions;
|
|
143
146
|
get corsOptions(): CorsOptions;
|
|
144
147
|
private _jsonOptions;
|
|
@@ -222,10 +225,10 @@ export default class PsychicApp {
|
|
|
222
225
|
plugin(cb: (app: PsychicApp) => void | Promise<void>): void;
|
|
223
226
|
on<T extends PsychicHookEventType>(hookEventType: T, cb: T extends 'server:error' ? (err: Error, req: Request, res: Response) => void | Promise<void> : T extends 'server:init:before-middleware' ? (psychicServer: PsychicServer) => void | Promise<void> : T extends 'server:init:after-middleware' ? (psychicServer: PsychicServer) => void | Promise<void> : T extends 'server:start' ? (psychicServer: PsychicServer) => void | Promise<void> : T extends 'server:shutdown' ? (psychicServer: PsychicServer) => void | Promise<void> : T extends 'server:init:after-routes' ? (psychicServer: PsychicServer) => void | Promise<void> : T extends 'cli:start' ? (program: Command) => void | Promise<void> : T extends 'cli:sync' ? () => any : (conf: PsychicApp) => void | Promise<void>): void;
|
|
224
227
|
set(option: 'openapi', name: string, value: NamedPsychicOpenapiOptions): void;
|
|
225
|
-
set<Opt extends PsychicAppOption>(option: Opt, value: Opt extends 'appName' ? string : Opt extends 'apiOnly' ? boolean : Opt extends 'defaultResponseHeaders' ? Record<string, string | null> : Opt extends 'encryption' ? PsychicAppEncryptionOptions : Opt extends 'cors' ? CorsOptions : Opt extends 'cookie' ? CustomCookieOptions : Opt extends 'apiRoot' ? string : Opt extends 'importExtension' ? GeneratorImportStyle : Opt extends 'sessionCookieName' ? string : Opt extends 'json' ? bodyParser.Options : Opt extends 'logger' ? PsychicLogger : Opt extends 'ssl' ? PsychicSslCredentials : Opt extends 'openapi' ? DefaultPsychicOpenapiOptions : Opt extends 'paths' ? PsychicPathOptions : Opt extends 'port' ? number : Opt extends 'saltRounds' ? number : Opt extends 'sanitizeResponseJson' ? boolean : Opt extends 'packageManager' ? DreamAppAllowedPackageManagersEnum : Opt extends 'inflections' ? () => void | Promise<void> : Opt extends 'routes' ? (r: PsychicRouter) => void | Promise<void> : never): void;
|
|
228
|
+
set<Opt extends PsychicAppOption>(option: Opt, value: Opt extends 'appName' ? string : Opt extends 'apiOnly' ? boolean : Opt extends 'defaultResponseHeaders' ? Record<string, string | null> : Opt extends 'httpServerOptions' ? http.ServerOptions | https.ServerOptions : Opt extends 'encryption' ? PsychicAppEncryptionOptions : Opt extends 'cors' ? CorsOptions : Opt extends 'cookie' ? CustomCookieOptions : Opt extends 'apiRoot' ? string : Opt extends 'importExtension' ? GeneratorImportStyle : Opt extends 'sessionCookieName' ? string : Opt extends 'json' ? bodyParser.Options : Opt extends 'logger' ? PsychicLogger : Opt extends 'ssl' ? PsychicSslCredentials : Opt extends 'openapi' ? DefaultPsychicOpenapiOptions : Opt extends 'paths' ? PsychicPathOptions : Opt extends 'port' ? number : Opt extends 'saltRounds' ? number : Opt extends 'sanitizeResponseJson' ? boolean : Opt extends 'packageManager' ? DreamAppAllowedPackageManagersEnum : Opt extends 'inflections' ? () => void | Promise<void> : Opt extends 'routes' ? (r: PsychicRouter) => void | Promise<void> : never): void;
|
|
226
229
|
override<Override extends keyof PsychicAppOverrides>(override: Override, value: PsychicAppOverrides[Override]): void;
|
|
227
230
|
}
|
|
228
|
-
export type PsychicAppOption = 'appName' | 'apiOnly' | 'apiRoot' | 'importExtension' | 'encryption' | 'sessionCookieName' | 'cookie' | 'cors' | 'defaultResponseHeaders' | 'inflections' | 'json' | 'logger' | 'openapi' | 'packageManager' | 'paths' | 'port' | 'routes' | 'saltRounds' | 'sanitizeResponseJson' | 'ssl';
|
|
231
|
+
export type PsychicAppOption = 'appName' | 'apiOnly' | 'apiRoot' | 'httpServerOptions' | 'importExtension' | 'encryption' | 'sessionCookieName' | 'cookie' | 'cors' | 'defaultResponseHeaders' | 'inflections' | 'json' | 'logger' | 'openapi' | 'packageManager' | 'paths' | 'port' | 'routes' | 'saltRounds' | 'sanitizeResponseJson' | 'ssl';
|
|
229
232
|
export interface PsychicAppSpecialHooks {
|
|
230
233
|
cliSync: (() => any)[];
|
|
231
234
|
serverInitBeforeMiddleware: ((server: PsychicServer) => void | Promise<void>)[];
|