nuxt-feathers-zod 6.3.2 → 6.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -84
- package/bin/nuxt-feathers-zod +7 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +7 -6
- package/dist/runtime/composables/feathers.d.ts +2 -2
- package/dist/runtime/composables/useAuth.js +8 -6
- package/dist/runtime/options/database/mongodb.d.ts +24 -2
- package/dist/runtime/options/database/mongodb.js +13 -1
- package/dist/runtime/options/index.js +5 -5
- package/dist/runtime/options/plugins.js +10 -1
- package/dist/runtime/options/server.js +1 -1
- package/dist/runtime/options/transports/websocket.js +5 -3
- package/dist/runtime/plugins/feathers-auth.d.ts +1 -1
- package/dist/runtime/plugins/keycloak-sso.d.ts +1 -1
- package/dist/runtime/templates/server/app.js +19 -0
- package/dist/runtime/templates/server/authentication.js +1 -6
- package/dist/runtime/templates/server/index.js +15 -9
- package/dist/runtime/templates/server/keycloak.js +15 -26
- package/dist/runtime/templates/server/mongodb.js +150 -9
- package/dist/runtime/templates/server/plugin.js +43 -12
- package/dist/runtime/templates/server/server-runtime.d.ts +2 -0
- package/dist/runtime/templates/server/server-runtime.js +14 -0
- package/dist/runtime/templates/server/server-types.d.ts +2 -0
- package/dist/runtime/templates/server/server-types.js +65 -0
- package/dist/runtime/templates/server/server.js +4 -2
- package/package.json +15 -6
- package/src/cli/core.ts +1368 -70
- package/src/cli/index.ts +821 -292
package/README.md
CHANGED
|
@@ -2,28 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
[Documentation](https://vevedh.github.io/nuxt-feathers-zod/)
|
|
4
4
|
|
|
5
|
-
`nuxt-feathers-zod` is
|
|
5
|
+
`nuxt-feathers-zod` is an official **Nuxt 4** module that embeds or connects to **FeathersJS v5 (Dove)** with a **CLI-first** workflow and optional **Zod-first** service generation.
|
|
6
6
|
|
|
7
7
|
It supports two main usage patterns:
|
|
8
8
|
|
|
9
9
|
- **embedded mode**: a Feathers server runs inside Nuxt/Nitro
|
|
10
10
|
- **remote mode**: a Nuxt app uses a Feathers client against an external API
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Open source scope
|
|
13
|
+
|
|
14
|
+
The public OSS module includes:
|
|
13
15
|
|
|
14
16
|
- Nuxt 4 + Nitro integration
|
|
15
17
|
- embedded and remote modes
|
|
16
18
|
- REST and Socket.IO transports
|
|
17
19
|
- embedded server with **Express** or **Koa**
|
|
18
20
|
- CLI bootstrap for `init embedded`, `init remote`, `init templates`
|
|
19
|
-
- CLI
|
|
20
|
-
-
|
|
21
|
-
- remote-service registration with `add remote-service`
|
|
21
|
+
- CLI generation for services, remote services, middleware and server modules
|
|
22
|
+
- schema modes `none | zod | json`
|
|
22
23
|
- local/JWT auth flows
|
|
23
|
-
- Keycloak SSO bridge
|
|
24
|
+
- Keycloak SSO bridge for remote mode
|
|
24
25
|
- optional legacy Swagger support
|
|
25
26
|
- template overrides
|
|
26
|
-
-
|
|
27
|
+
- optional MongoDB management surface via `database.mongo.management`
|
|
27
28
|
- client-side helpers with Pinia / feathers-pinia support
|
|
28
29
|
|
|
29
30
|
## Installation
|
|
@@ -39,7 +40,7 @@ Optional Swagger dependencies:
|
|
|
39
40
|
bun add feathers-swagger swagger-ui-dist
|
|
40
41
|
```
|
|
41
42
|
|
|
42
|
-
##
|
|
43
|
+
## Quick start — embedded mode
|
|
43
44
|
|
|
44
45
|
```bash
|
|
45
46
|
bunx nuxi@latest init my-nfz-app
|
|
@@ -61,7 +62,7 @@ bun install
|
|
|
61
62
|
bun add nuxt-feathers-zod feathers-pinia feathers-swagger swagger-ui-dist
|
|
62
63
|
bun add -D @pinia/nuxt
|
|
63
64
|
bunx nuxt-feathers-zod init embedded --force --auth --swagger
|
|
64
|
-
bunx nuxt-feathers-zod add service users --auth --adapter mongodb --collection users --idField _id --docs
|
|
65
|
+
bunx nuxt-feathers-zod add service users --auth --adapter mongodb --schema zod --collection users --idField _id --docs
|
|
65
66
|
bun dev
|
|
66
67
|
```
|
|
67
68
|
|
|
@@ -83,110 +84,94 @@ bun dev
|
|
|
83
84
|
```bash
|
|
84
85
|
bunx nuxt-feathers-zod init embedded --force
|
|
85
86
|
bunx nuxt-feathers-zod init remote --url https://api.example.com --transport rest --force
|
|
86
|
-
bunx nuxt-feathers-zod add service users --adapter mongodb --collection users --idField _id
|
|
87
|
+
bunx nuxt-feathers-zod add service users --adapter mongodb --schema zod --collection users --idField _id
|
|
88
|
+
bunx nuxt-feathers-zod add service users --auth --authAware --schema zod --adapter mongodb --collection users --idField _id
|
|
87
89
|
bunx nuxt-feathers-zod add service actions --custom --methods find --customMethods run,preview
|
|
88
90
|
bunx nuxt-feathers-zod add remote-service users --path users --methods find,get
|
|
91
|
+
bunx nuxt-feathers-zod add middleware trace-headers --target nitro
|
|
92
|
+
bunx nuxt-feathers-zod add server-module helmet --preset helmet
|
|
93
|
+
bunx nuxt-feathers-zod add mongodb-compose
|
|
94
|
+
bunx nuxt-feathers-zod auth service users --enabled true
|
|
95
|
+
bunx nuxt-feathers-zod schema users --show
|
|
89
96
|
bunx nuxt-feathers-zod doctor
|
|
90
97
|
```
|
|
91
98
|
|
|
92
|
-
##
|
|
93
|
-
|
|
94
|
-
The project is being stabilized around a predictable **standard open source core**.
|
|
95
|
-
|
|
96
|
-
That core currently includes:
|
|
97
|
-
|
|
98
|
-
- runtime + transports
|
|
99
|
-
- auth basics
|
|
100
|
-
- CLI generation
|
|
101
|
-
- template overrides
|
|
102
|
-
- server modules
|
|
103
|
-
- docs and playground validation
|
|
104
|
-
|
|
105
|
-
Potential future **license-key / Pro** candidates are intentionally kept outside that frozen core, such as advanced visual consoles, premium diagnostics, builders, enterprise presets, and packaged RBAC/policy layers.
|
|
106
|
-
|
|
107
|
-
## Development commands
|
|
108
|
-
|
|
109
|
-
```bash
|
|
110
|
-
bun install
|
|
111
|
-
bun run build
|
|
112
|
-
bun run typecheck
|
|
113
|
-
bun run docs:dev
|
|
114
|
-
bun run docs:build
|
|
115
|
-
```
|
|
99
|
+
## Auth-aware generation for `users`
|
|
116
100
|
|
|
101
|
+
For the `users` service, `--auth` and `--authAware` are distinct concerns:
|
|
117
102
|
|
|
118
|
-
|
|
103
|
+
- `--auth` protects service methods with JWT hooks
|
|
104
|
+
- `--authAware` enables local-auth-aware password handling
|
|
119
105
|
|
|
120
|
-
|
|
121
|
-
It validates the main surfaces of the module:
|
|
106
|
+
When generating `users --auth`, the CLI keeps an **auto-safe default** and enables auth-aware behavior unless it is explicitly disabled.
|
|
122
107
|
|
|
123
|
-
-
|
|
124
|
-
- lint the repository
|
|
125
|
-
- run the template sanity check
|
|
126
|
-
- build the Nuxt module
|
|
127
|
-
- build the playground application
|
|
128
|
-
- build the VitePress documentation
|
|
108
|
+
Auth-aware generation ensures the generated service handles password concerns consistently across `schema=none|zod|json` and `adapter=memory|mongodb`:
|
|
129
109
|
|
|
130
|
-
|
|
110
|
+
- hashes `password` with `passwordHash({ strategy: 'local' })`
|
|
111
|
+
- strips `password` from returned records/results
|
|
112
|
+
- persists the `authAware` state in the service manifest
|
|
131
113
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
The repository now includes two GitHub Actions workflows:
|
|
135
|
-
|
|
136
|
-
- `.github/workflows/ci.yml` for the standard open-source validation gates
|
|
137
|
-
- `.github/workflows/publish.yml` for validated npm publication on tag or manual trigger
|
|
138
|
-
|
|
139
|
-
Manual release checklist:
|
|
114
|
+
Examples:
|
|
140
115
|
|
|
141
116
|
```bash
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
bun run prepare
|
|
146
|
-
bun run build
|
|
147
|
-
bun run docs:build
|
|
148
|
-
npm pack --dry-run
|
|
117
|
+
bunx nuxt-feathers-zod add service users --auth --schema none --adapter memory --force
|
|
118
|
+
bunx nuxt-feathers-zod add service users --auth --schema zod --adapter mongodb --collection users --idField _id --force
|
|
119
|
+
bunx nuxt-feathers-zod add service users --auth --authAware false --schema json --adapter memory --force
|
|
149
120
|
```
|
|
150
121
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
122
|
+
## Optional MongoDB management surface
|
|
123
|
+
|
|
124
|
+
The OSS core can expose an optional MongoDB management layer from the generated `feathers/server/mongodb.ts` template, backed by `feathers-mongodb-management-ts`.
|
|
125
|
+
|
|
126
|
+
Example:
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
export default defineNuxtConfig({
|
|
130
|
+
modules: ['nuxt-feathers-zod'],
|
|
131
|
+
feathers: {
|
|
132
|
+
database: {
|
|
133
|
+
mongo: {
|
|
134
|
+
url: 'mongodb://root:change-me@127.0.0.1:27017/app?authSource=admin',
|
|
135
|
+
management: {
|
|
136
|
+
enabled: true,
|
|
137
|
+
auth: true,
|
|
138
|
+
basePath: '/mongo',
|
|
139
|
+
exposeDatabasesService: true,
|
|
140
|
+
exposeCollectionsService: true,
|
|
141
|
+
exposeCollectionCrud: true,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
})
|
|
156
147
|
```
|
|
157
148
|
|
|
158
|
-
|
|
149
|
+
This adds a controlled, opt-in management layer for:
|
|
159
150
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
```
|
|
151
|
+
- `/mongo/databases`
|
|
152
|
+
- `/mongo/<db>/collections`
|
|
153
|
+
- `/mongo/<db>/<collection>`
|
|
164
154
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
## Publishing to npm
|
|
155
|
+
## Protecting an existing service after generation
|
|
168
156
|
|
|
169
157
|
```bash
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
bun run build
|
|
173
|
-
npm pack --dry-run
|
|
174
|
-
npm version patch
|
|
175
|
-
npm publish --access public
|
|
158
|
+
bunx nuxt-feathers-zod auth service users --enabled true
|
|
159
|
+
bunx nuxt-feathers-zod auth service users --enabled false
|
|
176
160
|
```
|
|
177
161
|
|
|
178
|
-
|
|
162
|
+
## Generating a local MongoDB Docker Compose file
|
|
179
163
|
|
|
180
164
|
```bash
|
|
181
|
-
|
|
182
|
-
|
|
165
|
+
bunx nuxt-feathers-zod add mongodb-compose
|
|
166
|
+
bunx nuxt-feathers-zod add mongodb-compose --out docker-compose-db.yaml --database app --rootPassword secret --force
|
|
183
167
|
```
|
|
184
168
|
|
|
185
169
|
## Notes
|
|
186
170
|
|
|
187
|
-
-
|
|
188
|
-
-
|
|
189
|
-
- Historical aliases may remain supported for backward compatibility, but the public docs
|
|
171
|
+
- Recommended convention: `servicesDirs: ['services']`
|
|
172
|
+
- Recommended path: **CLI-first**
|
|
173
|
+
- Historical aliases may remain supported for backward compatibility, but the public docs foreground canonical commands only
|
|
174
|
+
- Maintainer-only publication and admin procedures are kept in `README_private.md` and intentionally excluded from the public repository surface
|
|
190
175
|
|
|
191
176
|
## License
|
|
192
177
|
|
package/bin/nuxt-feathers-zod
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
+
import { handleCliError } from '../src/cli/core.ts'
|
|
3
4
|
import { runCli } from '../src/cli/index.ts'
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
try {
|
|
7
|
+
await runCli(process.argv.slice(2), { cwd: process.cwd() })
|
|
8
|
+
}
|
|
9
|
+
catch (err) {
|
|
10
|
+
handleCliError(err)
|
|
11
|
+
}
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { getServerTemplates } from '../dist/runtime/templates/server/index.js';
|
|
|
13
13
|
function setAliases(options, nuxt) {
|
|
14
14
|
const resolver = createResolver(import.meta.url);
|
|
15
15
|
const aliases = {
|
|
16
|
-
"nuxt-feathers-zod/server": resolver.resolve(options.templateDir, "server/server"),
|
|
16
|
+
"nuxt-feathers-zod/server": resolver.resolve(options.templateDir, "server/server.js"),
|
|
17
17
|
"nuxt-feathers-zod/validators": resolver.resolve("runtime/zod/validators"),
|
|
18
18
|
"nuxt-feathers-zod/query": resolver.resolve("runtime/zod/query"),
|
|
19
19
|
"nuxt-feathers-zod/zod": resolver.resolve("runtime/zod/index"),
|
|
@@ -121,7 +121,7 @@ const module$1 = defineNuxtModule({
|
|
|
121
121
|
for (const serverTemplate of getServerTemplates(resolvedOptions)) {
|
|
122
122
|
const ov = resolveTemplateOverrideForFilename(serverTemplate.filename, resolvedOptions);
|
|
123
123
|
const tpl = addTemplate(ov ? { filename: serverTemplate.filename, src: ov.absPath, write: true, options: resolvedOptions } : { ...serverTemplate, options: resolvedOptions });
|
|
124
|
-
if (serverTemplate.filename?.endsWith("server/plugin.ts") || serverTemplate.filename?.endsWith("server/plugin"))
|
|
124
|
+
if (serverTemplate.filename?.endsWith("server/plugin.ts") || serverTemplate.filename?.endsWith("server/plugin.js") || serverTemplate.filename?.endsWith("server/plugin"))
|
|
125
125
|
serverPluginDst = tpl.dst;
|
|
126
126
|
}
|
|
127
127
|
addServerPlugin(serverPluginDst ?? resolver.resolve(resolvedOptions.templateDir, "server/plugin.ts"));
|
|
@@ -131,10 +131,11 @@ const module$1 = defineNuxtModule({
|
|
|
131
131
|
const piniaEnabled = clientOptions.pinia !== false && Boolean(clientOptions.pinia);
|
|
132
132
|
if (piniaEnabled) {
|
|
133
133
|
nuxt.hook("vite:extendConfig", (config) => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
const mutableConfig = config;
|
|
135
|
+
mutableConfig.optimizeDeps ||= {};
|
|
136
|
+
mutableConfig.optimizeDeps.include ||= [];
|
|
137
|
+
if (!mutableConfig.optimizeDeps.include.includes("feathers-pinia"))
|
|
138
|
+
mutableConfig.optimizeDeps.include.push("feathers-pinia");
|
|
138
139
|
});
|
|
139
140
|
const enableAuthBootstrap = Boolean(
|
|
140
141
|
resolvedOptions.auth && serverEnabled || isResolvedRemoteAuthEnabled(resolvedOptions)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ServiceTypes } from 'nuxt-feathers-zod/client';
|
|
2
2
|
export declare function useFeathers(): {
|
|
3
3
|
api: unknown;
|
|
4
4
|
client: ClientApplication;
|
|
5
5
|
};
|
|
6
|
-
export declare function useService<L extends keyof ServiceTypes>(path: L):
|
|
6
|
+
export declare function useService<L extends keyof ServiceTypes>(path: L): any;
|
|
@@ -95,8 +95,12 @@ export function useAuth() {
|
|
|
95
95
|
async function login(options) {
|
|
96
96
|
if (provider.value === "keycloak")
|
|
97
97
|
return keycloak.value?.login?.(options);
|
|
98
|
-
if (provider.value === "local")
|
|
99
|
-
|
|
98
|
+
if (provider.value === "local") {
|
|
99
|
+
const store = authStore.value;
|
|
100
|
+
if (typeof store?.login === "function")
|
|
101
|
+
return store.login(options);
|
|
102
|
+
return store?.authenticate?.(options);
|
|
103
|
+
}
|
|
100
104
|
if (provider.value === "remote") {
|
|
101
105
|
const pub2 = useRuntimeConfig().public;
|
|
102
106
|
const ra = getPublicRemoteAuthConfig(pub2);
|
|
@@ -110,10 +114,8 @@ export function useAuth() {
|
|
|
110
114
|
async function logout(options) {
|
|
111
115
|
if (provider.value === "keycloak")
|
|
112
116
|
return keycloak.value?.logout?.(options);
|
|
113
|
-
if (provider.value === "local")
|
|
114
|
-
return authStore.value?.logout?.(
|
|
115
|
-
if (provider.value === "remote")
|
|
116
|
-
return authStore.value?.logout?.(options);
|
|
117
|
+
if (provider.value === "local" || provider.value === "remote")
|
|
118
|
+
return authStore.value?.logout?.();
|
|
117
119
|
}
|
|
118
120
|
return {
|
|
119
121
|
provider,
|
|
@@ -5,8 +5,30 @@ type PickSerializable<T> = {
|
|
|
5
5
|
interface MongoUrlOption {
|
|
6
6
|
url: string;
|
|
7
7
|
}
|
|
8
|
+
export interface MongoManagementOptions {
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
auth?: boolean;
|
|
11
|
+
exposeDatabasesService?: boolean;
|
|
12
|
+
exposeCollectionsService?: boolean;
|
|
13
|
+
exposeUsersService?: boolean;
|
|
14
|
+
exposeCollectionCrud?: boolean;
|
|
15
|
+
basePath?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ResolvedMongoManagementOptions {
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
auth: boolean;
|
|
20
|
+
exposeDatabasesService: boolean;
|
|
21
|
+
exposeCollectionsService: boolean;
|
|
22
|
+
exposeUsersService: boolean;
|
|
23
|
+
exposeCollectionCrud: boolean;
|
|
24
|
+
basePath: string;
|
|
25
|
+
}
|
|
8
26
|
type SerializableMongoClientOptions = PickSerializable<MongoClientOptions>;
|
|
9
|
-
export type MongoOptions = MongoUrlOption & SerializableMongoClientOptions
|
|
10
|
-
|
|
27
|
+
export type MongoOptions = MongoUrlOption & SerializableMongoClientOptions & {
|
|
28
|
+
management?: MongoManagementOptions;
|
|
29
|
+
};
|
|
30
|
+
export type ResolvedMongoOptions = MongoUrlOption & SerializableMongoClientOptions & {
|
|
31
|
+
management: ResolvedMongoManagementOptions;
|
|
32
|
+
};
|
|
11
33
|
export declare function resolveMongoOptions(mongodb: MongoOptions): ResolvedMongoOptions;
|
|
12
34
|
export {};
|
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
export function resolveMongoOptions(mongodb) {
|
|
2
|
-
|
|
2
|
+
const basePath = mongodb.management?.basePath || "/mongo";
|
|
3
|
+
return {
|
|
4
|
+
...mongodb,
|
|
5
|
+
management: {
|
|
6
|
+
enabled: mongodb.management?.enabled === true,
|
|
7
|
+
auth: mongodb.management?.auth !== false,
|
|
8
|
+
exposeDatabasesService: mongodb.management?.exposeDatabasesService !== false,
|
|
9
|
+
exposeCollectionsService: mongodb.management?.exposeCollectionsService !== false,
|
|
10
|
+
exposeUsersService: mongodb.management?.exposeUsersService === true,
|
|
11
|
+
exposeCollectionCrud: mongodb.management?.exposeCollectionCrud !== false,
|
|
12
|
+
basePath: basePath.startsWith("/") ? basePath : `/${basePath}`
|
|
13
|
+
}
|
|
14
|
+
};
|
|
3
15
|
}
|
|
@@ -16,19 +16,19 @@ export async function resolveOptions(options, nuxt) {
|
|
|
16
16
|
const srcDir = nuxt.options.srcDir;
|
|
17
17
|
const servicesDirs = resolveServicesDirs(options.servicesDirs, rootDir);
|
|
18
18
|
const templateDir = createResolver(nuxt.options.buildDir).resolve("feathers");
|
|
19
|
-
const transports = resolveTransportsOptions(options.transports);
|
|
19
|
+
const transports = resolveTransportsOptions(options.transports, nuxt.options.ssr);
|
|
20
20
|
const database = resolveDataBaseOptions(options.database);
|
|
21
21
|
const server = await resolveServerOptions(options.server, rootDir, srcDir);
|
|
22
|
-
const client = await resolveClientOptions(options.client, database.mongo, rootDir, srcDir);
|
|
22
|
+
const client = await resolveClientOptions(options.client, Boolean(database.mongo), rootDir, srcDir);
|
|
23
23
|
const validator = resolveValidatorOptions(options.validator);
|
|
24
|
-
const swagger = resolveSwaggerOptions(options.swagger);
|
|
24
|
+
const swagger = resolveSwaggerOptions(options.swagger, transports);
|
|
25
25
|
const templates = resolveTemplatesOptions(options.templates, rootDir);
|
|
26
|
-
const servicesImports = getResolvedClientMode(
|
|
26
|
+
const servicesImports = getResolvedClientMode(client) === "embedded" ? await getServicesImports(servicesDirs) : [];
|
|
27
27
|
const auth = resolveAuthOptions(
|
|
28
28
|
options.auth,
|
|
29
29
|
{
|
|
30
30
|
client: Boolean(client),
|
|
31
|
-
mode: client && isRemoteClientMode(
|
|
31
|
+
mode: client && isRemoteClientMode(client) ? "remote" : "embedded"
|
|
32
32
|
},
|
|
33
33
|
servicesImports,
|
|
34
34
|
rootDir
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import { createResolver } from "@nuxt/kit";
|
|
3
|
+
import { consola } from "consola";
|
|
2
4
|
import { scanDirExports, scanExports } from "unimport";
|
|
3
5
|
import { filterExports, setImportsMeta } from "./utils.js";
|
|
4
6
|
function forceArray(value) {
|
|
@@ -27,7 +29,14 @@ export function resolvePluginDirs(pluginDirs, rootDir, defaultDir) {
|
|
|
27
29
|
return resolvedPluginDirs.map((dir) => rootResolver.resolve(dir));
|
|
28
30
|
}
|
|
29
31
|
export async function resolvePluginsFromPluginDirs(pluginDirs) {
|
|
30
|
-
const
|
|
32
|
+
const existingPluginDirs = pluginDirs.filter((dir) => existsSync(dir));
|
|
33
|
+
const missingPluginDirs = pluginDirs.filter((dir) => !existsSync(dir));
|
|
34
|
+
for (const dir of missingPluginDirs) {
|
|
35
|
+
consola.debug(`[nuxt-feathers-zod] Skipping missing plugin directory: ${dir}`);
|
|
36
|
+
}
|
|
37
|
+
if (!existingPluginDirs.length)
|
|
38
|
+
return [];
|
|
39
|
+
const imports = await scanDirExports(existingPluginDirs, {
|
|
31
40
|
filePatterns: ["*.ts"],
|
|
32
41
|
types: false
|
|
33
42
|
});
|
|
@@ -135,7 +135,7 @@ function buildSecureServerModules(server) {
|
|
|
135
135
|
if (hasMeaningfulValue(compression))
|
|
136
136
|
push("compression", compression);
|
|
137
137
|
const serveStatic = secure.serveStatic;
|
|
138
|
-
if (serveStatic
|
|
138
|
+
if (serveStatic)
|
|
139
139
|
push("serve-static", serveStatic);
|
|
140
140
|
return out;
|
|
141
141
|
}
|
|
@@ -11,9 +11,11 @@ export function resolveWebsocketTransportsOptions(websocket) {
|
|
|
11
11
|
if (websocket === true || websocket === void 0) {
|
|
12
12
|
resolvedWebsocket = websocketDefaults;
|
|
13
13
|
} else if (websocket !== false) {
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
|
|
14
|
+
const merged = defu(websocket, websocketDefaults);
|
|
15
|
+
if (merged.cors == null)
|
|
16
|
+
delete merged.cors;
|
|
17
|
+
resolvedWebsocket = merged;
|
|
18
|
+
checkPath(merged.path);
|
|
17
19
|
}
|
|
18
20
|
return resolvedWebsocket;
|
|
19
21
|
}
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
* IMPORTANT: we guard on `nuxtApp.$pinia` instead of declaring a plugin dependsOn,
|
|
11
11
|
* to avoid noisy build-time warnings when Pinia is enabled dynamically by the module.
|
|
12
12
|
*/
|
|
13
|
-
declare const _default:
|
|
13
|
+
declare const _default: any;
|
|
14
14
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: any;
|
|
2
2
|
export default _default;
|
|
@@ -9,6 +9,7 @@ export function getServerAppContents(options) {
|
|
|
9
9
|
const sio = !!transports?.websocket;
|
|
10
10
|
const authStrategies = options?.auth?.authStrategies;
|
|
11
11
|
const auth = (authStrategies || []).length > 0;
|
|
12
|
+
const mongo = !!options.database?.mongo;
|
|
12
13
|
const restPath = transports?.rest?.path;
|
|
13
14
|
const websocketOptions = transports?.websocket || void 0;
|
|
14
15
|
const websocketPath = JSON.stringify(websocketOptions?.path ?? "/socket.io");
|
|
@@ -27,6 +28,8 @@ ${puts([
|
|
|
27
28
|
[sio, `import socketio from '@feathersjs/socketio'`]
|
|
28
29
|
])}
|
|
29
30
|
${put(rest, `import { ${framework}ErrorHandler } from '@gabortorma/feathers-nitro-adapter/handlers'`)}
|
|
31
|
+
${put(auth, `import authentication from './authentication.js'`)}
|
|
32
|
+
${put(mongo, `import mongodb from './mongodb.js'`)}
|
|
30
33
|
|
|
31
34
|
export async function createFeathersApp(nitroApp, config) {
|
|
32
35
|
const app = ${puts([
|
|
@@ -62,6 +65,22 @@ ${websocketConnectTimeout}${websocketTransports}${websocketCors} }))
|
|
|
62
65
|
|
|
63
66
|
return app
|
|
64
67
|
}
|
|
68
|
+
|
|
69
|
+
export async function configureFeathersInfrastructure(app, config) {
|
|
70
|
+
const mongoConfig = config?.database?.mongo
|
|
71
|
+
const mongoEnabled = !!(mongoConfig && mongoConfig.enabled && mongoConfig.url)
|
|
72
|
+
|
|
73
|
+
if (mongoEnabled) {
|
|
74
|
+
app.set('mongodb', mongoConfig.url)
|
|
75
|
+
app.set('mongoPath', mongoConfig.management?.basePath || '/mongo')
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
${put(auth, ` if (config?.auth?.enabled !== false)
|
|
79
|
+
await app.configure(authentication)
|
|
80
|
+
|
|
81
|
+
`)}${put(mongo, ` if (mongoEnabled)
|
|
82
|
+
await mongodb(app)
|
|
83
|
+
`)} }
|
|
65
84
|
`;
|
|
66
85
|
};
|
|
67
86
|
}
|
|
@@ -31,7 +31,7 @@ ${put(oauth, ` app.configure(oauth())
|
|
|
31
31
|
before: {
|
|
32
32
|
create: [
|
|
33
33
|
async (context) => {
|
|
34
|
-
const d
|
|
34
|
+
const d = context.data
|
|
35
35
|
if (d && typeof d === 'object') {
|
|
36
36
|
// access_token -> accessToken
|
|
37
37
|
if (d.access_token && !d.accessToken)
|
|
@@ -47,11 +47,6 @@ ${put(oauth, ` app.configure(oauth())
|
|
|
47
47
|
})
|
|
48
48
|
})
|
|
49
49
|
|
|
50
|
-
declare module './server' {
|
|
51
|
-
interface ServiceTypes {
|
|
52
|
-
authentication: AuthenticationService
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
50
|
`;
|
|
56
51
|
};
|
|
57
52
|
}
|
|
@@ -4,47 +4,53 @@ import { getServerKeycloakContents } from "./keycloak.js";
|
|
|
4
4
|
import { getServerMongodbContents } from "./mongodb.js";
|
|
5
5
|
import { getServerPluginContents } from "./plugin.js";
|
|
6
6
|
import { getSecureDefaultsModuleContents } from "./secure-defaults.js";
|
|
7
|
-
import {
|
|
7
|
+
import { getServerRuntimeContents } from "./server-runtime.js";
|
|
8
|
+
import { getServerTypesContents } from "./server-types.js";
|
|
8
9
|
export function getServerTemplates(options) {
|
|
9
10
|
const serverTemplates = [
|
|
10
11
|
{
|
|
11
|
-
filename: "feathers/server/server.
|
|
12
|
-
getContents:
|
|
12
|
+
filename: "feathers/server/server.js",
|
|
13
|
+
getContents: getServerRuntimeContents(options),
|
|
13
14
|
write: true
|
|
14
15
|
},
|
|
15
16
|
{
|
|
16
|
-
filename: "feathers/server/
|
|
17
|
+
filename: "feathers/server/server.d.ts",
|
|
18
|
+
getContents: getServerTypesContents(options),
|
|
19
|
+
write: true
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
filename: "feathers/server/app.js",
|
|
17
23
|
getContents: getServerAppContents(options),
|
|
18
24
|
write: true
|
|
19
25
|
},
|
|
20
26
|
{
|
|
21
|
-
filename: "feathers/server/modules/secure-defaults.
|
|
27
|
+
filename: "feathers/server/modules/secure-defaults.js",
|
|
22
28
|
getContents: getSecureDefaultsModuleContents(options),
|
|
23
29
|
write: true
|
|
24
30
|
},
|
|
25
31
|
{
|
|
26
|
-
filename: "feathers/server/plugin.
|
|
32
|
+
filename: "feathers/server/plugin.js",
|
|
27
33
|
getContents: getServerPluginContents(options),
|
|
28
34
|
write: true
|
|
29
35
|
}
|
|
30
36
|
];
|
|
31
37
|
if (options.database.mongo) {
|
|
32
38
|
serverTemplates.push({
|
|
33
|
-
filename: "feathers/server/mongodb.
|
|
39
|
+
filename: "feathers/server/mongodb.js",
|
|
34
40
|
getContents: getServerMongodbContents(options),
|
|
35
41
|
write: true
|
|
36
42
|
});
|
|
37
43
|
}
|
|
38
44
|
if (options.auth) {
|
|
39
45
|
serverTemplates.push({
|
|
40
|
-
filename: "feathers/server/authentication.
|
|
46
|
+
filename: "feathers/server/authentication.js",
|
|
41
47
|
getContents: getServerAuthContents(options),
|
|
42
48
|
write: true
|
|
43
49
|
});
|
|
44
50
|
}
|
|
45
51
|
if (options.keycloak) {
|
|
46
52
|
serverTemplates.push({
|
|
47
|
-
filename: "feathers/server/keycloak.
|
|
53
|
+
filename: "feathers/server/keycloak.js",
|
|
48
54
|
getContents: getServerKeycloakContents(options),
|
|
49
55
|
write: true
|
|
50
56
|
});
|