slope

slope.js is a web server library written in Node.js that strives to be as feature-filled as it is easy-to-use.

View the Project on GitHub wibbuffey/slope

Classes

Client

Used as a parameter for function calls.

Config

Used internally as an object to store configuration.

Header

Class used internally as a list of headers.

Result

Class passed as the second parameter to route callbacks.

Routes

Object used internally as a list of routes.

Server

The object used to create a web server.

Client

Used as a parameter for function calls.

Kind: global class

Config

Used internally as an object to store configuration.

Kind: global class

Class used internally as a list of headers.

Kind: global class

Header.get(header) ⇒ String

Retrieves a header from the object.

Kind: static method of Header
Returns: String - The value of the header.

Param Type Description
header String The header’s name.

Header.set(header, value)

Adds or replaces a header in the object.

Kind: static method of Header

Param Type Description
header String The header’s name.
value String The value the header will be set to.

Header.remove(header)

Removes a header from the object.

Kind: static method of Header

Param Type Description
header String The header’s name.

Result

Class passed as the second parameter to route callbacks.

Kind: global class

Result.send(content, [headers])

Sends text with provided headers and ends the response.

Kind: static method of Result

Param Type Default Description
content String   Content to write/return.
[headers] Object {"Content-Type": "text/html"} Headers to send.

Result.write(content)

Sends text WITHOUT headers and DOES NOT end the response.

Kind: static method of Result

Param Type Description
content String Content to write.

Result.end([content])

Ends the response (with an optional message).

Kind: static method of Result

Param Type Default Description
[content] String "" Content to write/return.

Result.head(status, [headers])

Sets status and headers.

Kind: static method of Result

Param Type Default Description
status Number   Status code to return.
[headers] Object {"Content-Type": "text/html"} Headers to send.

Routes

Object used internally as a list of routes.

Kind: global class

Routes.add(name, callback)

Assigns a function to a URL.

Kind: static method of Routes

Param Type Description
name String | RegExp The URL/RegExp to bind the function to, or “*” as a fallback.
callback function What to call when the page is visited.

Routes.remove(name)

Removes a URL from the database of routes.

Kind: static method of Routes

Param Type Description
name String | RegExp The URL to remove from the database.

Server

The object used to create a web server.

Kind: global class

Server.run()

Run the web server.

Kind: static method of Server