- Delete old Vite+Svelte frontend - Initialize new SvelteKit project with TypeScript - Configure Tailwind CSS v4 + DaisyUI - Implement JWT authentication with auto-refresh - Create login page with form validation (Zod) - Add protected route guards - Update Docker configuration for single-stage build - Add E2E tests with Playwright (6/11 passing) - Fix Svelte 5 reactivity with $state() runes Known issues: - 5 E2E tests failing (timing/async issues) - Token refresh implementation needs debugging - Validation error display timing
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import { createAdapter, createJsonSchema } from './adapters.js';
|
|
import { memoize } from '../memoize.js';
|
|
async function validate(schema, data) {
|
|
const result = schema.validate(data, { coerce: true });
|
|
if (!result[0]) {
|
|
return {
|
|
data: result[1],
|
|
success: true
|
|
};
|
|
}
|
|
const errors = result[0];
|
|
return {
|
|
success: false,
|
|
issues: errors.failures().map((error) => ({
|
|
message: error.message,
|
|
path: error.path
|
|
}))
|
|
};
|
|
}
|
|
function _superstruct(schema, options) {
|
|
return createAdapter({
|
|
superFormValidationLibrary: 'superstruct',
|
|
defaults: options.defaults,
|
|
jsonSchema: createJsonSchema(options),
|
|
validate: async (data) => validate(schema, data)
|
|
});
|
|
}
|
|
function _superstructClient(schema) {
|
|
return {
|
|
superFormValidationLibrary: 'superstruct',
|
|
validate: async (data) => validate(schema, data)
|
|
};
|
|
}
|
|
export const superstruct = /* @__PURE__ */ memoize(_superstruct);
|
|
export const superstructClient = /* @__PURE__ */ memoize(_superstructClient);
|