Skip to content

Commit 2e62362

Browse files
committed
use markdown-it-include pkg for re-usable content
1 parent 6cd6f1c commit 2e62362

13 files changed

+166
-54
lines changed

docs/.vuepress/config.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import packageJson, {description} from '../../package';
2-
import {defineUserConfig, defaultTheme} from 'vuepress';
3-
import {getDirname, path} from '@vuepress/utils';
4-
import {docsearchPlugin} from '@vuepress/plugin-docsearch';
51
import codeCopyPlugin from '@snippetors/vuepress-plugin-code-copy';
2+
import { docsearchPlugin } from '@vuepress/plugin-docsearch';
3+
import { getDirname, path } from '@vuepress/utils';
4+
import markdownItInclude from 'markdown-it-include';
5+
import { defaultTheme, defineUserConfig } from 'vuepress';
6+
import packageJson, { description } from '../../package';
67

78
const __dirname = getDirname(import.meta.url);
89

@@ -24,10 +25,13 @@ export default defineUserConfig({
2425
* ref:https://v1.vuepress.vuejs.org/config/#head
2526
*/
2627
head: [
27-
['meta', {name: 'theme-color', content: '#3eaf7c'}],
28-
['meta', {name: 'apple-mobile-web-app-capable', content: 'yes'}],
29-
['meta', {name: 'apple-mobile-web-app-status-bar-style', content: 'black'}],
30-
['link', {rel: 'icon', type: 'image/x-icon', href: `${base}favicon.ico`}],
28+
['meta', { name: 'theme-color', content: '#3eaf7c' }],
29+
['meta', { name: 'apple-mobile-web-app-capable', content: 'yes' }],
30+
[
31+
'meta',
32+
{ name: 'apple-mobile-web-app-status-bar-style', content: 'black' },
33+
],
34+
['link', { rel: 'icon', type: 'image/x-icon', href: `${base}favicon.ico` }],
3135
[
3236
'link',
3337
{
@@ -60,6 +64,11 @@ export default defineUserConfig({
6064
codeCopyPlugin(),
6165
],
6266

67+
extendsMarkdown: (md) => {
68+
// use more markdown-it plugins!
69+
md.use(markdownItInclude);
70+
},
71+
6372
/**
6473
* Theme configuration, here is the default theme configuration for VuePress.
6574
*

docs/docs/api/administrator.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -331,16 +331,25 @@ This API allows a super-admin or admin to search for administrators. An admin ca
331331
- super admin
332332
- admin
333333
- inputs
334-
- a filter defining fields, where, include, order, offset, and limit. See [Loopback Querying Data](https://loopback.io/doc/en/lb4/Querying-data.html) for valid syntax and examples
335-
- parameter name: filter
336-
- required: false
337-
- parameter type: query
338-
- data type: object
334+
335+
- !!!include(./docs/shared/filterQueryParam.md)!!!
336+
339337
- outcome
338+
340339
- for super-admins, returns an array of _Administrators_ matching the filter
341340
- for admins, returns an array of one element - own record if the record matches the filter; empty array otherwise
342341
- forbidden otherwise
343342
343+
- example
344+
345+
to retrieve administrators created in year 2023, run
346+
347+
```sh
348+
curl -X GET --header 'Accept: application/json' 'http://localhost:3000/api/administrators!!!include(./docs/shared/filterQueryParamCode.md)!!!'
349+
```
350+
351+
!!!include(./docs/shared/filterQueryParamExample.md)!!!
352+
344353
## Update Administrators
345354

346355
```
@@ -388,16 +397,19 @@ This API allows a super-admin or admin to count administrators by filter. An adm
388397
- super admin
389398
- admin
390399
- inputs
391-
392-
- a [where filter](https://loopback.io/doc/en/lb4/Where-filter.html)
393-
- parameter name: where
394-
- required: false
395-
- parameter type: query
396-
- data type: object
397-
400+
- !!!include(./docs/shared/whereQueryParam.md)!!!
398401
- outcome
399402
- for super-admins or admin, a count matching the filter
400403
- forbidden otherwise
404+
- example
405+
406+
to retrieve the count of administrators created in year 2023 , run
407+
408+
```sh
409+
curl -X GET --header 'Accept: application/json' 'http://localhost:3000/api/administrators/count!!!include(./docs/shared/whereQueryParamCode.md)!!!'
410+
```
411+
412+
!!!include(./docs/shared/whereQueryParamExample.md)!!!
401413

402414
## Delete an Administrator
403415

docs/docs/api/config.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,28 +79,22 @@ GET /configurations
7979
- super admin
8080
- admin
8181
- inputs
82-
- a [filter](https://loopback.io/doc/en/lb4/Querying-data.html#filters) defining fields, where, include, order, offset, and limit
83-
- parameter name: filter
84-
- required: false
85-
- parameter type: query
86-
- data type: object
82+
83+
- !!!include(./docs/shared/filterQueryParam.md)!!!
84+
8785
- outcome
8886

8987
For admin request, a list of config items matching the filter; forbidden for user request
9088

9189
- example
9290

93-
to retrieve config items with name _rsa_, run
91+
to retrieve configs created in year 2023, run
9492

9593
```sh
96-
curl -X GET --header 'Accept: application/json' 'http://localhost:3000/api/configurations?filter=%7B%22where%22%3A%20%7B%22name%22%3A%22rsa%22%7D%7D'
94+
curl -X GET --header 'Accept: application/json' 'http://localhost:3000/api/configurations!!!include(./docs/shared/filterQueryParamCode.md)!!!'
9795
```
9896

99-
the value of filter query parameter is the [stringified JSON](https://loopback.io/doc/en/lb4/Querying-data.html#using-stringified-json-in-rest-queries)
100-
101-
```json
102-
{"where": {"name": "rsa"}}
103-
```
97+
!!!include(./docs/shared/filterQueryParamExample.md)!!!
10498

10599
## Create a Configuration
106100

docs/docs/api/notification.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,11 @@ GET /notifications
359359
- admin
360360
- authenticated user
361361
- inputs
362-
- a filter defining fields, where, include, order, offset, and limit. See [Loopback Querying Data](https://loopback.io/doc/en/lb4/Querying-data.html#filters) for valid syntax and examples
363-
- parameter name: filter
364-
- required: false
365-
- parameter type: query
366-
- data type: object
362+
363+
- !!!include(./docs/shared/filterQueryParam.md)!!!
364+
367365
- outcome
366+
368367
- for admin requests, returns unabridged array of notification data matching the filter
369368
- for authenticated user requests, in addition to filter, following constraints are imposed on the returned array
370369
- only inApp notifications
@@ -375,6 +374,16 @@ GET /notifications
375374
- the internal field _readBy_ and _deletedBy_ are removed
376375
- forbidden to anonymous user requests
377376

377+
- example
378+
379+
to retrieve notifications created in year 2023, run
380+
381+
```sh
382+
curl -X GET --header 'Accept: application/json' 'http://localhost:3000/api/notifications!!!include(./docs/shared/filterQueryParamCode.md)!!!'
383+
```
384+
385+
!!!include(./docs/shared/filterQueryParamExample.md)!!!
386+
378387
## Get Notification Count
379388

380389
```
@@ -386,11 +395,7 @@ GET /notifications/count
386395
- admin
387396
- authenticated user
388397
- inputs
389-
- a [where filter](https://loopback.io/doc/en/lb4/Where-filter.html)
390-
- parameter name: filter
391-
- required: false
392-
- parameter type: query
393-
- data type: object
398+
- !!!include(./docs/shared/whereQueryParam.md)!!!
394399
- outcome
395400

396401
Validations rules are the same as _GET /notifications_. If passed, the output is a count of notifications matching the query
@@ -401,6 +406,16 @@ GET /notifications/count
401406
}
402407
```
403408

409+
- example
410+
411+
to retrieve the count of notifications created in year 2023, run
412+
413+
```sh
414+
curl -X GET --header 'Accept: application/json' 'http://localhost:3000/api/notifications/count!!!include(./docs/shared/whereQueryParamCode.md)!!!'
415+
```
416+
417+
!!!include(./docs/shared/whereQueryParamExample.md)!!!
418+
404419
## Create/Send Notifications
405420

406421
```

docs/docs/api/subscription.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,19 +266,28 @@ GET /subscriptions
266266
- admin
267267
- authenticated user
268268
- inputs
269-
- a filter defining fields, where, include, order, offset, and limit. See [Loopback Querying Data](https://loopback.io/doc/en/lb4/Querying-data.html) for valid syntax and examples
270-
- parameter name: filter
271-
- required: false
272-
- parameter type: query
273-
- data type: object
269+
270+
- !!!include(./docs/shared/filterQueryParam.md)!!!
271+
274272
- outcome
273+
275274
- for admin requests, returns unabridged array of subscription data matching the filter
276275
- for authenticated user requests, in addition to filter, following constraints are imposed on the returned array
277276
- only non-deleted subscriptions
278277
- only subscriptions created by the user
279278
- the _confirmationRequest_ field is removed.
280279
- forbidden for anonymous user requests
281280

281+
- example
282+
283+
to retrieve subscriptions created in year 2023, run
284+
285+
```sh
286+
curl -X GET --header 'Accept: application/json' 'http://localhost:3000/api/subscriptions!!!include(./docs/shared/filterQueryParamCode.md)!!!'
287+
```
288+
289+
!!!include(./docs/shared/filterQueryParamExample.md)!!!
290+
282291
## Get Subscription Count
283292

284293
```
@@ -290,11 +299,7 @@ GET /subscriptions/count?where[property]=value
290299
- admin
291300
- authenticated user
292301
- inputs
293-
- a [where filter](https://loopback.io/doc/en/lb4/Where-filter.html)
294-
- parameter name: where
295-
- required: false
296-
- parameter type: query
297-
- data type: object
302+
- !!!include(./docs/shared/whereQueryParam.md)!!!
298303
- outcome
299304

300305
Validations rules are the same as _GET /subscriptions_. If passed, the output is a count of subscriptions matching the query
@@ -305,9 +310,15 @@ GET /subscriptions/count?where[property]=value
305310
}
306311
```
307312

308-
- examples
313+
- example
314+
315+
to retrieve the count of subscriptions created in year 2023, run
316+
317+
```sh
318+
curl -X GET --header 'Accept: application/json' 'http://localhost:3000/api/subscriptions/count!!!include(./docs/shared/whereQueryParamCode.md)!!!'
319+
```
309320

310-
See LoopBack [Get instance count](http://loopback.io/doc/en/lb3/PersistedModel-REST-API.html#get-instance-count) for examples.
321+
!!!include(./docs/shared/whereQueryParamExample.md)!!!
311322

312323
## Create a Subscription
313324

docs/docs/shared/filterQueryParam.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
a filter containing properties _where_, _fields_, _order_, _skip_, and _limit_
2+
3+
- parameter name: filter
4+
- required: false
5+
- parameter type: query
6+
- data type: object
7+
8+
The filter can be expressed as either
9+
10+
1. URL-encoded stringified JSON object (see example below); or
11+
2. in the format supported by [qs](https://github.com/ljharb/qs), for example `?filter[where][created][$gte]="2023-01-01"&filter[where][created][$lt]="2024-01-01"`
12+
13+
Regardless, the filter will have to be parsed into a JSON object conforming to
14+
15+
```json
16+
{
17+
"where": {...},
18+
"fields": ...,
19+
"order": ...,
20+
"skip": ...,
21+
"limit": ...,
22+
}
23+
```
24+
25+
All properties are optional. The syntax for each property is documented, respectively
26+
- for *where* , see MongoDB [Query Documents](https://www.mongodb.com/docs/manual/tutorial/query-documents/)
27+
- for *fields* , see Mongoose [select](https://mongoosejs.com/docs/api/query.html#Query.prototype.select())
28+
- for *order*, see Mongoose [sort](https://mongoosejs.com/docs/api/query.html#Query.prototype.sort())
29+
- for *skip*, see MongoDB [cursor.skip](https://www.mongodb.com/docs/manual/reference/method/cursor.skip/)
30+
- for *limit*, see MongoDB [cursor.limit](https://www.mongodb.com/docs/manual/reference/method/cursor.limit/)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
?filter=%7B%22where%22%3A%7B%22created%22%3A%7B%22%24gte%22%3A%222023-01-01%22%2C%22%24lt%22%3A%222024-01-01%22%7D%7D%7D
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
the value of the filter query parameter is URL-encoded stringified JSON object
2+
3+
```json
4+
{
5+
"where": {
6+
"created": {
7+
"$gte": "2023-01-01",
8+
"$lt": "2024-01-01"
9+
}
10+
}
11+
}
12+
```

docs/docs/shared/whereQueryParam.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
a _where_ query parameter with value conforming to MongoDB [Query Documents](https://www.mongodb.com/docs/manual/tutorial/query-documents/)
2+
3+
- parameter name: where
4+
- required: false
5+
- parameter type: query
6+
- data type: object
7+
8+
The value can be expressed as either
9+
10+
1. URL-encoded stringified JSON object (see example below); or
11+
2. in the format supported by [qs](https://github.com/ljharb/qs), for example `?where[created][$gte]="2023-01-01"&where[created][$lt]="2024-01-01"`
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
?where=%7B%22created%22%3A%7B%22%24gte%22%3A%222023-01-01%22%2C%22%24lt%22%3A%222024-01-01%22%7D%7D

0 commit comments

Comments
 (0)