Browse Source

refactor code, nuxt 4

pull/2399/head
Bernd Storath 5 months ago
committed by Bernd Storath
parent
commit
90176d5cba
  1. 4
      src/i18n/locales/en.json
  2. 9
      src/nuxt.config.ts
  3. 2
      src/package.json
  4. 1423
      src/pnpm-lock.yaml
  5. 3
      src/server/database/repositories/user/types.ts
  6. 3
      src/server/tsconfig.json
  7. 20
      src/server/utils/types.ts
  8. 8
      src/tsconfig.json

4
src/i18n/locales/en.json

@ -196,7 +196,9 @@
"validBoolean": "{0} must be a valid boolean",
"validArray": "{0} must be a valid array",
"stringMin": "{0} must be at least {1} Character",
"numberMin": "{0} must be at least {1}"
"stringMax": "{0} must be at most {1} Character",
"numberMin": "{0} must be at least {1}",
"numberMax": "{0} must be at most {1}"
},
"client": {
"id": "Client ID",

9
src/nuxt.config.ts

@ -2,10 +2,7 @@ import { fileURLToPath } from 'node:url';
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
future: {
compatibilityVersion: 4,
},
compatibilityDate: '2026-02-06',
compatibilityDate: '2026-06-03',
devtools: { enabled: true },
modules: [
'@nuxtjs/i18n',
@ -166,15 +163,11 @@ export default defineNuxtConfig({
target: 'node20',
},
},
alias: {
'#db': fileURLToPath(new URL('./server/database/', import.meta.url)),
},
externals: {
traceInclude: [fileURLToPath(new URL('./cli/index.ts', import.meta.url))],
},
},
alias: {
// for typecheck reasons (https://github.com/nuxt/cli/issues/323)
'#db': fileURLToPath(new URL('./server/database/', import.meta.url)),
},
});

2
src/package.json

@ -42,7 +42,7 @@
"is-cidr": "^7.0.0",
"is-ip": "^5.0.1",
"js-sha256": "^0.11.1",
"nuxt": "^3.21.6",
"nuxt": "^4.4.6",
"obug": "^2.1.1",
"otpauth": "^9.5.1",
"pinia": "^3.0.4",

1423
src/pnpm-lock.yaml

File diff suppressed because it is too large

3
src/server/database/repositories/user/types.ts

@ -44,9 +44,8 @@ const name = z
.pipe(safeStringRefine);
const email = z
.string({ message: t('zod.user.email') })
.min(5, t('zod.user.email'))
.email({ message: t('zod.user.emailInvalid') })
.min(5, t('zod.user.email'))
.pipe(safeStringRefine)
.nullable();

3
src/server/tsconfig.json

@ -1,3 +0,0 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}

20
src/server/utils/types.ts

@ -1,4 +1,4 @@
import type { ZodSchema } from 'zod';
import type { ZodType } from 'zod';
import z from 'zod';
import type { H3Event, EventHandlerRequest } from 'h3';
import { isIP } from 'is-ip';
@ -168,7 +168,7 @@ export const schemaForType =
};
export function validateZod<T>(
schema: ZodSchema<T>,
schema: ZodType<T>,
event: H3Event<EventHandlerRequest>
) {
return async (data: unknown) => {
@ -203,6 +203,22 @@ export function validateZod<T>(
break;
}
break;
case 'too_big':
switch (v.origin) {
case 'string':
newMessage = t('zod.generic.stringMax', [
t(v.message),
v.maximum,
]);
break;
case 'number':
newMessage = t('zod.generic.numberMax', [
t(v.message),
v.maximum,
]);
break;
}
break;
case 'invalid_type': {
if (v.input === null || v.input === undefined) {
newMessage = t('zod.generic.required', [

8
src/tsconfig.json

@ -1,4 +1,10 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
"files": [],
"references": [
{ "path": "./.nuxt/tsconfig.app.json" },
{ "path": "./.nuxt/tsconfig.server.json" },
{ "path": "./.nuxt/tsconfig.shared.json" },
{ "path": "./.nuxt/tsconfig.node.json" }
]
}

Loading…
Cancel
Save