@openapi-typescript-infra/service 5.8.1 → 5.9.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openapi-typescript-infra/service",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.9.1",
|
|
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/config/schema.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BaseConfitSchema } from '@sesamecare-oss/confit';
|
|
2
2
|
import type { middleware } from 'express-openapi-validator';
|
|
3
3
|
import type { Level } from 'pino';
|
|
4
|
+
import bodyParser from 'body-parser';
|
|
4
5
|
|
|
5
6
|
export interface ConfigurationItemEnabled {
|
|
6
7
|
enabled?: boolean;
|
|
@@ -28,8 +29,8 @@ export interface ConfigurationSchema extends BaseConfitSchema {
|
|
|
28
29
|
etag?: boolean;
|
|
29
30
|
cookieParser?: boolean;
|
|
30
31
|
bodyParsers?: {
|
|
31
|
-
json?: boolean;
|
|
32
|
-
form?: boolean;
|
|
32
|
+
json?: boolean | Parameters<typeof bodyParser.json>[0];
|
|
33
|
+
form?: boolean | Parameters<typeof bodyParser.urlencoded>[0];
|
|
33
34
|
};
|
|
34
35
|
// Set static.enabled to true to enable static assets to be served
|
|
35
36
|
static?: ConfigurationItemEnabled & {
|
package/src/express-app/app.ts
CHANGED
|
@@ -174,6 +174,7 @@ export async function startApp<
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
if (routing?.bodyParsers?.json) {
|
|
177
|
+
const jsonArgs = typeof routing.bodyParsers.json === 'object' ? routing.bodyParsers.json : {};
|
|
177
178
|
app.use(
|
|
178
179
|
express.json({
|
|
179
180
|
verify(req, res, buf) {
|
|
@@ -182,11 +183,12 @@ export async function startApp<
|
|
|
182
183
|
locals.rawBody = buf;
|
|
183
184
|
}
|
|
184
185
|
},
|
|
186
|
+
...jsonArgs,
|
|
185
187
|
}),
|
|
186
188
|
);
|
|
187
189
|
}
|
|
188
190
|
if (routing?.bodyParsers?.form) {
|
|
189
|
-
app.use(express.urlencoded());
|
|
191
|
+
app.use(express.urlencoded(typeof routing.bodyParsers.form === 'object' ? routing.bodyParsers.form : {}));
|
|
190
192
|
}
|
|
191
193
|
|
|
192
194
|
if (serviceImpl.authorize) {
|