import Errors from '@feathersjs/errors';
import Ajv from 'ajv';
import { validateSchema } from 'feathers-hooks-common';
import jsonSchema from '@lemonpeach/sequelize-to-json-schema';
const getSchema = context => jsonSchema(
context.service.Model,
['createdAt', 'updatedAt', 'id']
);
export const validateSchemaHook = async (
context,
schema = getSchema(context)
) => {
try {
switch (context.method) {
case 'patch':
case 'update':
schema.required = [];
/* eslint no-fallthrough: "error" */
case 'create':
await validateSchema(schema, new Ajv())(context);
break;
default:
break;
}
} catch (error) {
// handle error
}
return context;
};
-
Notifications
You must be signed in to change notification settings - Fork 0
Convert Sequelize models to their JSON schema representation.
License
Lemonpeach/sequelize-to-json-schema
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Convert Sequelize models to their JSON schema representation.
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published