mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
35 lines
911 B
TypeScript
35 lines
911 B
TypeScript
import express = require('express');
|
|
import send = require('send');
|
|
|
|
var app = express();
|
|
|
|
send.mime.define({
|
|
'application/x-my-type': ['x-mt', 'x-mtt']
|
|
});
|
|
|
|
app.get('/test.html', (req, res) => {
|
|
send(req, '/test.html', {
|
|
maxAge: 0,
|
|
root: __dirname + '/wwwroot'
|
|
}).pipe(res);
|
|
});
|
|
|
|
app.get('/test.html', (req, res) => {
|
|
send(req, '/test.html')
|
|
.maxage(0)
|
|
.root(__dirname + '/wwwroot')
|
|
.on('error', (err: any) => {
|
|
res.statusCode = err.status || 500;
|
|
res.end(err.message);
|
|
})
|
|
.on('directory', () => {
|
|
res.statusCode = 301;
|
|
res.setHeader('Location', req.url + '/');
|
|
res.end('Redirecting to ' + req.url + '/');
|
|
})
|
|
.on('headers', (res: any, path: string, stat: any) => {
|
|
res.setHeader('Content-Disposition', 'attachment');
|
|
})
|
|
.pipe(res);
|
|
});
|