mirror of
https://github.com/zhigang1992/deployd.git
synced 2026-05-22 20:37:59 +08:00
doc updates
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
# Collection Resource
|
||||
|
||||
A Collection resource allows your app to save and load data in a simple schema.
|
||||
A Collection resource allows client apps to save and query data.
|
||||
|
||||
## Setting up a collection
|
||||
|
||||
After creating a Collection resource in the dashboard, you can set up the schema by dragging properties into the database and naming them.
|
||||
After creating a Collection resource in the dashboard, you can set up the schema that will automatically validate data sent to the resource url over HTTP. You can configure this schema in the dashboard.
|
||||
|
||||
The grid view below the property list allows you to edit the Collection manually.
|
||||
|
||||
@@ -19,7 +19,7 @@ You can currently use the following property types:
|
||||
|
||||
## Formats
|
||||
|
||||
You must format the request body as a JSON string and pass the header "Content-Type: application/json".
|
||||
When POSTing or PUTing data to a resource `/path`, you must format the request body as a JSON string and pass the header "Content-Type: application/json".
|
||||
|
||||
## Saving data
|
||||
|
||||
|
||||
@@ -14,47 +14,52 @@
|
||||
</div><!--/span-->
|
||||
<div id="side">
|
||||
<div class="well sidebar-nav">
|
||||
<h4 style="margin-left: 17px; margin-bottom: 10px;">Deployd</h4>
|
||||
<ul class="nav nav-list">
|
||||
|
||||
|
||||
</ul>
|
||||
</div><!--/.well -->
|
||||
</div><!-- /#side -->
|
||||
<div class="span9" style="max-width: 1000px;"><div id="index">
|
||||
<div class="hero-unit">
|
||||
<h1>Deployd</h1>
|
||||
<p>A modern web server for front-end developers.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span9" style="max-width: 1000px;"><h1>Deployd</h1>
|
||||
|
||||
<h2>Basics</h2>
|
||||
<p><strong><em>Deployd</strong> 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.</em></p>
|
||||
|
||||
<p>Deployd is a web server built on resources, in the style of REST. In the dashboard, you can build your app by creating resources and configuring them to work the way the want.</p>
|
||||
<p>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.</p>
|
||||
|
||||
<h2>Routing</h2>
|
||||
<h2>Quick start</h2>
|
||||
|
||||
<p>When Deployd receives an HTTP request, it checks the first part of the URL to see which resource should handle the request:</p>
|
||||
<p>To install deployd locally you must have <code>npm</code> and a running instance of mongodb.</p>
|
||||
|
||||
<pre><code>[sudo] npm install deployd -g
|
||||
</code></pre>
|
||||
|
||||
<p>First you'll want to generate an authentication key.</p>
|
||||
|
||||
<pre><code>dpd key
|
||||
</code></pre>
|
||||
|
||||
<p>Copy the key for use in the dashboard. Then start the server.</p>
|
||||
|
||||
<pre><code>dpd listen
|
||||
</code></pre>
|
||||
|
||||
<p>You can view the dashboard at <code>http://localhost:2403/__dashboard/</code>. It will prompt you for your auth key.</p>
|
||||
|
||||
<h2>How does it work?</h2>
|
||||
|
||||
<h3>Resources</h3>
|
||||
|
||||
<p>When deployd receives an HTTP request, it checks the first part of the URL to see which resource should handle the request:</p>
|
||||
|
||||
<ul>
|
||||
<li><strong>/todos</strong>/12345 - handled by the <strong>/todos</strong> resource</li>
|
||||
<li><strong>/admin</strong>/users/12345 - handled by the <strong>/admin</strong> resource, if it exists (you cannot create multi-part resource names)</li>
|
||||
<li><strong>/img</strong>/bg.jpg - handled by the <strong>/img</strong> resource</li>
|
||||
<li><strong>/</strong>index.html - handled by the <strong>/</strong> resource</li>
|
||||
</ul>
|
||||
|
||||
<h2>Reserved resource names</h2>
|
||||
<p>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.</p>
|
||||
|
||||
<p>Certain resource paths are used internally by Deployd. You should not create resources with these names:</p>
|
||||
|
||||
<ul>
|
||||
<li>/keys</li>
|
||||
<li>/types</li>
|
||||
<li>/resources</li>
|
||||
<li>/sessions</li>
|
||||
<li>/property-types</li>
|
||||
<li>/__dashboard</li>
|
||||
</ul>
|
||||
|
||||
<h2>REST</h2>
|
||||
<h2>REST API</h2>
|
||||
|
||||
<p>REST is a web service design pattern that conforms closely to HTTP itself. In Deployd, HTTP methods or verbs have meaning:</p>
|
||||
|
||||
@@ -79,13 +84,15 @@
|
||||
<h2>Cross-Origin AJAX</h2>
|
||||
|
||||
<p>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.</p>
|
||||
|
||||
<hr />
|
||||
<h1>Collection Resource</h1>
|
||||
|
||||
<p>A Collection resource allows your app to save and load data in a simple schema.</p>
|
||||
<p>A Collection resource allows client apps to save and query data.</p>
|
||||
|
||||
<h2>Setting up a collection</h2>
|
||||
|
||||
<p>After creating a Collection resource in the dashboard, you can set up the schema by dragging properties into the database and naming them. </p>
|
||||
<p>After creating a Collection resource in the dashboard, you can set up the schema that will automatically validate data sent to the resource url over HTTP. You can configure this schema in the dashboard.</p>
|
||||
|
||||
<p>The grid view below the property list allows you to edit the Collection manually.</p>
|
||||
|
||||
@@ -102,7 +109,7 @@
|
||||
|
||||
<h2>Formats</h2>
|
||||
|
||||
<p>You must format the request body as a JSON string and pass the header "Content-Type: application/json".</p>
|
||||
<p>When POSTing or PUTing data to a resource <code>/path</code>, you must format the request body as a JSON string and pass the header "Content-Type: application/json".</p>
|
||||
|
||||
<h2>Saving data</h2>
|
||||
|
||||
@@ -376,7 +383,7 @@ protect('createdDate');
|
||||
<p>First create a user by POSTing it to the root of the collection.
|
||||
For this example our collection will be called <code>/users</code>.</p>
|
||||
|
||||
<pre><code>POST /users/login
|
||||
<pre><code>POST /users
|
||||
Content-Type: application/json
|
||||
{
|
||||
"email": "foo@bar.com",
|
||||
|
||||
@@ -1,41 +1,38 @@
|
||||
<div id="index">
|
||||
<div class="hero-unit">
|
||||
<h1>Deployd</h1>
|
||||
<p>A modern web server for front-end developers.</p>
|
||||
</div>
|
||||
</div>
|
||||
# Deployd
|
||||
|
||||
Basics
|
||||
------
|
||||
***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.*
|
||||
|
||||
Deployd is a web server built on resources, in the style of REST. In the dashboard, you can build your app by creating resources and configuring them to work the way the want.
|
||||
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.
|
||||
|
||||
## Quick start
|
||||
|
||||
Routing
|
||||
-------
|
||||
To install deployd locally you must have `npm` and a running instance of mongodb.
|
||||
|
||||
When Deployd receives an HTTP request, it checks the first part of the URL to see which resource should handle the request:
|
||||
[sudo] npm install deployd -g
|
||||
|
||||
First you'll want to generate an authentication key.
|
||||
|
||||
dpd key
|
||||
|
||||
Copy the key for use in the dashboard. Then start the server.
|
||||
|
||||
dpd listen
|
||||
|
||||
You can view the dashboard at `http://localhost:2403/__dashboard/`. It will prompt you for your auth key.
|
||||
|
||||
## 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
|
||||
* **/admin**/users/12345 - handled by the **/admin** resource, if it exists (you cannot create multi-part resource names)
|
||||
* **/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.
|
||||
|
||||
Reserved resource names
|
||||
-----------------------
|
||||
|
||||
Certain resource paths are used internally by Deployd. You should not create resources with these names:
|
||||
|
||||
* /keys
|
||||
* /types
|
||||
* /resources
|
||||
* /sessions
|
||||
* /property-types
|
||||
* /__dashboard
|
||||
|
||||
REST
|
||||
----
|
||||
## REST API
|
||||
|
||||
REST is a web service design pattern that conforms closely to HTTP itself. In Deployd, HTTP methods or verbs have meaning:
|
||||
|
||||
@@ -53,7 +50,8 @@ In Deployd, HTTP response codes are also important:
|
||||
* **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
|
||||
-----------------
|
||||
## 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.
|
||||
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.
|
||||
|
||||
<hr />
|
||||
@@ -14,8 +14,9 @@
|
||||
</div><!--/span-->
|
||||
<div id="side">
|
||||
<div class="well sidebar-nav">
|
||||
<h4 style="margin-left: 17px; margin-bottom: 10px;">Deployd</h4>
|
||||
<ul class="nav nav-list">
|
||||
|
||||
|
||||
</ul>
|
||||
</div><!--/.well -->
|
||||
</div><!-- /#side -->
|
||||
|
||||
Reference in New Issue
Block a user