mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
Adding express-mongo-sanitize typings (#20463)
This commit is contained in:
committed by
Wesley Wigham
parent
a97f575766
commit
39a7427dee
@@ -0,0 +1,26 @@
|
||||
import * as express from 'express';
|
||||
import * as mongoSanitize from 'express-mongo-sanitize';
|
||||
|
||||
const app: express.Express = express();
|
||||
|
||||
app.use(mongoSanitize());
|
||||
|
||||
app.use(mongoSanitize({
|
||||
replaceWith: '_'
|
||||
}));
|
||||
|
||||
interface TestPayload {
|
||||
foo: string;
|
||||
}
|
||||
|
||||
const testPayload: TestPayload = {
|
||||
foo: 'bar'
|
||||
};
|
||||
|
||||
const sanitize1: TestPayload = mongoSanitize.sanitize(testPayload);
|
||||
|
||||
const sanitize2: TestPayload = mongoSanitize.sanitize(testPayload, {
|
||||
replaceWith: '_'
|
||||
});
|
||||
|
||||
const isCorrect: boolean = mongoSanitize.has(testPayload);
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// Type definitions for express-mongo-sanitize 1.3
|
||||
// Project: https://github.com/fiznool/express-mongo-sanitize#readme
|
||||
// Definitions by: Eric Byers <https://github.com/ericbyers>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import express = require('express');
|
||||
|
||||
interface MongoSanitizeOptions {
|
||||
replaceWith: any;
|
||||
}
|
||||
|
||||
declare namespace expressMongoSanitize {
|
||||
function sanitize<T>(payload: T, options?: MongoSanitizeOptions): T;
|
||||
function has(payload: any): boolean;
|
||||
}
|
||||
|
||||
declare function expressMongoSanitize(options?: MongoSanitizeOptions): (req: express.Request, res: express.Response, next: express.NextFunction) => void;
|
||||
|
||||
export = expressMongoSanitize;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"express-mongo-sanitize-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user