0.1.0 • Published 9 months ago
express-trim-strings v0.1.0
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
0.1.0
9 months ago