UNPKG

1.47 kBMarkdownView Raw
1> Documentation and development interface for component libraries
2
3# @patternplate/api
4
5* Framework independent
6* Bring design docs to live with real components
7* Powerful search and meta data system
8
9This is the contributor documentation for `@patternplate/cli`
10For user docs see [patternplate.github.io](https://patternplate.github.io)
11
12
13## About @patternplate/api
14
15`@patternplate/api` provides an express middleware for use with
16`@patternplate/client`, as well as a web socket emitting
17data about file changes and compilation processes.
18
19### Endpoints
20
21* `/` - Web socket
22* `/state.json` - Document and pattern tree
23* `/demo/*.html` - Demo renderings
24
25### WebSocket
26
27The web socket on `/` emits the following events:
28
29* `{type: "change", "payload": {file: "string", p: conntentType: "pattern" | "doc"}"}`
30* `{type: "error", "payload": Error"}`
31* `{type: "start", "payload": {target: "node" | "web"}}`
32* `{type: "done", "payload": {target: "node" | "web"}}`
33
34## Quick start
35
36```sh
37git clone https://github.com/patternplate/patternplate.git
38cd patternplate/packages/cli
39yarn
40yarn start
41```
42
43## Usage
44
45```js
46const http = require("http");
47const api = require("@patternplate/api");
48
49(async () => {
50 const server = http.createServer();
51
52 const apiRoute = await api({
53 cwd: process.cwd(),
54 server
55 });
56
57 const app = express().use("/api/", apiRoute)
58})();
59```
60
61## License
62
63Copyright by SinnerSchrader. All `@patternplate` packages are released under the MIT license.