Skip to content

Commit ba150c3

Browse files
Add types for Backend Customization Custom Routes (#2879)
1 parent 5c7efb7 commit ba150c3

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

docusaurus/docs/cms/backend-customization/routes.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@ In the following example, the custom routes file name is prefixed with `01-` to
209209
<TabItem value="js" label="JavaScript">
210210

211211
```js title="./src/api/restaurant/routes/01-custom-restaurant.js"
212-
213-
module.exports = {
212+
/** @type {import('@strapi/strapi').Core.RouterConfig} */
213+
const config = {
214+
type: 'content-api',
214215
routes: [
215216
{ // Path defined with an URL parameter
216217
method: 'POST',
@@ -224,15 +225,19 @@ module.exports = {
224225
}
225226
]
226227
}
228+
229+
module.exports = config
227230
```
228231

229232
</TabItem>
230233

231234
<TabItem value="ts" label="TypeScript">
232235

233236
```js title="./src/api/restaurant/routes/01-custom-restaurant.ts"
237+
import type { Core } from '@strapi/strapi';
234238

235-
export default {
239+
const config: Core.RouterConfig = {
240+
type: 'content-api',
236241
routes: [
237242
{ // Path defined with a URL parameter
238243
method: 'GET',
@@ -246,6 +251,8 @@ export default {
246251
}
247252
]
248253
}
254+
255+
export default config
249256
```
250257

251258
</TabItem>

docusaurus/static/llms-code.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13372,8 +13372,9 @@ Language: JavaScript
1337213372
File path: ./src/api/restaurant/routes/01-custom-restaurant.js
1337313373

1337413374
```js
13375-
13376-
module.exports = {
13375+
/** @type {import('@strapi/strapi').Core.RouterConfig} */
13376+
const config = {
13377+
type: 'content-api',
1337713378
routes: [
1337813379
{ // Path defined with an URL parameter
1337913380
method: 'POST',
@@ -13387,15 +13388,19 @@ module.exports = {
1338713388
}
1338813389
]
1338913390
}
13391+
13392+
module.exports = config
1339013393
```
1339113394

1339213395
---
1339313396
Language: TypeScript
1339413397
File path: ./src/api/restaurant/routes/01-custom-restaurant.ts
1339513398

1339613399
```ts
13400+
import type { Core } from '@strapi/strapi';
1339713401

13398-
export default {
13402+
const config: Core.RouterConfig = {
13403+
type: 'content-api',
1339913404
routes: [
1340013405
{ // Path defined with a URL parameter
1340113406
method: 'GET',
@@ -13409,6 +13414,8 @@ export default {
1340913414
}
1341013415
]
1341113416
}
13417+
13418+
export default config
1341213419
```
1341313420

1341413421

0 commit comments

Comments
 (0)