mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-10 11:40:16 +08:00
Add tests for connect typings
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/// <reference path="./connect.d.ts" />
|
||||
|
||||
import * as http from "http";
|
||||
import * as connect from "connect";
|
||||
|
||||
const app = connect();
|
||||
|
||||
// log all requests
|
||||
app.use((req, res, next) => {
|
||||
console.log(req, res);
|
||||
next();
|
||||
});
|
||||
|
||||
// Stop on errors
|
||||
app.use((err, req, res, next) => {
|
||||
if (err) {
|
||||
return res.end(`Error: ${err}`);
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
// respond to all requests
|
||||
app.use((req, res) => {
|
||||
res.end("Hello from Connect!\n");
|
||||
});
|
||||
|
||||
//create node.js http server and listen on port
|
||||
http.createServer(app).listen(3000);
|
||||
|
||||
//create node.js http server and listen on port using connect shortcut
|
||||
app.listen(3000);
|
||||
Reference in New Issue
Block a user