Lightweight replacement to express.
slush = require "slush"
app = slush()
app.ready ->
console.log "Listening at http://localhost:" + app.port- sock: String? Listen on a socket path
- port: Number? If undefined, default to
process.env.PORT, or443(if HTTPS), or8000(if HTTP) - secure: Boolean? If true, an HTTPS server is created with
ssl.keyandssl.crtfrom the project root - maxHeaders: Number? Limit the number of headers (defaults to 50)
- timeout: Number? The timeout (in ms) before a request sends a 408 response
- onError: Function? Send a custom response when your server throws an unexpected error
- onUnhandled: Function? Send a custom response when a request goes unhandled
The slush server uses a pipeline of request handlers (called "pipes").
app.pipe (req, res) ->
# Handle the request in here.
# Calls to `pipe` can be chained.The return value of each pipe is used to determine the server's next action.
Return undefined or null to skip the rest of the current pipe.
Return a Number literal to set the status code for an empty response.
Return an Error instance for invalid requests.
Return a Promise instance for asynchronous requests.
The resolved value is treated the same as synchronous return values.
The server will visit each pipe in the pipeline until res.send is called.
If that never happens, the server responds with "404 Not Found".
If an Error instance is thrown while inside a pipe, the server responds with "500 Internal Error".
Support for express middleware is included.
app.use middlewareUse the drain() method for running code after the response is sent.
app.drain (req, res) ->
# The response has been sent.request: (req, res)A request was receivedresponse: (req, res)A response has finishedrequestError: (error)The request handler caught an error (not emitted whenoptions.onErroris defined)error: ()A server error occurred (see here)close: ()The server has closed, all connections have ended (see here)