Skip to content

Commit 9a742be

Browse files
committed
docs: add ITranslateExpressRequest and IAdminUserExpressRequest types in api requests
1 parent f9de8c7 commit 9a742be

File tree

5 files changed

+5
-6
lines changed

5 files changed

+5
-6
lines changed

adminforth/documentation/docs/tutorial/03-Customization/08-pageInjections.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Also we have to add an Api to get percentages:
100100
```ts title="./index.ts"
101101
app.get(`${ADMIN_BASE_URL}/api/aparts-by-room-percentages/`,
102102
admin.express.authorize(
103-
async (req, res) => {
103+
async (req: IAdminUserExpressRequest, res) => {
104104
const roomPercentages = await admin.resource('aparts').dataConnector.client.prepare(
105105
`SELECT
106106
number_of_rooms,

adminforth/documentation/docs/tutorial/07-Plugins/01-AuditLog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ If you have a custom, self coded actions in your API, you can log them by callin
163163

164164
app.get(`${ADMIN_BASE_URL}/api/dashboard/`,
165165
admin.express.authorize(
166-
async (req, res) => {
166+
async (req: IAdminUserExpressRequest, res) => {
167167

168168
admin.getPluginByClassName<AuditLogPlugin>('AuditLogPlugin').logCustomAction({
169169
resourceId: 'aparts',

adminforth/documentation/docs/tutorial/07-Plugins/10-i18n.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ And on the backend side you can use tr function to translate the string:
428428
app.get(`${ADMIN_BASE_URL}/api/greeting`,
429429
admin.express.authorize(
430430
admin.express.translatable(
431-
async (req, res) => {
431+
async (req: IAdminUserExpressRequest & ITranslateExpressRequest, res) => {
432432
res.json({
433433
text: await req.tr('Welcome, {name}', 'customApis', { name: req.adminUser.username }),
434434
});

adminforth/types/Back.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ export interface ITranslateFunction {
109109
(
110110
msg: string,
111111
category: string,
112-
lang: string,
113112
params: any,
114113
pluralizationNumber?: number
115114
): Promise<string>;
@@ -351,7 +350,7 @@ export interface IAdminForth {
351350

352351
formatAdminForth(): string;
353352

354-
tr: ITranslateFunction;
353+
tr(msg: string, category: string, lang: string, params: any, pluralizationNumber?: number): Promise<string>;
355354

356355
createResourceRecord(
357356
params: { resource: AdminForthResource, record: any, adminUser: AdminUser, extra?: HttpExtra }

dev-demo/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ app.get(`${ADMIN_BASE_URL}/api/dashboard/`,
464464

465465
app.get(`${ADMIN_BASE_URL}/api/aparts-by-room-percentages/`,
466466
admin.express.authorize(
467-
async (req:IAdminUserExpressRequest, res) => {
467+
async (req: IAdminUserExpressRequest, res: express.response) => {
468468
const roomPercentages = await admin.resource('aparts').dataConnector.client.prepare(
469469
`SELECT
470470
number_of_rooms,

0 commit comments

Comments
 (0)