mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add type definitions for the connect-slashes middleware
This commit is contained in:
parent
e57df787f4
commit
266fc895f8
53
connect-slashes/connect-slashes-tests.ts
Normal file
53
connect-slashes/connect-slashes-tests.ts
Normal file
@ -0,0 +1,53 @@
|
||||
/// <reference path="../express/express.d.ts"/>
|
||||
|
||||
import express = require('express');
|
||||
import slashes = require('connect-slashes');
|
||||
|
||||
var app = express();
|
||||
|
||||
// Using default settings...
|
||||
app.use(slashes());
|
||||
|
||||
|
||||
// Remove slashes instead of adding them...
|
||||
app.use(slashes(false));
|
||||
|
||||
|
||||
// With additional options defined inline...
|
||||
app.use(slashes(true, {
|
||||
base: '/blog',
|
||||
code: 302,
|
||||
headers: {
|
||||
'Cache-Control': 'public',
|
||||
'Accpet': 'application/json'
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
// Defining an options object and referencing
|
||||
// it in the constructor...
|
||||
var options: slashes.Options = {
|
||||
base: '/blog',
|
||||
code: 302,
|
||||
headers: {
|
||||
'Cache-Control': 'public',
|
||||
'Accpet': 'application/json'
|
||||
}
|
||||
};
|
||||
app.use(slashes(true, options));
|
||||
|
||||
|
||||
// Defining an options object with only
|
||||
// some properties...
|
||||
var options: slashes.Options = {
|
||||
base: '/blog'
|
||||
}
|
||||
var options: slashes.Options = {
|
||||
code: 302
|
||||
}
|
||||
var options: slashes.Options = {
|
||||
headers: {
|
||||
'Cache-Control': 'public',
|
||||
'Accpet': 'application/json'
|
||||
}
|
||||
}
|
||||
40
connect-slashes/connect-slashes.d.ts
vendored
Normal file
40
connect-slashes/connect-slashes.d.ts
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
// Type definitions for connect-slashes
|
||||
// Project: https://github.com/avinoamr/connect-slashes
|
||||
// Definitions by: Sam Herrmann <https://github.com/samherrmann>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/* =================== USAGE ===================
|
||||
|
||||
import express = require('express');
|
||||
import slashes = require('connect-slashes');
|
||||
|
||||
var app = express();
|
||||
app.use(slashes());
|
||||
=============================================== */
|
||||
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
|
||||
|
||||
declare module "connect-slashes" {
|
||||
import express = require('express');
|
||||
|
||||
/**
|
||||
* @see https://github.com/avinoamr/connect-slashes#usage
|
||||
*/
|
||||
function slashes (addTrailingSlashes?: boolean, options?: slashes.Options): express.RequestHandler;
|
||||
|
||||
module slashes {
|
||||
|
||||
/**
|
||||
* Additional settings
|
||||
* @see https://github.com/avinoamr/connect-slashes#additional-settings
|
||||
*/
|
||||
interface Options {
|
||||
base?: string;
|
||||
code?: number;
|
||||
headers?: {[field: string]: string};
|
||||
}
|
||||
}
|
||||
|
||||
export = slashes;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user