-
Notifications
You must be signed in to change notification settings - Fork 21
Home
Welcome to the turtle.io wiki!
turtle.io is an easy to use web server for a node.js environment. Why have a complicated stack if you can have a super fast, async web server?
Virtual host keys are the hostname, and the value is the directory relative to "root". You must set the default value, otherwise turtle.io will not be able to handle all routes.
var turtle = require("turtle.io"),
config, server;
config = {
default : "mycompany.com",
uid : 100,
port : 80,
root : "/var/www",
pages : "custom",
vhosts : {
"mycompany.com" : "mycompany.com",
"www.mycompany.com" : "mycompany.com",
"blog.mycompany.com" : "blog.mycompany.com"
}
}
server = new turtle();
server.start(config);The /api route acts as a proxy to another service. This example also utilizes a config.json file local to the server script, for easy DevOps management.
var config = require("./config.json"),
turtle_io = require("turtle.io"),
server = new turtle_io();
// Setting proxy routes
server.proxy("/github", "https://api.github.com"[, "hostname"]);
server.start(config);The request object which is passed to every route handler as the second argument, will have a body property with the payload from the Client. It will not be coerced to another format, so if you expect JSON, you'll have to JSON.parse() it yourself (for now). This only applies to PATCH, POST, & PUT requests.
Configuration values can be set by editing config.json in the turtle.io directory, or by passing an Object to start().
Number (1000)
Size of LRU cache for Etag validation.
String
[Required] Default hostname to handle requests which are not specified within vhosts; must be a valid entry within vhosts.
Object
Response headers. CORS is enabled by default.
Array
Files to look for when accessing a directory resource.
Number (70)
Milliseconds to configure toobusy.maxLag().
Object
Logging configuration.
String (%v %h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i")
Common Log Format string of tokens, defaulting to standard Virtual Host format.
String ("info")
Minimum Common Log Level which is emitted to stdout.
Boolean (true)
Override & disable stdout emitting by setting to false.
Boolean (true)
Override & disable syslog emitting by setting to false.
String (D/MMM/YYYY:HH:mm:ss ZZ)
Format for the date/time portion of a log message.
String (null)
Directory relative to root which has files named for HTTP status codes, to be served upon error, e.g. 404.htm.
Number (8000)
Port the server will listen on.
Object
Proxy configuration.
Array
Content-Type header values to apply URL rewrites to.
String (./sites)
Relative path to the web root directory.
Object
[Optional] SSL certificate
Object
[Optional] SSL certificate key/pem
Number (null)
[Optional] UID the server runs as.
Object
[Required] Virtual hosts the server will respond for, key is the hostname & value is the directory relative to root.
Please visit api.turtle.io
Copyright (c) 2013 Jason Mulligan
Licensed under the BSD-3 license.