-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.ts
48 lines (43 loc) · 889 Bytes
/
example.ts
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
import { manifestation, ApiManifest } from "./src/index";
const teapot = manifestation.newRoute({
route: "/teapot",
method: "all",
executor: (req, res) => {
const response = manifestation.newApiResponse({
status: 418,
message: "I'm not a teapot",
successful: true
});
manifestation.sendApiResponse(res, response);
}
})
/**
* Example Manifest
*
* This manifest has two routes with no middleware.
*
* /teapot
* /v1/teapot
*/
const manifest = manifestation.newManifest({
routes: [teapot],
versions: [
{
version: 1,
routes: [teapot],
routers: [
{
route: "/demoRouter",
routes: [teapot]
}
]
}
],
routers: [
{
route: "/demoRouter",
routes: [teapot]
}
]
})
manifestation.createServer(manifest, {}).listen(2020, () => { console.log("started") });