@openapi-typescript-infra/service 5.9.0 → 5.9.2
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/build/types.d.ts
CHANGED
|
@@ -63,6 +63,8 @@ export interface DelayLoadServiceStartOptions extends Omit<ServiceStartOptions,
|
|
|
63
63
|
service: string;
|
|
64
64
|
}
|
|
65
65
|
export interface ServiceOptions {
|
|
66
|
+
codepath: string;
|
|
67
|
+
codeExtension: string;
|
|
66
68
|
configurationDirectories: string[];
|
|
67
69
|
openApiOptions?: Partial<Parameters<typeof middleware>[0]>;
|
|
68
70
|
shortstopHandlers: Record<string, ShortstopHandler<string, unknown>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openapi-typescript-infra/service",
|
|
3
|
-
"version": "5.9.
|
|
3
|
+
"version": "5.9.2",
|
|
4
4
|
"description": "An opinionated framework for building configuration driven services - web, api, or ob. Uses OpenAPI, pino logging, express, confit, Typescript and vitest.",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
package/src/express-app/app.ts
CHANGED
|
@@ -97,9 +97,13 @@ export async function startApp<
|
|
|
97
97
|
assert(serviceImpl?.start, 'Service function did not return a conforming object');
|
|
98
98
|
|
|
99
99
|
const sourceDirectory = path.join(rootDirectory, codepath);
|
|
100
|
+
const codeExtension = codepath === 'src' ? '.ts' : '.js';
|
|
101
|
+
|
|
100
102
|
const baseOptions: ServiceOptions = {
|
|
101
103
|
configurationDirectories: [path.resolve(rootDirectory, './config')],
|
|
102
104
|
shortstopHandlers: shortstops({ name }, sourceDirectory),
|
|
105
|
+
codepath,
|
|
106
|
+
codeExtension,
|
|
103
107
|
};
|
|
104
108
|
const options = serviceImpl.configure?.(startOptions, baseOptions) || baseOptions;
|
|
105
109
|
|
|
@@ -188,7 +192,7 @@ export async function startApp<
|
|
|
188
192
|
);
|
|
189
193
|
}
|
|
190
194
|
if (routing?.bodyParsers?.form) {
|
|
191
|
-
app.use(express.urlencoded());
|
|
195
|
+
app.use(express.urlencoded(typeof routing.bodyParsers.form === 'object' ? routing.bodyParsers.form : {}));
|
|
192
196
|
}
|
|
193
197
|
|
|
194
198
|
if (serviceImpl.authorize) {
|
package/src/types.ts
CHANGED
|
@@ -143,6 +143,11 @@ export interface DelayLoadServiceStartOptions extends Omit<ServiceStartOptions,
|
|
|
143
143
|
|
|
144
144
|
// Handled by service.configure
|
|
145
145
|
export interface ServiceOptions {
|
|
146
|
+
// Used to resolve code paths flexibly during dev/prod
|
|
147
|
+
codepath: string;
|
|
148
|
+
// Will be either .ts or .js depending on the runtime environment
|
|
149
|
+
codeExtension: string;
|
|
150
|
+
|
|
146
151
|
// If you need multiple configuration directories, pass them here
|
|
147
152
|
// in the desired order (later trumps earlier)
|
|
148
153
|
configurationDirectories: string[];
|