You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Install and import Zod before using this pattern: `pnpm add zod` or `npm install zod`, then `import * as z from 'zod';`. `admin.express.withSchema(...)` will convert the Zod schema to OpenAPI for you.
80
+
69
81
Now you want to translate page meta title and meta description. You can do this by using `i18n` plugin for AdminForth.
70
82
71
83
```ts
72
84
import { AdminForth } from"adminforth";
85
+
import*aszfrom"zod";
73
86
74
87
exportconst SEO_PAGE_CATEGORY ="seo_page_config";
75
88
76
89
app.get(`${admin.config.baseUrl}/api/get_page`,\
90
+
admin.express.withSchema(
91
+
{
92
+
description: 'Returns translated SEO metadata for the page specified by the pageUrl query parameter.',
Install and import Zod before using this pattern: `pnpm add zod` or `npm install zod`, then `import*aszfrom'zod';`. `admin.express.withSchema(...)` will convert the Zod schema to OpenAPI for you.
427
+
416
428
417
429
> ☝️ Please note that we are using `admin.express.authorize` middleware to check if the user is logged in. If you want to make this endpoint public, you can remove this middleware. If user is not logged in, the request will return 401 Unauthorized status code, and protect our statistics from leak.
418
430
419
431
> ☝️ Moreover if you wrap your endpoint with `admin.express.authorize` middleware, you can access `req.adminUser` object in your endpoint to get the current user information.
420
432
433
+
> ☝️ Wrapping the route with `admin.express.withSchema(...)` registers it in `/api/v1/openapi.json` and `/api-docs`. Define custom routes before `admin.express.serve(app)` so AdminForth can pick them up.
434
+
421
435
> ☝️ AdminForth does not provide any facility to access data in database. You are free to use any ORM like Prisma, TypeORM, Sequelize,
422
436
mongoose, or just use raw SQL queries against your tables.
@@ -139,7 +148,8 @@ import express from 'express';
139
148
})
140
149
)
141
150
);
142
-
}
151
+
}
152
+
)
143
153
)
144
154
);
145
155
@@ -148,8 +158,12 @@ import express from 'express';
148
158
admin.express.serve(app)
149
159
```
150
160
161
+
Install and import Zod before using this pattern: `pnpm add zod` or `npm install zod`, then `import*aszfrom'zod';`. `admin.express.withSchema(...)` will convert the Zod schema to OpenAPI for you.
162
+
151
163
> ☝️ Please note that we are using [Frontend API](/docs/api/FrontendAPI/interfaces/FrontendAPIInterface/) `adminforth.list.updateFilter({field:'number_of_rooms', operator:'eq', value: selectedRoomsCount});` to set filter when we are located on apartments list page
152
164
165
+
> ☝️ The outer `admin.express.withSchema(...)` wrapper makes this custom Express route appear in `/api/v1/openapi.json` and `/api-docs`.
0 commit comments