mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* 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
32 lines
817 B
TypeScript
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);
|
|
}
|