-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathhttp.js
More file actions
49 lines (43 loc) · 1.59 KB
/
Copy pathhttp.js
File metadata and controls
49 lines (43 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// # Exposing ARCs with HTTP
// Downstream apps set `path` to their `assets/` (or similar). Files there are served first; unhandled
// paths fall through to the packaged `@fabric/http` `assets/` (e.g. Fomantic / semantic) — no extra
// settings required. See `FabricHTTPServer` in `@fabric/http` `types/server.js` static middleware order.
// Fabric makes it easy to publish applications to the Web,
// giving downstream users access to a hosted instance of the
// application.
//
// By using `@fabric/http` we can import an existing Fabric
// application, and run an HTTP server which exposes a rendered
// HTML user interface, complete with progressive enhancement of
// features such as real-time updates and hardware-based key
// management.
//
// ## Quick Start
// Import the `@fabric/http` library:
const HTTP = require('@fabric/http');
// Define the `main` program:
async function main () {
// Create an instance of a [Server](https://dev.fabric.pub/docs/service.html):
const server = new HTTP.Server();
// Define a [Resource](https://dev.fabric.pub/docs/resource.html):
await server.define('Person', {
name: 'Person',
properties: {
username: { type: String , maxLength: 55 }
},
routes: {
list: '/people',
view: '/people/:id'
}
});
// Start the Server instance:
await server.start();
}
// Run Program:
main().catch((exception) => {
console.log('[EXAMPLES:HTTP]', 'HTTP Exception:', exception);
});
// That's it! You can now visit `https://localhost:` to interact
// using the HTTP interface for your program.
//
// Take a look at the other examples to learn more!