Files
deployd/docs/index.markdown
Ritchie Martori d2dbb55316 docs
2012-05-10 13:42:25 -07:00

3.3 KiB

Deployd

Deployd lets you quickly build secure, dynamic JavaScript and Mobile apps without writing backend code. Instead you boot a simple server that is very good at securely proxying requests to a storage layer such as a database. This enables your un-trusted client code to do things it never could before, such as write directly to a database without a custom application running in-between.

Instead of reinventing a protocol, deployd embraces HTTP. This means that any HTTP client, such as a JavaScript app, a mobile app, or even another server, can securely interact with your data without having to setup a web server and write a custom backend.

Dependencies

Currently deployd requires mongodb to be installed. You can download it here.

Deployd also requires node.js >= v0.6.0. You can download it here.

Quick start

Install deployd from npm (requires [nodejs(http://www.mongodb.org/downloads), mongodb).

$ [sudo] npm install deployd -g

Create an index.html file in a new directory.

$ cat >> index.html
hello world!
^C

Run deployd from the directory where you want to server your files.

$ dpd -d

This will open up the dashboard where you can manage your deployd server.

See dpd -h for more info on how to use the command line interface.

How does it work?

Resources

When deployd receives an HTTP request, it checks the first part of the URL to see which resource should handle the request:

  • /todos/12345 - handled by the /todos resource
  • /img/bg.jpg - handled by the /img resource
  • **/**index.html - handled by the / resource

Once deployd knows what resource is being requested, it will validate the input, execute any event handlers you have defined and either return or store the result. You can create and configure resources and event handlers in the dashboard.

REST API

REST is a web service design pattern that conforms closely to HTTP itself. In Deployd, HTTP methods or verbs have meaning:

  • GET - Load a resource without modifying it (this is a browser's default method)
  • POST - Create a resource, or send data to a special that doesn't fit within these methods
  • PUT - Update an existing resource
  • DELETE - Destroy an existing resource

In Deployd, HTTP response codes are also important:

  • 200 OK - The request succeeded
  • 204 No Content - The request succeeded, but there is no content to return (for example, after a deletion, or requesting an empty list)
  • 400 Bad Request - The request did not pass validation. Change the parameters and try again.
  • 401 Unauthorized - The request's session does not have permission to access that resource.
  • 404 Not Found - That URL does not reference an existing resource
  • 500 Internal Server Error - Deployd has failed to process the request due to an unexpected error.

Cross-Origin AJAX

Deployd is configured so that you can easily develop a web app locally on your computer. It will send Access-Control-Allow-Origin HTTP headers if a request is coming from localhost or your filesystem, which will allow modern web browsers to use AJAX normally. It will not send these headers for any other domain.