{"version":3,"sources":["../../../src/frameworks/body-parser/index.ts","../../../src/network/request.ts","../../../src/network/response.ts","../../../src/network/utils.ts","../../../src/network/response-stream.ts","../../../src/core/no-op.ts","../../../src/core/logger.ts","../../../src/core/optional.ts","../../../src/core/stream.ts","../../../src/frameworks/body-parser/base-body-parser.framework.ts","../../../src/frameworks/body-parser/json-body-parser.framework.ts","../../../src/frameworks/body-parser/raw-body-parser.framework.ts","../../../src/frameworks/body-parser/text-body-parser.framework.ts","../../../src/frameworks/body-parser/urlencoded-body-parser.framework.ts"],"sourcesContent":["export * from './base-body-parser.framework';\nexport * from './json-body-parser.framework';\nexport * from './raw-body-parser.framework';\nexport * from './text-body-parser.framework';\nexport * from './urlencoded-body-parser.framework';\n","// ATTRIBUTION: https://github.com/dougmoscrop/serverless-http\nimport { IncomingMessage } from 'node:http';\nimport type { AddressInfo } from 'node:net';\nimport type { SingleValueHeaders } from '../@types';\nimport { NO_OP } from '../core';\n\nconst HTTPS_PORT = 443;\n\n/**\n * The properties to create a {@link ServerlessRequest}\n *\n * @breadcrumb Network / ServerlessRequest\n * @public\n */\nexport interface ServerlessRequestProps {\n  /**\n   * The HTTP Method of the request\n   */\n  method: string;\n\n  /**\n   * The URL requested\n   */\n  url: string;\n\n  /**\n   * The headers from the event source\n   */\n  headers: SingleValueHeaders;\n\n  /**\n   * The body from the event source\n   */\n  body?: Buffer | Uint8Array;\n\n  /**\n   * The IP Address from caller\n   */\n  remoteAddress?: string;\n}\n\n/**\n * The class that represents an {@link http#IncomingMessage} created by the library to represent an actual request to the framework.\n *\n * @breadcrumb Network / ServerlessRequest\n * @public\n */\nexport class ServerlessRequest extends IncomingMessage {\n  constructor({\n    method,\n    url,\n    headers,\n    body,\n    remoteAddress,\n  }: ServerlessRequestProps) {\n    super({\n      encrypted: true,\n      readable: true, // credits to @pnkp at https://github.com/CodeGenieApp/serverless-express/pull/692\n      remoteAddress,\n      address: () => ({ port: HTTPS_PORT }) as AddressInfo,\n      on: NO_OP,\n      removeListener: NO_OP,\n      removeEventListener: NO_OP,\n      end: NO_OP,\n      destroy: NO_OP,\n    } as any);\n\n    this.statusCode = 200;\n    this.statusMessage = 'OK';\n    this.complete = true;\n    this.httpVersion = '1.1';\n    this.httpVersionMajor = 1;\n    this.httpVersionMinor = 1;\n    this.method = method;\n    this.headers = headers;\n    this.body = body;\n    this.url = url;\n    this.ip = remoteAddress;\n\n    this._read = () => {\n      this.push(body);\n      this.push(null);\n    };\n  }\n\n  ip?: string;\n  body?: Buffer | Uint8Array;\n}\n","// ATTRIBUTION: https://github.com/dougmoscrop/serverless-http\nimport { IncomingMessage, ServerResponse } from 'node:http';\nimport type { Socket } from 'node:net';\nimport { NO_OP } from '../core';\nimport { getString } from './utils';\n\nconst headerEnd = '\\r\\n\\r\\n';\nconst endChunked = '0\\r\\n\\r\\n';\n\nconst BODY = Symbol('Response body');\nconst HEADERS = Symbol('Response headers');\n\nfunction addData(stream: ServerlessResponse, data: Uint8Array | string) {\n  if (\n    Buffer.isBuffer(data) ||\n    typeof data === 'string' ||\n    data instanceof Uint8Array\n  )\n    stream[BODY].push(Buffer.from(data));\n  else throw new Error(`response.write() of unexpected type: ${typeof data}`);\n}\n\n/**\n * The properties to create a {@link ServerlessResponse}.\n *\n * @breadcrumb Network / ServerlessResponse\n * @public\n */\nexport interface ServerlessResponseProps {\n  /**\n   * The HTTP Method from request\n   */\n  method?: string;\n}\n\n/**\n * The class that represents a response instance used to send to the framework and wait until the framework finishes processing the request.\n * Once it's happens, we use the properties from this response to built the response to the cloud.\n *\n * @breadcrumb Network / ServerlessResponse\n * @public\n */\nexport class ServerlessResponse extends ServerResponse {\n  constructor({ method }: ServerlessResponseProps) {\n    super({ method } as any);\n\n    this[BODY] = [];\n    this[HEADERS] = {};\n\n    this.useChunkedEncodingByDefault = false;\n    this.chunkedEncoding = false;\n    this._header = '';\n\n    // this ignore is used because I need to ignore these write calls:\n    // https://github.com/nodejs/node/blob/main/lib/_http_outgoing.js#L934-L935\n    // https://github.com/nodejs/node/blob/main/lib/_http_outgoing.js#L937\n    let writesToIgnore = 1;\n\n    const socket: Partial<Socket> & { _writableState: any } = {\n      _writableState: {},\n      writable: true,\n      on: NO_OP,\n      removeListener: NO_OP,\n      destroy: NO_OP,\n      cork: NO_OP,\n      uncork: NO_OP,\n      write: (\n        data: Uint8Array | string,\n        encoding?: string | null | (() => void),\n        cb?: () => void,\n      ): any => {\n        if (typeof encoding === 'function') {\n          cb = encoding;\n          encoding = null;\n        }\n\n        if (this._header === '' || this._wroteHeader) {\n          if (!this.chunkedEncoding) addData(this, data);\n          else {\n            if (writesToIgnore > 0) writesToIgnore--;\n            else if (data !== endChunked) {\n              addData(this, data);\n              writesToIgnore = 3;\n            }\n          }\n        } else {\n          const string = getString(data);\n          const index = string.indexOf(headerEnd);\n\n          if (index !== -1) {\n            const remainder = string.slice(index + headerEnd.length);\n\n            if (remainder && !this.chunkedEncoding) addData(this, remainder);\n\n            this._wroteHeader = true;\n          }\n        }\n\n        if (typeof cb === 'function') cb();\n      },\n    };\n\n    this.assignSocket(socket as unknown as Socket);\n  }\n\n  _header: string;\n  _headers?: Record<any, any>;\n  _wroteHeader?: boolean;\n\n  [BODY]: any[];\n  [HEADERS]: Record<any, any>;\n\n  get headers(): Record<any, any> {\n    return this[HEADERS];\n  }\n\n  static from(res: IncomingMessage) {\n    const response = new ServerlessResponse({ method: res.method });\n\n    response.statusCode = res.statusCode || 0;\n    response[HEADERS] = res.headers;\n    response[BODY] = (res as any).body ? [Buffer.from((res as any).body)] : [];\n    response.end();\n\n    return response;\n  }\n\n  static body(res: ServerlessResponse): Buffer {\n    return Buffer.concat(res[BODY]);\n  }\n\n  static headers(res: ServerlessResponse) {\n    const headers = res.getHeaders();\n\n    return Object.assign(headers, res[HEADERS]);\n  }\n\n  override setHeader(\n    key: string,\n    value: number | string | readonly string[],\n  ): any {\n    if (this._wroteHeader) this[HEADERS][key] = value;\n    else super.setHeader(key, value);\n  }\n\n  override writeHead(\n    statusCode: number,\n    statusMessage?: string | any | any[],\n    obj?: any | any[],\n  ): any {\n    const headersObjOrArray =\n      typeof statusMessage === 'string' ? obj : statusMessage;\n\n    const arrayHeaders = Array.isArray(headersObjOrArray)\n      ? headersObjOrArray\n      : [headersObjOrArray || {}];\n\n    for (const headers of arrayHeaders) {\n      for (const name in headers) {\n        this.setHeader(name, headers[name]!);\n\n        if (!this._wroteHeader) {\n          // we only need to initiate super.headers once\n          // writeHead will add the other headers itself\n          break;\n        }\n      }\n    }\n\n    return this.callNativeWriteHead(statusCode, statusMessage, obj);\n  }\n\n  /**\n   * I use ignore here because in nodejs 12.x, statusMessage can be string | OutgoingHttpHeaders\n   * But in nodejs \\>=14.x, statusMessage can also be OutgoingHttpHeaders[]\n   * I take care of these cases above, but here I can't handle it well, so I give up\n   * nodejs 12.x ref: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v12/http.d.ts#L229\n   * nodejs 14.x ref: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v14/http.d.ts#L263\n   */\n  protected callNativeWriteHead(\n    statusCode: number,\n    statusMessage?: string | any | any[],\n    obj?: any | any[],\n  ): this {\n    return super.writeHead(statusCode, statusMessage, obj);\n  }\n}\n","/**\n * Get the data from a buffer, string, or Uint8Array\n *\n * @breadcrumb Network\n * @param data - The data that was written inside the stream\n */\nexport function getString(data: Buffer | string | unknown) {\n  if (Buffer.isBuffer(data)) return data.toString('utf8');\n  else if (typeof data === 'string') return data;\n  else if (data instanceof Uint8Array) return new TextDecoder().decode(data);\n  else throw new Error(`response.write() of unexpected type: ${typeof data}`);\n}\n","import { ServerResponse } from 'node:http';\nimport type { Socket } from 'node:net';\nimport type { Writable } from 'node:stream';\nimport type { BothValueHeaders } from '../@types';\nimport { type ILogger, NO_OP, parseHeaders } from '../core';\nimport { getString } from './utils';\n\n// header or data crlf\nconst crlfBuffer = Buffer.from('\\r\\n');\n\nconst endChunked = '0\\r\\n\\r\\n';\nconst headerEnd = '\\r\\n\\r\\n';\nconst endStatusSeparator = '\\r\\n';\n\n/**\n * The properties to create a {@link ServerlessStreamResponse}.\n *\n * @breadcrumb Network / ServerlessStreamResponse\n * @public\n */\nexport interface ServerlessStreamResponseProps {\n  /**\n   * The HTTP Method from request\n   */\n  method?: string;\n\n  /**\n   * The callback to receive the headers when they are written to the stream\n   * You need to return a writable stream be able to continue writing the response\n   *\n   * @param statusCode - The status code of the response\n   * @param headers - The headers of the response\n   */\n  onReceiveHeaders: (statusCode: number, headers: BothValueHeaders) => Writable;\n\n  /**\n   * Instance of the logger\n   */\n  log: ILogger;\n}\n\n/**\n * The class that represents a response instance used to send to the framework and wait until the framework finishes processing the request.\n * This response is specially built to deal with transfer-encoding: chunked\n *\n * @breadcrumb Network / ServerlessStreamResponse\n * @public\n */\nexport class ServerlessStreamResponse extends ServerResponse {\n  constructor({\n    method,\n    onReceiveHeaders,\n    log,\n  }: ServerlessStreamResponseProps) {\n    super({ method } as any);\n\n    this.useChunkedEncodingByDefault = true;\n    this.chunkedEncoding = true;\n\n    let internalWritable: Writable | null = null;\n    let firstCrlfBufferEncountered = false;\n    let chunkEncountered = false;\n\n    const socket: Partial<Socket> & { _writableState: any } = {\n      _writableState: {},\n      writable: true,\n      on: NO_OP,\n      removeListener: NO_OP,\n      destroy: NO_OP,\n      cork: NO_OP,\n      uncork: NO_OP,\n      write: (\n        data: Uint8Array | string,\n        encoding?: string | null | (() => void),\n        cb?: () => void,\n      ): any => {\n        // very unlikely, I don't even know how to reproduce this, but exist on types\n        // istanbul ignore if\n        if (typeof encoding === 'function') {\n          cb = encoding;\n          encoding = null;\n        }\n\n        log.debug('SERVERLESS_ADAPTER:RESPONSE_STREAM:DATA', () => ({\n          data: Buffer.isBuffer(data) ? data.toString('utf8') : data,\n          encoding,\n        }));\n\n        if (!internalWritable) {\n          const stringData = getString(data);\n          const endStatusIndex = stringData.indexOf(endStatusSeparator);\n          const status = +stringData.slice(0, endStatusIndex).split(' ')[1];\n          const endHeaderIndex = stringData.indexOf(headerEnd);\n\n          const headerData = stringData.slice(\n            endStatusIndex + 2,\n            endHeaderIndex,\n          );\n          const headers = parseHeaders(headerData);\n          log.debug(\n            'SERVERLESS_ADAPTER:RESPONSE_STREAM:FRAMEWORK_HEADERS',\n            () => ({\n              headers,\n            }),\n          );\n\n          internalWritable = onReceiveHeaders(status, headers);\n\n          // If we get an endChunked right after header which means the response body is empty, we need to immediately end the writable\n          if (stringData.substring(endHeaderIndex + 4) === endChunked)\n            internalWritable.end();\n\n          return true;\n        }\n\n        // node sends the last chunk crlf as a string:\n        // https://github.com/nodejs/node/blob/v22.8.0/lib/_http_outgoing.js#L1131\n        if (data === endChunked) {\n          internalWritable.end(cb);\n          return true;\n        }\n\n        // check for header or data crlf\n        // node sends the header and data crlf as a buffer\n        // below code is aligned to following node implementation of the HTTP/1.1 chunked transfer coding:\n        // https://github.com/nodejs/node/blob/v22.8.0/lib/_http_outgoing.js#L1012-L1015\n        // for reference: https://datatracker.ietf.org/doc/html/rfc9112#section-7\n        if (Buffer.isBuffer(data) && crlfBuffer.equals(data)) {\n          const isHeaderCrlf = !firstCrlfBufferEncountered;\n          if (isHeaderCrlf) {\n            firstCrlfBufferEncountered = true;\n            return true;\n          }\n\n          const isDataCrlf = firstCrlfBufferEncountered && chunkEncountered;\n          if (isDataCrlf) {\n            // done with chunk\n            firstCrlfBufferEncountered = false;\n            chunkEncountered = false;\n            return true;\n          }\n\n          // the crlf *is* the chunk\n        }\n\n        const isContentLength = !firstCrlfBufferEncountered;\n        if (isContentLength) {\n          // discard content length\n          return true;\n        }\n\n        // write chunk\n        chunkEncountered = true;\n        internalWritable.write(data, cb);\n        return true;\n      },\n    };\n\n    this.assignSocket(socket as unknown as Socket);\n  }\n}\n","/**\n * No operation function is used when we need to pass a function, but we don't want to specify any behavior.\n *\n * @breadcrumb Core\n * @public\n */\nexport const NO_OP: (...args: any[]) => any = () => void 0;\n","import { NO_OP } from './no-op';\n\n/**\n * The type representing the possible log levels to choose from.\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport type LogLevels =\n  | 'debug'\n  | 'verbose'\n  | 'info'\n  | 'warn'\n  | 'error'\n  | 'none';\n\n/**\n * The options to customize {@link ILogger}\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport type LoggerOptions = {\n  /**\n   * Select the log level, {@link LogLevels | see more}.\n   *\n   * @defaultValue error\n   */\n  level: LogLevels;\n};\n\n/**\n * The log function used in any level.\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport type LoggerFN = (message: any, ...additional: any[]) => void;\n\n/**\n * The interface representing the logger, you can provide a custom logger by implementing this interface.\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport type ILogger = Record<Exclude<LogLevels, 'none'>, LoggerFN>;\n\n/**\n * The symbol used to check against an ILogger instace to verify if that ILogger was created by this library\n *\n * @breadcrumb Core / Logger\n * @public\n */\nconst InternalLoggerSymbol = Symbol('InternalLogger');\n\nconst logLevels: Record<\n  LogLevels,\n  [level: LogLevels, consoleMethod: keyof Console][]\n> = {\n  debug: [\n    ['debug', 'debug'],\n    ['verbose', 'debug'],\n    ['info', 'info'],\n    ['error', 'error'],\n    ['warn', 'warn'],\n  ],\n  verbose: [\n    ['verbose', 'debug'],\n    ['info', 'info'],\n    ['error', 'error'],\n    ['warn', 'warn'],\n  ],\n  info: [\n    ['info', 'info'],\n    ['error', 'error'],\n    ['warn', 'warn'],\n  ],\n  warn: [\n    ['warn', 'warn'],\n    ['error', 'error'],\n  ],\n  error: [['error', 'error']],\n  none: [],\n};\n\nconst lazyPrint = (value: () => any | unknown) => {\n  if (typeof value === 'function') return value();\n\n  return value;\n};\n\nconst print =\n  (fn: string) =>\n  (message: any, ...additional: (() => any)[]) =>\n    console[fn](message, ...additional.map(lazyPrint));\n\n/**\n * The method used to create a simple logger instance to use in this library.\n *\n * @remarks Behind the scenes, this simple logger sends the message to the `console` methods.\n *\n * @example\n * ```typescript\n * const logger = createDefaultLogger();\n *\n * logger.error('An error happens.');\n * // An error happens.\n * ```\n *\n * @param level - Select the level of the log\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport function createDefaultLogger(\n  { level }: LoggerOptions = { level: 'error' },\n): ILogger {\n  const levels = logLevels[level];\n\n  if (!levels) throw new Error('Invalid log level');\n\n  const logger = {\n    [InternalLoggerSymbol]: true,\n    error: NO_OP,\n    debug: NO_OP,\n    info: NO_OP,\n    verbose: NO_OP,\n    warn: NO_OP,\n  } as ILogger;\n\n  for (const [level, consoleMethod] of levels)\n    logger[level] = print(consoleMethod);\n\n  return logger;\n}\n\n/**\n * The method used to chck if logger was created by this library, or it was defined by the user.\n *\n * @param logger - The instance of the logger to check\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport function isInternalLogger(logger: ILogger): boolean {\n  return !!logger[InternalLoggerSymbol];\n}\n","/**\n * Return the defaultValue whether the value is undefined, otherwise, return the value.\n *\n * @example\n * ```typescript\n * const value1 = getDefaultIfUndefined(undefined, true);\n * const value2 = getDefaultIfUndefined(false, true);\n *\n * console.log(value1);\n * // true\n * console.log(value2);\n * // false\n * ```\n *\n * @param value - The value to be checked\n * @param defaultValue - The default value when value is undefined\n *\n * @breadcrumb Core\n * @public\n */\nexport function getDefaultIfUndefined<T>(\n  value: T | undefined,\n  defaultValue: T,\n): T {\n  if (value === undefined) return defaultValue;\n\n  return value;\n}\n","//#region Imports\n\nimport { Readable, Writable } from 'node:stream';\n\n//#endregion\n\n/**\n * Check if stream already ended\n *\n * @param stream - The stream\n *\n * @breadcrumb Core / Stream\n * @public\n */\nexport function isStreamEnded(stream: Readable | Writable): boolean {\n  if ('readableEnded' in stream && stream.readableEnded) return true;\n\n  if ('writableEnded' in stream && stream.writableEnded) return true;\n\n  return false;\n}\n\n/**\n * Wait asynchronous the stream to complete\n *\n * @param stream - The stream\n *\n * @breadcrumb Core / Stream\n * @public\n */\nexport function waitForStreamComplete<TStream extends Readable | Writable>(\n  stream: TStream,\n): Promise<TStream> {\n  if (isStreamEnded(stream)) return Promise.resolve(stream);\n\n  return new Promise<TStream>((resolve, reject) => {\n    // Reading the {@link https://github.com/nodejs/node/blob/v12.22.9/lib/events.js#L262 | emit source code},\n    // it's almost impossible to complete being called twice because the emit function runs synchronously and removes the other listeners,\n    // but I'll leave it at that because I didn't write that code, so I couldn't figure out what the author thought when he wrote this.\n    let isComplete = false;\n\n    function complete(err: any) {\n      /* istanbul ignore next */\n      if (isComplete) return;\n\n      isComplete = true;\n\n      stream.removeListener('error', complete);\n      stream.removeListener('end', complete);\n      stream.removeListener('finish', complete);\n\n      if (err) reject(err);\n      else resolve(stream);\n    }\n\n    stream.once('error', complete);\n    stream.once('end', complete);\n    stream.once('finish', complete);\n  });\n}\n","//#region Imports\n\nimport type { IncomingMessage, ServerResponse } from 'http';\nimport type { NextHandleFunction } from 'connect';\nimport type { HttpError } from 'http-errors';\nimport type { FrameworkContract } from '../../contracts';\nimport { getDefaultIfUndefined } from '../../core';\n\n//#endregion\n\n/**\n * The options for {@link BaseBodyParserFramework}\n *\n * @breadcrumb Frameworks / BodyParserFramework\n * @public\n */\nexport type BodyParserOptions = {\n  /**\n   * Implements a custom way of handling error.\n   *\n   * @defaultValue {@link BaseBodyParserFramework.defaultHandleOnError}\n   *\n   * @example\n   * ```typescript\n   * customErrorHandler: (req: IncomingMessage, response: ServerResponse, error: HttpError<any>) => {\n   *   response.setHeader('content-type', 'text/plain');\n   *   response.statusCode = error.statusCode;\n   *   // always call end to return the error\n   *   response.end(error.message);\n   * }\n   * ```\n   *\n   * @param request - The referecene for request\n   * @param response - The reference for response\n   * @param error - The error throwed by body-parser\n   */\n  customErrorHandler?: (\n    request: IncomingMessage,\n    response: ServerResponse,\n    error: HttpError<any>,\n  ) => void;\n};\n\n/**\n * The base class used by other body-parser functions to parse a specific content-type\n *\n * @breadcrumb Frameworks / BodyParserFramework\n * @public\n */\nexport class BaseBodyParserFramework<TApp> implements FrameworkContract<TApp> {\n  //#region Constructor\n\n  /**\n   * Default Constructor\n   */\n  protected constructor(\n    protected readonly framework: FrameworkContract<TApp>,\n    protected readonly middleware: NextHandleFunction,\n    protected readonly options?: BodyParserOptions,\n  ) {\n    this.errorHandler = getDefaultIfUndefined(\n      this.options?.customErrorHandler,\n      this.defaultHandleOnError.bind(this),\n    );\n  }\n\n  //#endregion\n\n  //#region Protected Properties\n\n  /**\n   * The selected error handler\n   */\n  protected readonly errorHandler: NonNullable<\n    BodyParserOptions['customErrorHandler']\n  >;\n\n  //#endregion\n\n  //#region Public Methods\n\n  /**\n   * {@inheritDoc}\n   */\n  public sendRequest(\n    app: TApp,\n    request: IncomingMessage,\n    response: ServerResponse,\n  ): void {\n    this.middleware(\n      request,\n      response,\n      this.onBodyParserFinished(app, request, response),\n    );\n  }\n\n  //#endregion\n\n  //#region Protected Methods\n\n  /**\n   * Handle next execution called by the cors package\n   */\n  protected onBodyParserFinished(\n    app: TApp,\n    request: IncomingMessage,\n    response: ServerResponse,\n  ): () => void {\n    return (err?: any) => {\n      if (err) return this.errorHandler(request, response, err);\n\n      this.framework.sendRequest(app, request, response);\n    };\n  }\n\n  /**\n   * The default function to handle errors\n   *\n   * @param _request - The referecene for request\n   * @param response - The reference for response\n   * @param error - The error throwed by body-parser\n   */\n  protected defaultHandleOnError(\n    _request: IncomingMessage,\n    response: ServerResponse,\n    error: HttpError<any>,\n  ): void {\n    response.setHeader('content-type', 'text/plain');\n    response.statusCode = error.statusCode;\n    response.end(error.message);\n  }\n\n  //#endregion\n}\n","//#region Imports\n\nimport { type OptionsJson, json } from 'body-parser';\nimport { type FrameworkContract } from '../../contracts';\nimport {\n  BaseBodyParserFramework,\n  type BodyParserOptions,\n} from './base-body-parser.framework';\n\n//#endregion\n\n/**\n * The body-parser options for application/json\n *\n * @remarks {@link https://github.com/expressjs/body-parser#bodyparserjsonoptions}\n *\n * @breadcrumb Frameworks / BodyParserFramework / JsonBodyParserFramework\n * @public\n */\nexport type JsonBodyParserFrameworkOptions = OptionsJson & BodyParserOptions;\n\n/**\n * The body-parser class used to parse application/json.\n *\n * @breadcrumb Frameworks / BodyParserFramework / JsonBodyParserFramework\n * @public\n */\nexport class JsonBodyParserFramework<TApp>\n  extends BaseBodyParserFramework<TApp>\n  implements FrameworkContract<TApp>\n{\n  //#region Constructor\n\n  /**\n   * Default Constructor\n   */\n  constructor(\n    framework: FrameworkContract<TApp>,\n    options?: JsonBodyParserFrameworkOptions,\n  ) {\n    super(framework, json(options), options);\n  }\n\n  //#endregion\n}\n","//#region Imports\n\nimport { type Options, raw } from 'body-parser';\nimport type { FrameworkContract } from '../../contracts';\nimport {\n  BaseBodyParserFramework,\n  type BodyParserOptions,\n} from './base-body-parser.framework';\n\n//#endregion\n\n/**\n * The body-parser options for application/octet-stream\n *\n * @remarks {@link https://github.com/expressjs/body-parser#bodyparserrawoptions}\n *\n * @breadcrumb Frameworks / BodyParserFramework / RawBodyParserFramework\n * @public\n */\nexport type RawBodyParserFrameworkOptions = Options & BodyParserOptions;\n\n/**\n * The body-parser class used to parse application/octet-stream.\n *\n * @breadcrumb Frameworks / BodyParserFramework / RawBodyParserFramework\n * @public\n */\nexport class RawBodyParserFramework<TApp>\n  extends BaseBodyParserFramework<TApp>\n  implements FrameworkContract<TApp>\n{\n  //#region Constructor\n\n  /**\n   * Default Constructor\n   */\n  constructor(\n    framework: FrameworkContract<TApp>,\n    options?: RawBodyParserFrameworkOptions,\n  ) {\n    super(framework, raw(options), options);\n  }\n\n  //#endregion\n}\n","//#region Imports\n\nimport { type OptionsText, text } from 'body-parser';\nimport type { FrameworkContract } from '../../contracts';\nimport {\n  BaseBodyParserFramework,\n  type BodyParserOptions,\n} from './base-body-parser.framework';\n\n//#endregion\n\n/**\n * The body-parser options for text/plain\n *\n * @remarks {@link https://github.com/expressjs/body-parser#bodyparsertextoptions}\n *\n * @breadcrumb Frameworks / BodyParserFramework / TextBodyParserFramework\n * @public\n */\nexport type TextBodyParserFrameworkOptions = OptionsText & BodyParserOptions;\n\n/**\n * The body-parser class used to parse text/plain.\n *\n * @breadcrumb Frameworks / BodyParserFramework / TextBodyParserFramework\n * @public\n */\nexport class TextBodyParserFramework<TApp>\n  extends BaseBodyParserFramework<TApp>\n  implements FrameworkContract<TApp>\n{\n  //#region Constructor\n\n  /**\n   * Default Constructor\n   */\n  constructor(\n    framework: FrameworkContract<TApp>,\n    options?: TextBodyParserFrameworkOptions,\n  ) {\n    super(framework, text(options), options);\n  }\n\n  //#endregion\n}\n","//#region Imports\n\nimport { type OptionsUrlencoded, urlencoded } from 'body-parser';\nimport { type FrameworkContract } from '../../contracts';\nimport {\n  BaseBodyParserFramework,\n  type BodyParserOptions,\n} from './base-body-parser.framework';\n\n//#endregion\n\n/**\n * The body parser options for application/x-www-form-urlencoded\n *\n * @remarks {@link https://github.com/expressjs/body-parser#bodyparserurlencodedoptions}\n *\n * @breadcrumb Frameworks / BodyParserFramework / UrlencodedBodyParserFramework\n * @public\n */\nexport type UrlencodedBodyParserFrameworkOptions = OptionsUrlencoded &\n  BodyParserOptions;\n\n/**\n * The body-parser class used to parse application/x-www-form-urlencoded.\n *\n * @breadcrumb Frameworks / BodyParserFramework / UrlencodedBodyParserFramework\n * @public\n */\nexport class UrlencodedBodyParserFramework<TApp>\n  extends BaseBodyParserFramework<TApp>\n  implements FrameworkContract<TApp>\n{\n  //#region Constructor\n\n  /**\n   * Default Constructor\n   */\n  constructor(\n    framework: FrameworkContract<TApp>,\n    options?: UrlencodedBodyParserFrameworkOptions,\n  ) {\n    super(framework, urlencoded(options), options);\n  }\n\n  //#endregion\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,EAAA,4BAAAC,EAAA,2BAAAC,EAAA,4BAAAC,EAAA,kCAAAC,IAAA,eAAAC,EAAAP,GCCA,IAAAQ,EAAgC,gBCAhC,IAAAC,EAAgD,gBCKzC,SAASC,EAAUC,EAAiC,CACzD,GAAI,OAAO,SAASA,CAAI,EAAG,OAAOA,EAAK,SAAS,MAAM,EACjD,GAAI,OAAOA,GAAS,SAAU,OAAOA,EACrC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,+BAME,YACEC,EACAC,EACA,CACA,MAAMD,KAAW,OAAIC,CAAO,EAAGA,CAAO,CACxC,CAGF,EC1CA,IAAAC,EAAuC,uBAyBhC,IAAMC,EAAN,cACGC,CAEV,CA9BA,MA8BA,CAAAC,EAAA,gCAME,YACEC,EACAC,EACA,CACA,MAAMD,KAAW,QAAKC,CAAO,EAAGA,CAAO,CACzC,CAGF,EC1CA,IAAAC,EAAmD,uBA0B5C,IAAMC,EAAN,cACGC,CAEV,CA/BA,MA+BA,CAAAC,EAAA,sCAME,YACEC,EACAC,EACA,CACA,MAAMD,KAAW,cAAWC,CAAO,EAAGA,CAAO,CAC/C,CAGF","names":["body_parser_exports","__export","BaseBodyParserFramework","JsonBodyParserFramework","RawBodyParserFramework","TextBodyParserFramework","UrlencodedBodyParserFramework","__toCommonJS","import_node_http","import_node_http","getString","data","__name","headerEnd","endChunked","BODY","HEADERS","addData","stream","data","__name","ServerlessResponse","_ServerlessResponse","method","writesToIgnore","socket","NO_OP","encoding","cb","string","getString","index","remainder","res","response","headers","key","value","statusCode","statusMessage","obj","headersObjOrArray","arrayHeaders","name","import_node_http","crlfBuffer","NO_OP","__name","InternalLoggerSymbol","getDefaultIfUndefined","value","defaultValue","__name","import_node_stream","BaseBodyParserFramework","framework","middleware","options","getDefaultIfUndefined","__name","app","request","response","err","_request","error","import_body_parser","JsonBodyParserFramework","BaseBodyParserFramework","__name","framework","options","import_body_parser","RawBodyParserFramework","BaseBodyParserFramework","__name","framework","options","import_body_parser","TextBodyParserFramework","BaseBodyParserFramework","__name","framework","options","import_body_parser","UrlencodedBodyParserFramework","BaseBodyParserFramework","__name","framework","options"]}