JSPM

express-trim-strings

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q12047F
  • License ISC

Trim Strings of Request Body and Query

Package Exports

  • express-trim-strings
  • express-trim-strings/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (express-trim-strings) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Express Trim Strings Middleware

Trim whitespace from request body.

Features

  • Trim whitespace from request body of json data.
  • Support for nested objects.
  • Support for arrays.
  • Support for routing-controller.
  • Support for TypeScript.
  • Support for query parameters.
  • Support for form data.

Installation

npm install express-trim-strings

Usage

JavaScript

const express = require('express');
const trim = require('express-trim-strings');

const app = express();

app.use(trim.trimStrings);

app.post('/test', (req, res) => {
  res.send(req.body);
});

app.listen(3000, () => {
  console.log('Server is running on port 3000');
});

TypeScript

import express from 'express';
import { trimStrings } from 'express-trim-strings';

const app = express();

app.use(trimStrings);

app.post('/test', (req, res) => {
  res.send(req.body);
});

app.listen(3000, () => {
  console.log('Server is running on port 3000');
});

with routing-controller

import 'reflect-metadata';
import { createExpressServer, useExpressServer } from 'routing-controllers';
import { TrimStringsMiddleware } from 'express-trim-strings';

const app = createExpressServer({
  middlewares: [TrimStringsMiddleware],
  controllers: [__dirname + '/controllers/*.ts']
});

app.listen(3000, () => {
  console.log('Server is running on port 3000');
});

License

ISC