Skip to content

Commit fa5ab57

Browse files
committed
Initial commit
1 parent aeab8f1 commit fa5ab57

File tree

7 files changed

+3614
-0
lines changed

7 files changed

+3614
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
custom/node_modules
3+
dist

custom/tsconfig.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": ".", // This should point to your project root
4+
"paths": {
5+
"@/*": [
6+
"../node_modules/adminforth/dist/spa/src/*"
7+
],
8+
"*": [
9+
"../node_modules/adminforth/dist/spa/node_modules/*"
10+
],
11+
"@@/*": [
12+
"."
13+
]
14+
}
15+
}
16+
}

index.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { AdminForthPlugin } from "adminforth";
2+
import type { IAdminForth, IHttpServer, AdminForthResourcePages, AdminForthResourceColumn, AdminForthDataTypes, AdminForthResource } from "adminforth";
3+
import type { PluginOptions } from './types.js';
4+
5+
6+
export default class extends AdminForthPlugin {
7+
options: PluginOptions;
8+
9+
constructor(options: PluginOptions) {
10+
super(options, import.meta.url);
11+
this.options = options;
12+
}
13+
14+
async modifyResourceConfig(adminforth: IAdminForth, resourceConfig: AdminForthResource) {
15+
super.modifyResourceConfig(adminforth, resourceConfig);
16+
17+
// simply modify resourceConfig or adminforth.config. You can get access to plugin options via this.options;
18+
}
19+
20+
validateConfigAfterDiscover(adminforth: IAdminForth, resourceConfig: AdminForthResource) {
21+
// optional method where you can safely check field types after database discovery was performed
22+
}
23+
24+
instanceUniqueRepresentation(pluginOptions: any) : string {
25+
// optional method to return unique string representation of plugin instance.
26+
// Needed if plugin can have multiple instances on one resource
27+
return `single`;
28+
}
29+
30+
setupEndpoints(server: IHttpServer) {
31+
server.endpoint({
32+
method: 'POST',
33+
path: `/plugin/${this.pluginInstanceId}/example`,
34+
handler: async ({ body }) => {
35+
const { name } = body;
36+
return { hey: `Hello ${name}` };
37+
}
38+
});
39+
}
40+
41+
}

0 commit comments

Comments
 (0)