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 |
|
9 | This is the contributor documentation for `@patternplate/cli`
|
10 | For 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
|
17 | data 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 |
|
27 | The 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
|
37 | git clone https://github.com/patternplate/patternplate.git
|
38 | cd patternplate/packages/cli
|
39 | yarn
|
40 | yarn start
|
41 | ```
|
42 |
|
43 | ## Usage
|
44 |
|
45 | ```js
|
46 | const http = require("http");
|
47 | const 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 |
|
63 | Copyright by SinnerSchrader. All `@patternplate` packages are released under the MIT license.
|