Skip to content

Commit 142914f

Browse files
feat(docs): CLI and application structure guide (#2818)
1 parent 9f712bf commit 142914f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1754
-670
lines changed

docs/.vitepress/components.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ declare module '@vue/runtime-core' {
1111
BlockQuote: typeof import('./components/BlockQuote.vue')['default']
1212
Contributors: typeof import('./components/Contributors.vue')['default']
1313
DatabaseBlock: typeof import('./components/DatabaseBlock.vue')['default']
14+
DatabaseSelect: typeof import('./components/DatabaseSelect.vue')['default']
1415
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
1516
ElInput: typeof import('element-plus/es')['ElInput']
1617
ElOption: typeof import('element-plus/es')['ElOption']
@@ -19,6 +20,7 @@ declare module '@vue/runtime-core' {
1920
ElSelect: typeof import('element-plus/es')['ElSelect']
2021
FeaturesList: typeof import('./components/FeaturesList.vue')['default']
2122
LanguageBlock: typeof import('./components/LanguageBlock.vue')['default']
23+
LanguageSelect: typeof import('./components/LanguageSelect.vue')['default']
2224
ListItem: typeof import('./components/ListItem.vue')['default']
2325
Logo: typeof import('./components/Logo.vue')['default']
2426
Select: typeof import('./components/Select.vue')['default']
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<script setup lang="ts">
2+
import { useGlobalDb } from '../theme/store'
3+
import Select from './Select.vue'
4+
5+
const activeGlobalDb = useGlobalDb()
6+
7+
const handleGlobalDbUpdate = (val: string) => {
8+
if (activeGlobalDb.value !== val) {
9+
activeGlobalDb.value = val
10+
document.body.setAttribute('data-db', val)
11+
}
12+
}
13+
</script>
14+
15+
<template>
16+
<Select
17+
id="GlobalDbSelect"
18+
:value="activeGlobalDb"
19+
label="Database"
20+
:options="[
21+
{ value: 'sql', text: 'SQL' },
22+
{ value: 'mongodb', text: 'MongoDB' }
23+
]"
24+
@update-value="handleGlobalDbUpdate"
25+
/>
26+
</template>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script setup lang="ts">
2+
import { useGlobalLanguage } from '../theme/store'
3+
import Select from './Select.vue'
4+
5+
const activeGlobalLanguage = useGlobalLanguage()
6+
7+
const handleGlobalLanguageUpdate = (val: string) => {
8+
activeGlobalLanguage.value = val
9+
document.body.setAttribute('data-language', val)
10+
}
11+
</script>
12+
13+
<template>
14+
<Select
15+
id="GlobalLanguageSelect"
16+
:value="activeGlobalLanguage"
17+
label="Code Language"
18+
:options="[
19+
{ value: 'ts', text: 'TypeScript' },
20+
{ value: 'js', text: 'JavaScript' }
21+
]"
22+
@update-value="handleGlobalLanguageUpdate"
23+
/>
24+
</template>

docs/.vitepress/config.sidebar.ts

Lines changed: 152 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export default {
6565
{
6666
text: 'Frontend',
6767
collapsible: true,
68+
collapsed: false,
6869
items: [
6970
{
7071
text: 'JavaScript',
@@ -77,16 +78,163 @@ export default {
7778
]
7879
},
7980
{
80-
text: 'Migrating',
81-
// collapsible: true,
81+
text: 'CLI',
82+
collapsible: true,
83+
collapsed: true,
8284
items: [
8385
{
84-
text: 'Migration guide',
85-
link: '/guides/migrating.md'
86+
text: 'Using the CLI',
87+
link: '/guides/cli/index.md'
8688
},
89+
{
90+
text: 'Generate App',
91+
link: '/guides/cli/generate-app.md'
92+
}
93+
]
94+
},
95+
{
96+
text: 'App Structure',
97+
collapsible: true,
98+
collapsed: false,
99+
items: [
100+
{
101+
text: '📂 config',
102+
items: [
103+
{
104+
text: '📄 default.json',
105+
link: '/guides/cli/default.json.md'
106+
},
107+
{
108+
text: '📄 custom-environment-variables.json',
109+
link: '/guides/cli/custom-environment-variables.md'
110+
}
111+
]
112+
},
113+
{
114+
text: '📂 src',
115+
items: [
116+
{
117+
text: '📂 hooks',
118+
items: [
119+
{
120+
text: '📄 &lt;hook&gt;',
121+
link: '/guides/cli/hook.md'
122+
},
123+
{
124+
text: '📄 log-error',
125+
link: '/guides/cli/log-error.md'
126+
}
127+
]
128+
},
129+
{
130+
text: '📂 services',
131+
items: [
132+
{
133+
text: '📂 &lt;service&gt;',
134+
items: [
135+
{
136+
text: '📄 &lt;service&gt;',
137+
link: '/guides/cli/service.md'
138+
},
139+
{
140+
text: '📄 &lt;service&gt;.class',
141+
link: '/guides/cli/service.class.md'
142+
},
143+
{
144+
text: '📄 &lt;service&gt;.schemas',
145+
link: '/guides/cli/service.schemas.md'
146+
}
147+
]
148+
},
149+
{
150+
text: '📄 index'
151+
}
152+
]
153+
},
154+
{
155+
text: '📄 app',
156+
link: '/guides/cli/app.md'
157+
},
158+
{
159+
text: '📄 authentication',
160+
link: '/guides/cli/authentication.md'
161+
},
162+
{
163+
text: '📄 channels',
164+
link: '/guides/cli/channels.md'
165+
},
166+
{
167+
text: '📄 client',
168+
link: '/guides/cli/client.md'
169+
},
170+
{
171+
text: '📄 configuration',
172+
link: '/guides/cli/configuration.md'
173+
},
174+
{
175+
text: '📄 declarations',
176+
link: '/guides/cli/declarations.md'
177+
},
178+
{
179+
text: '📄 logger',
180+
link: '/guides/cli/logger.md'
181+
},
182+
{
183+
text: '📄 validators',
184+
link: '/guides/cli/validators.md'
185+
},
186+
{
187+
text: '📄 &lt;database&gt;',
188+
link: '/guides/cli/databases.md'
189+
}
190+
]
191+
},
192+
{
193+
text: '📂 test',
194+
items: [
195+
{
196+
text: '📄 client.test',
197+
link: '/guides/cli/client.test.md'
198+
},
199+
{
200+
text: '📄 app.test',
201+
link: '/guides/cli/app.test.md'
202+
},
203+
{
204+
text: '📄 &lt;service&gt;.test',
205+
link: '/guides/cli/service.test.md'
206+
}
207+
]
208+
},
209+
{
210+
text: '📄 .prettierrc',
211+
link: '/guides/cli/prettierrc.md'
212+
},
213+
{
214+
text: '📄 knexfile',
215+
link: '/guides/cli/knexfile.md'
216+
},
217+
{
218+
text: '📄 package.json',
219+
link: '/guides/cli/package.md'
220+
},
221+
{
222+
text: '📄 tsconfig.json',
223+
link: '/guides/cli/tsconfig.md'
224+
}
225+
]
226+
},
227+
{
228+
text: 'Migrating',
229+
// collapsible: true,
230+
items: [
87231
{
88232
text: "What's new?",
89233
link: '/guides/whats-new.md'
234+
},
235+
{
236+
text: 'Migration guide',
237+
link: '/guides/migrating.md'
90238
}
91239
]
92240
}

docs/.vitepress/theme/FeathersLayout.vue

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,17 @@
11
<script setup lang="ts">
22
import DefaultTheme from 'vitepress/theme'
33
import Footer from '../../components/Footer.vue'
4-
import { useGlobalLanguage, useGlobalDb } from './store'
5-
import Select from '../components/Select.vue'
4+
import LanguageSelect from '../components/LanguageSelect.vue'
5+
import DatabaseSelect from '../components/DatabaseSelect.vue'
66
77
const { Layout } = DefaultTheme
8-
9-
const activeGlobalLanguage = useGlobalLanguage()
10-
const activeGlobalDb = useGlobalDb()
11-
12-
const handleGlobalLanguageUpdate = (val: string) => {
13-
activeGlobalLanguage.value = val
14-
document.body.setAttribute('data-language', val)
15-
}
16-
const handleGlobalDbUpdate = (val: string) => {
17-
if (activeGlobalDb.value !== val) {
18-
activeGlobalDb.value = val
19-
document.body.setAttribute('data-db', val)
20-
}
21-
}
228
</script>
239

2410
<template>
2511
<Layout>
2612
<template #sidebar-nav-before>
27-
<Select
28-
id="GlobalLanguageSelect"
29-
:value="activeGlobalLanguage"
30-
label="Code Language"
31-
:options="[
32-
{ value: 'ts', text: 'TypeScript' },
33-
{ value: 'js', text: 'JavaScript' }
34-
]"
35-
@update-value="handleGlobalLanguageUpdate"
36-
/>
37-
<Select
38-
id="GlobalDbSelect"
39-
:value="activeGlobalDb"
40-
label="Database"
41-
:options="[
42-
{ value: 'sql', text: 'SQL' },
43-
{ value: 'mongodb', text: 'MongoDB' }
44-
]"
45-
@update-value="handleGlobalDbUpdate"
46-
/>
13+
<LanguageSelect />
14+
<DatabaseSelect />
4715
</template>
4816
</Layout>
4917
<Footer />

docs/.vscode/settings.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/api/schema/validators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Ajv and most other validation libraries are only used for ensuring data is valid
1414

1515
## Usage
1616

17-
The following is the standard `validators.ts` file that sets up a validator for data and querys (for which string types will be coerced automatically). It also sets up a collection of additional formats using [ajv-formats](https://ajv.js.org/packages/ajv-formats.html). The validators in this file can be customized according to the [Ajv documentation](https://ajv.js.org/) and [its plugins](https://ajv.js.org/packages/). You can find the available Ajv options in the [Ajs class API docs](https://ajv.js.org/options.html).
17+
The following is the standard `validators.ts` file that sets up a validator for data and querys (for which string types will be coerced automatically). It also sets up a collection of additional formats using [ajv-formats](https://ajv.js.org/packages/ajv-formats.html). The validators in this file can be customized according to the [Ajv documentation](https://ajv.js.org/) and [its plugins](https://ajv.js.org/packages/). You can find the available Ajv options in the [Ajv class API docs](https://ajv.js.org/options.html).
1818

1919
```ts
2020
import { Ajv, addFormats } from '@feathersjs/schema'

docs/ecosystem/Packages.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,12 @@ const packagesToShow = computed(() => {
139139
return a.hasNPM ? -1 : 1
140140
}
141141
142-
if (a[key] > b[key]) {
142+
const valA = a[key] || 0
143+
const valB = b[key] || 0
144+
145+
if (valA > valB) {
143146
return -1
144-
} else if (a[key] < b[key]) {
147+
} else if (valA < valB) {
145148
return 1
146149
} else {
147150
return 0

docs/guides/basics/schemas.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ While schemas and resolvers can be used outside of a Feather application, you wi
3030
- **Query** schemas and resolvers validate and convert the query string and can also be used for additional limitations like only allowing a user to see and modify their own data
3131
- **External** resolvers that return a safe version of the data (e.g. hiding a users password) that can be sent to external clients
3232

33+
<hr />
34+
<DatabaseSelect />
35+
3336
## Adding a user avatar
3437

3538
Let's extend our existing users schema to add an `avatar` property so that our users can have a profile image.
@@ -55,7 +58,7 @@ import type { Static } from '@feathersjs/typebox'
5558
import { passwordHash } from '@feathersjs/authentication-local'
5659
5760
import type { HookContext } from '../../declarations'
58-
import { dataValidator, queryValidator } from '../../schemas/validators'
61+
import { dataValidator, queryValidator } from '../../validators'
5962
6063
// Main data model schema
6164
export const userSchema = Type.Object(
@@ -133,7 +136,7 @@ import type { Static } from '@feathersjs/typebox'
133136
import { passwordHash } from '@feathersjs/authentication-local'
134137
135138
import type { HookContext } from '../../declarations'
136-
import { dataValidator, queryValidator } from '../../schemas/validators'
139+
import { dataValidator, queryValidator } from '../../validators'
137140
138141
// Main data model schema
139142
export const userSchema = Type.Object(
@@ -220,7 +223,7 @@ import { Type, getDataValidator, getValidator, querySyntax } from '@feathersjs/t
220223
import type { Static } from '@feathersjs/typebox'
221224
222225
import type { HookContext } from '../../declarations'
223-
import { dataValidator, queryValidator } from '../../schemas/validators'
226+
import { dataValidator, queryValidator } from '../../validators'
224227
import { userSchema } from '../users/users.schema'
225228
226229
// Main data model schema
@@ -295,7 +298,7 @@ import { Type, getDataValidator, getValidator, querySyntax } from '@feathersjs/t
295298
import type { Static } from '@feathersjs/typebox'
296299
297300
import type { HookContext } from '../../declarations'
298-
import { dataValidator, queryValidator } from '../../schemas/validators'
301+
import { dataValidator, queryValidator } from '../../validators'
299302
import { userSchema } from '../users/users.schema'
300303
301304
// Main data model schema

0 commit comments

Comments
 (0)