Home / File/ express.text.js — express Source File

express.text.js — express Source File

Architecture documentation for express.text.js, a javascript file in the express codebase.

Entity Profile

Relationship Graph

Source Code

'use strict'

var assert = require('node:assert')
var AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage
const { Buffer } = require('node:buffer');
var express = require('..')
var request = require('supertest')

describe('express.text()', function () {
  before(function () {
    this.app = createApp()
  })

  it('should parse text/plain', function (done) {
    request(this.app)
      .post('/')
      .set('Content-Type', 'text/plain')
      .send('user is tobi')
      .expect(200, '"user is tobi"', done)
  })

  it('should 400 when invalid content-length', function (done) {
    var app = express()

    app.use(function (req, res, next) {
      req.headers['content-length'] = '20' // bad length
      next()
    })

    app.use(express.text())

    app.post('/', function (req, res) {
      res.json(req.body)
    })

    request(app)
      .post('/')
      .set('Content-Type', 'text/plain')
      .send('user')
      .expect(400, /content length/, done)
  })

  it('should handle Content-Length: 0', function (done) {
    request(createApp({ limit: '1kb' }))
      .post('/')
      .set('Content-Type', 'text/plain')
      .set('Content-Length', '0')
      .expect(200, '""', done)
  })

  it('should handle empty message-body', function (done) {
    request(createApp({ limit: '1kb' }))
      .post('/')
      .set('Content-Type', 'text/plain')
      .set('Transfer-Encoding', 'chunked')
      .send('')
      .expect(200, '""', done)
  })

  it('should handle duplicated middleware', function (done) {
// ... (507 more lines)

Domain

Subdomains

Functions

Frequently Asked Questions

What does express.text.js do?
express.text.js is a source file in the express codebase, written in javascript. It belongs to the ExpressCore domain, ApplicationInit subdomain.
What functions are defined in express.text.js?
express.text.js defines 1 function(s): createApp.
Where is express.text.js in the architecture?
express.text.js is located at test/express.text.js (domain: ExpressCore, subdomain: ApplicationInit, directory: test).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free