From b9857962de3411bcdc91350e1f6a3588bd26f477 Mon Sep 17 00:00:00 2001 From: Pavlo Kulyk Date: Mon, 23 Mar 2026 13:38:29 +0200 Subject: [PATCH 1/4] feat: extend API to include all user and current user in response --- adminforth/commands/createApp/templates/api.ts.hbs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/adminforth/commands/createApp/templates/api.ts.hbs b/adminforth/commands/createApp/templates/api.ts.hbs index 6aac70a5..c9fef34b 100644 --- a/adminforth/commands/createApp/templates/api.ts.hbs +++ b/adminforth/commands/createApp/templates/api.ts.hbs @@ -2,6 +2,11 @@ import { Express, Request, Response } from "express"; import { IAdminForth } from "adminforth"; export function initApi(app: Express, admin: IAdminForth) { app.get(`${admin.config.baseUrl}/api/hello/`, + + // you can use data API to work with your database https://adminforth.dev/docs/tutorial/Customization/dataApi/ + const allUsers = await admin.resource.list([]); + + // you can use req.adminUser to get info about the logged-in admin user async (req: Request, res: Response) => { const allUsers = await admin.resource("adminuser").list([]); res.json({ @@ -9,5 +14,12 @@ export function initApi(app: Express, admin: IAdminForth) { users: allUsers, }); } + + // you can use admin.express.authorize to get info about the current user + admin.express.authorize( + async (req: Request, res: Response) => { + res.json({ message: "Hello from AdminForth API!", adminUser: req.adminUser }); + } + ) ); } \ No newline at end of file From 545f5e4d228735e161d7d809614a051eea6ad570 Mon Sep 17 00:00:00 2001 From: Pavlo Kulyk Date: Wed, 25 Mar 2026 11:54:05 +0200 Subject: [PATCH 2/4] feat: extend API to include all user and current user in response --- adminforth/commands/createApp/templates/api.ts.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adminforth/commands/createApp/templates/api.ts.hbs b/adminforth/commands/createApp/templates/api.ts.hbs index c9fef34b..1107b1de 100644 --- a/adminforth/commands/createApp/templates/api.ts.hbs +++ b/adminforth/commands/createApp/templates/api.ts.hbs @@ -10,7 +10,7 @@ export function initApi(app: Express, admin: IAdminForth) { async (req: Request, res: Response) => { const allUsers = await admin.resource("adminuser").list([]); res.json({ - message: "Hello from AdminForth API!", + message: "List of adminuser from AdminForth API", users: allUsers, }); } @@ -18,7 +18,7 @@ export function initApi(app: Express, admin: IAdminForth) { // you can use admin.express.authorize to get info about the current user admin.express.authorize( async (req: Request, res: Response) => { - res.json({ message: "Hello from AdminForth API!", adminUser: req.adminUser }); + res.json({ message: "Current adminuser from AdminForth API", adminUser: req.adminUser }); } ) ); From 928919e7c918e4270db31c12418f5ecbf825a119 Mon Sep 17 00:00:00 2001 From: Pavlo Kulyk Date: Wed, 25 Mar 2026 12:00:12 +0200 Subject: [PATCH 3/4] feat: extend API to include all user and current user in response --- adminforth/commands/createApp/templates/api.ts.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adminforth/commands/createApp/templates/api.ts.hbs b/adminforth/commands/createApp/templates/api.ts.hbs index 1107b1de..5fd344b2 100644 --- a/adminforth/commands/createApp/templates/api.ts.hbs +++ b/adminforth/commands/createApp/templates/api.ts.hbs @@ -10,7 +10,7 @@ export function initApi(app: Express, admin: IAdminForth) { async (req: Request, res: Response) => { const allUsers = await admin.resource("adminuser").list([]); res.json({ - message: "List of adminuser from AdminForth API", + message: "List of logged-in admin user from AdminForth API", users: allUsers, }); } From 6cc9fc7815cda1581012c7fddf1c918d4b75944a Mon Sep 17 00:00:00 2001 From: Pavlo Kulyk Date: Wed, 25 Mar 2026 14:37:55 +0200 Subject: [PATCH 4/4] feat: extend API to include all user and current user in response --- adminforth/commands/createApp/templates/api.ts.hbs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/adminforth/commands/createApp/templates/api.ts.hbs b/adminforth/commands/createApp/templates/api.ts.hbs index 5fd344b2..b568af53 100644 --- a/adminforth/commands/createApp/templates/api.ts.hbs +++ b/adminforth/commands/createApp/templates/api.ts.hbs @@ -4,9 +4,7 @@ export function initApi(app: Express, admin: IAdminForth) { app.get(`${admin.config.baseUrl}/api/hello/`, // you can use data API to work with your database https://adminforth.dev/docs/tutorial/Customization/dataApi/ - const allUsers = await admin.resource.list([]); - - // you can use req.adminUser to get info about the logged-in admin user + // req.adminUser to get info about the logged-in admin user async (req: Request, res: Response) => { const allUsers = await admin.resource("adminuser").list([]); res.json({