DefinitelyTyped/connect-timeout/connect-timeout-tests.ts
Cyril Schumacher 36e064e2cb Fix error for "connect-timeout".
Add module to extend interface for "i18next".
Add default export for "express-brute-memcached".
Remove unnecessary interface for "i18next-express-middleware".
Add definitions for "i18next-browser-languagedetector" and "i18next-node-fs-backend".
2016-02-29 18:33:35 +01:00

29 lines
872 B
TypeScript

/// <reference path="connect-timeout.d.ts" />
/// <reference path="../body-parser/body-parser.d.ts" />
/// <reference path="../cookie-parser/cookie-parser.d.ts" />
/// <reference path="../express/express.d.ts" />
import * as express from "express";
import * as timeout from "connect-timeout";
import * as bodyParser from "body-parser";
import * as cookieParser from "cookie-parser";
// example of using this top-level; note the use of haltOnTimedout
// after every middleware; it will stop the request flow on a timeout
var app = express();
app.use(timeout("5s", { respond: false }));
app.use(bodyParser());
app.use(haltOnTimedout);
app.use(cookieParser());
app.use(haltOnTimedout);
// Add your routes here, etc.
function haltOnTimedout(req: express.Request, res: express.Response, next: Function) {
if (!req.timedout) {
next();
}
}
app.listen(3000);