DefinitelyTyped/types/sticky-session/sticky-session-tests.ts
vanny96 6c0f853713 Add sticky-session to types (#40704)
* Add sticky session typing

* Add sticky-session to types

* Solve package json issue and updated the project to latest commit

* Added readonly to options, optional where required and added env option

* Remove unused import
2019-12-10 11:11:02 -05:00

32 lines
817 B
TypeScript

import sticky = require('sticky-session');
import http = require('http');
const server = http.createServer();
// Test with all parameters
if (!sticky.listen(server, 3000, { workers: 2 })) {
server.once('listening', () => {
console.log("Server listening on port X");
});
} else {
console.log("Worker listening on process: " + process.pid);
}
// Test without options
if (!sticky.listen(server, 3000)) {
server.once('listening', () => {
console.log("Server listening on port X");
});
} else {
console.log("Worker listening on process: " + process.pid);
}
// Port is optional
if (!sticky.listen(server)) {
server.once('listening', () => {
console.log("Server listening on port X");
});
} else {
console.log("Worker listening on process: " + process.pid);
}