express-yaschema-api-handler
Advanced tools
Comparing version 2.2.8 to 2.2.9
@@ -24,3 +24,3 @@ "use strict"; | ||
const is_unsupported_http_method_1 = require("../internal-utils/is-unsupported-http-method"); | ||
const resolve_yaschema_json_prefixed_form_data_fields_1 = require("../internal-utils/resolve-yaschema-json-prefixed-form-data-fields"); | ||
const resolve_special_form_data_fields_1 = require("../internal-utils/resolve-special-form-data-fields"); | ||
const register_api_handler_1 = require("../register-api-handler/register-api-handler"); | ||
@@ -45,3 +45,3 @@ const anyStringSerializableTypeSchema = yaschema_1.schema.oneOf3(yaschema_1.schema.number().setAllowedSerializationForms(['number', 'string']), yaschema_1.schema.boolean().setAllowedSerializationForms(['boolean', 'string']), yaschema_1.schema.string()); | ||
// In-place substitution of prefixed JSON strings with their resolved values | ||
(0, resolve_yaschema_json_prefixed_form_data_fields_1.resolveYaschemaJsonPrefixedFormDataFields)(req.body); | ||
(0, resolve_special_form_data_fields_1.resolveSpecialFormDataFields)(req.body); | ||
} | ||
@@ -48,0 +48,0 @@ const [reqHeaders, reqParams, reqQuery, reqBody] = yield Promise.all([ |
@@ -21,3 +21,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import { isUnsupportedHttpMethod } from '../internal-utils/is-unsupported-http-method'; | ||
import { resolveYaschemaJsonPrefixedFormDataFields } from '../internal-utils/resolve-yaschema-json-prefixed-form-data-fields'; | ||
import { resolveSpecialFormDataFields } from '../internal-utils/resolve-special-form-data-fields'; | ||
import { registerApiHandler } from '../register-api-handler/register-api-handler'; | ||
@@ -42,3 +42,3 @@ const anyStringSerializableTypeSchema = schema.oneOf3(schema.number().setAllowedSerializationForms(['number', 'string']), schema.boolean().setAllowedSerializationForms(['boolean', 'string']), schema.string()); | ||
// In-place substitution of prefixed JSON strings with their resolved values | ||
resolveYaschemaJsonPrefixedFormDataFields(req.body); | ||
resolveSpecialFormDataFields(req.body); | ||
} | ||
@@ -45,0 +45,0 @@ const [reqHeaders, reqParams, reqQuery, reqBody] = yield Promise.all([ |
{ | ||
"name": "express-yaschema-api-handler", | ||
"version": "2.2.8", | ||
"version": "2.2.9", | ||
"description": "Express handler support for yaschema-api", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -30,3 +30,4 @@ import 'fast-text-encoding'; // node-fetch 3 needs this polyfill in Node | ||
three: schema.any(), // File | ||
four: schema.object({ a: schema.string() }) | ||
four: schema.object({ a: schema.string() }), | ||
five: schema.array() // Files | ||
}) | ||
@@ -55,10 +56,11 @@ }, | ||
POST, | ||
{ middlewares: acceptFilesMiddlewares({ three: 1 }) }, | ||
{ middlewares: acceptFilesMiddlewares({ three: 1, 'five[]': 2 }) }, | ||
async ({ express: _express, input, output }) => { | ||
const three = (input.body.three as Express.Multer.File[])[0]; | ||
const five = input.body.five as Express.Multer.File[]; | ||
output.success(StatusCodes.OK, { | ||
body: `GOT ${input.body.one} AND ${input.body.two} AND file (${three.buffer.toString('utf-8')}) with length ${ | ||
body: `GOT ${input.body.one} AND ${input.body.two} AND file(three) (${three.buffer.toString('utf-8')}) with length ${ | ||
three.size | ||
} AND ${JSON.stringify(input.body.four)}` | ||
} AND ${JSON.stringify(input.body.four)} AND file(five[0]) (${five[0].buffer.toString('utf-8')}) with length ${five[0].size} AND file(five[1]) (${five[1].buffer.toString('utf-8')}) with length ${five[1].size}` | ||
}); | ||
@@ -113,3 +115,4 @@ } | ||
three: new Blob([Buffer.from('hi there', 'utf-8')]), | ||
four: { a: 'hi' } | ||
four: { a: 'hi' }, | ||
five: [new Blob([Buffer.from('hello world', 'utf-8')]), new Blob([Buffer.from('goodbye world', 'utf-8')])] | ||
} | ||
@@ -123,3 +126,5 @@ }); | ||
expect(res.status).toBe(StatusCodes.OK); | ||
expect(res.body).toBe('GOT hello AND 12345678-9876 AND file (hi there) with length 8 AND {"a":"hi"}'); | ||
expect(res.body).toBe( | ||
'GOT hello AND 12345678-9876 AND file(three) (hi there) with length 8 AND {"a":"hi"} AND file(five[0]) (hello world) with length 11 AND file(five[1]) (goodbye world) with length 13' | ||
); | ||
@@ -126,0 +131,0 @@ expect(true).toBe(true); |
@@ -25,3 +25,3 @@ import type { Express, NextFunction, Request, RequestHandler, Response } from 'express'; | ||
import { isUnsupportedHttpMethod } from '../internal-utils/is-unsupported-http-method'; | ||
import { resolveYaschemaJsonPrefixedFormDataFields } from '../internal-utils/resolve-yaschema-json-prefixed-form-data-fields'; | ||
import { resolveSpecialFormDataFields } from '../internal-utils/resolve-special-form-data-fields'; | ||
import { registerApiHandler } from '../register-api-handler/register-api-handler'; | ||
@@ -87,3 +87,3 @@ import type { HttpApiHandler } from '../types/HttpApiHandler'; | ||
// In-place substitution of prefixed JSON strings with their resolved values | ||
resolveYaschemaJsonPrefixedFormDataFields(req.body); | ||
resolveSpecialFormDataFields(req.body); | ||
} | ||
@@ -90,0 +90,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
158504
2177