DefinitelyTyped/express/express-tests.ts
Ole Rehmsen 469065e77d Import type definitions for express.static from serve-static instead of only supporting the call signature.
Express exposes serve-static as express.static: https://github.com/strongloop/express/blob/master/lib/express.js#L60
Prior to this change, the type definitions would only consist of the call signature of serve-static, but serve static also has member variables. By importing the entire type definition from serve-static and using it for express.static, both the call signature and the members can be used.
2015-06-18 19:19:53 +02:00

40 lines
854 B
TypeScript

/// <reference path="express.d.ts" />
import express = require('express');
var app = express();
app.engine('jade', require('jade').__express);
app.engine('html', require('ejs').renderFile);
express.static.mime.define({
'application/fx': ['fx']
});
app.use('/static', express.static(__dirname + '/public'));
// simple logger
app.use(function(req, res, next){
console.log('%s %s', req.method, req.url);
next();
});
app.get('/', function(req, res){
res.send('hello world');
});
var router = express.Router();
router.use((req, res, next) => { next(); })
router.route('/users')
.get((req, res, next) => {
res.send(req.query['token']);
});
app.use((req, res, next) => {
// hacky trick, router is just a handler
router(req, res, next);
});
app.use(router);
app.listen(3000);