add examples
This commit is contained in:
parent
0696ba8084
commit
911c783c5e
106
README.md
106
README.md
|
@ -90,6 +90,40 @@ POST https://api.<domain.tld>/api/com.daplie.walnut.init
|
|||
{ "domain": "<domain.tld>" }
|
||||
```
|
||||
|
||||
The following domains are required to point to WALNUT server
|
||||
|
||||
```
|
||||
<domain.tld>
|
||||
www.<domain.tld>
|
||||
|
||||
api.<domain.tld>
|
||||
assets.<domain.tld>
|
||||
|
||||
cloud.<domain.tld>
|
||||
api.cloud.<domain.tld>
|
||||
```
|
||||
|
||||
Example `/etc/goldilocks/goldilocks.yml`:
|
||||
```yml
|
||||
tls:
|
||||
email: domains@example.com
|
||||
servernames:
|
||||
- example.com
|
||||
- www.example.com
|
||||
- api.example.com
|
||||
- assets.example.com
|
||||
- cloud.example.com
|
||||
- api.cloud.example.com
|
||||
|
||||
http:
|
||||
trust_proxy: true
|
||||
modules:
|
||||
- name: proxy
|
||||
domains:
|
||||
- '*'
|
||||
address: '127.0.0.1:3000'
|
||||
```
|
||||
|
||||
Resetting the Initialization
|
||||
----------------------------
|
||||
|
||||
|
@ -109,9 +143,75 @@ Static apps are stored in `packages/pages`
|
|||
|
||||
```
|
||||
# App ID as files with a list of packages they should load
|
||||
/srv/walnut/packages/pages/<domain.tld#path> # https://domain.tld/path
|
||||
/srv/walnut/packages/pages/<domain.tld> # https://domain.tld and https://domain.tld/foo match
|
||||
# note that '#' is used in place of '/' because files and folders may not contain '/' in their names
|
||||
/srv/walnut/packages/sites/<domain.tld#path> # https://domain.tld/path
|
||||
/srv/walnut/packages/sites/<domain.tld> # https://domain.tld and https://domain.tld/foo match
|
||||
|
||||
# packages are directories with reverse dns name # used for debugging
|
||||
# packages are directories with reverse dns name # For the sake of debugging these packages can be accessed directly, without a site by
|
||||
/srv/walnut/packages/pages/<tld.domain.package> # matches apps.<domain.tld>/<package-name> and <domain.tld>/apps/<package-name>
|
||||
```
|
||||
|
||||
Accessing REST APIs
|
||||
-------------------
|
||||
|
||||
```
|
||||
# Apps are granted access to use a package by listing it in the grants file by the name of the app url (domain.tld)
|
||||
/srv/walnut/packages/client-api-grants/<domain.tld> # matches api.<domain.tld>/api/ and contains a list of allowed REST APIs
|
||||
# the REST apis themselves are submatched as api.<domain.tld>/api/<tld.domain.package>
|
||||
|
||||
# packages are directories with reverse dns name, a package.json, and an index.js
|
||||
/srv/walnut/packages/rest/<tld.domain.package>
|
||||
```
|
||||
|
||||
Example tree with contents:
|
||||
|
||||
Here `com.example.hello` is a package with a REST API and a static page
|
||||
and `foobar.me` is a WALNUT-configured domain (smithfam.net, etc).
|
||||
|
||||
```
|
||||
/srv/walnut/packages/
|
||||
├── api
|
||||
├── client-api-grants
|
||||
│ └── cloud.foobar.me
|
||||
│ '''
|
||||
│ com.example.hello # refers to /srv/walnut/packages/rest/com.example.hello
|
||||
│ '''
|
||||
│
|
||||
├── pages
|
||||
│ └── com.example.hello
|
||||
│ └── index.html
|
||||
│ '''
|
||||
│ <html>
|
||||
│ <head><title>com.example.hello</title></head>
|
||||
│ <body>
|
||||
│ <h1>com.example.hello</h1>
|
||||
│ </body>
|
||||
│ </html>
|
||||
│ '''
|
||||
│
|
||||
├── rest
|
||||
│ └── com.example.hello
|
||||
│ ├── package.json
|
||||
│ └── index.js
|
||||
│ '''
|
||||
│ 'use strict';
|
||||
│
|
||||
│ module.exports.create = function (conf, deps, app) {
|
||||
│
|
||||
│ app.use('/', function (req, res) {
|
||||
│ console.log('[com.example.hello] req.url', req.url);
|
||||
│ res.send({ message: 'hello' });
|
||||
│ });
|
||||
│
|
||||
│ return deps.Promise.resolve();
|
||||
│ };
|
||||
│
|
||||
│ '''
|
||||
│
|
||||
├── services
|
||||
└── sites
|
||||
└── daplie.me
|
||||
'''
|
||||
com.example.hello # refers to /srv/walnut/packages/pages/com.example.hello
|
||||
'''
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue