Skip to content

Commit 47b1989

Browse files
test(frontend): add views to visually test components
1 parent 71f2856 commit 47b1989

File tree

9 files changed

+1055
-0
lines changed

9 files changed

+1055
-0
lines changed

helpers/frontend/assets/icon.svg

Lines changed: 4 additions & 0 deletions
Loading

helpers/frontend/index.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import express from "express";
2+
3+
const defaults = {
4+
mountPath: "/frontend",
5+
};
6+
7+
// eslint-disable-next-line new-cap
8+
const router = express.Router({ caseSensitive: true, mergeParams: true });
9+
10+
export default class FrontendEndpoint {
11+
constructor(options = {}) {
12+
this.id = "endpoint-frontend";
13+
this.meta = import.meta;
14+
this.name = "Frontend endpoint";
15+
this.options = { ...defaults, ...options };
16+
this.mountPath = this.options.mountPath;
17+
}
18+
19+
get routesPublic() {
20+
router.get("/:page", (request, response) => {
21+
const { page } = request.params;
22+
23+
response.render(`frontend-${page}`, {
24+
title: `Frontend ${page}`,
25+
});
26+
});
27+
28+
router.post("/form", (request, response) => {
29+
response.render(`frontend-form`, {
30+
title: `Frontend form (with errors)`,
31+
errors: {
32+
content: {
33+
msg: "Input error",
34+
param: "input",
35+
},
36+
},
37+
});
38+
});
39+
40+
return router;
41+
}
42+
43+
init(Indiekit) {
44+
Indiekit.addEndpoint(this);
45+
}
46+
}

helpers/frontend/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "@indiekit-test/frontend",
3+
"main": "index.js",
4+
"type": "module",
5+
"private": true,
6+
"license": "MIT"
7+
}

0 commit comments

Comments
 (0)