{"id":17204685,"url":"https://github.com/aexol/syncano-middleware-validate","last_synced_at":"2025-03-25T09:43:37.670Z","repository":{"id":57095421,"uuid":"122483210","full_name":"aexol/syncano-middleware-validate","owner":"aexol","description":"Validation of data","archived":false,"fork":false,"pushed_at":"2018-03-08T11:54:11.000Z","size":399,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-01T04:12:44.437Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aexol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-22T13:37:22.000Z","updated_at":"2018-02-22T14:05:24.000Z","dependencies_parsed_at":"2022-08-22T23:10:25.881Z","dependency_job_id":null,"html_url":"https://github.com/aexol/syncano-middleware-validate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aexol%2Fsyncano-middleware-validate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aexol%2Fsyncano-middleware-validate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aexol%2Fsyncano-middleware-validate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aexol%2Fsyncano-middleware-validate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aexol","download_url":"https://codeload.github.com/aexol/syncano-middleware-validate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245437268,"owners_count":20615239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T02:22:48.863Z","updated_at":"2025-03-25T09:43:37.646Z","avatar_url":"https://github.com/aexol.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Syncano Middleware Validate\n\n## About\n\nLibrary used to validate socket input based on socket.yml.\n\n## Installation\n```\nnpm install @aexol/syncano-middleware-validate\n```\n\n## Usage\n\nThis library depends on syncano-middleware lib. The basic socket example is\n\n### socket.yml\n\n```yaml\nname: example\ndescription: Description of example\nversion: 0.1.0\nruntime: nodejs_v8\nendpoints:\n  hello:\n    response:\n      success:\n        mimetype: application/json\n        exit_code: 200\n```\n\n```javascript\nimport serve, {response} from '@aexol/syncano-middleware';\nimport validate from '@aexol/syncano-middleware-validate';\n\nasync function run(ctx, syncano) {\n    return response.success({message: 'Hello world'})\n}\n\nexport default ctx =\u003e serve(ctx, validate(run))\n```\n\nInput schema validation must be in inputs key.\n\nInputs can contain either method name objects (GET, POST, PUT, DELETE) or\ncommon schema for all cases.\n\n```yaml\nendpoints:\n  hello:\n    inputs:\n      GET:\n        properties:\n          world:\n            type: string\n        required:\n          - world\n```\n\n## Available schemas\n* #/ (https://{instanceName}.syncano.space/${socketName}) - Your socket.yml as schema\n* http://local/meta - Metadata as a schema. In case of missing socket.yml schema this becomes your root schema.\n* {schemaName}#/ - Extra schema for any schemas defined in `schemas` property of socket.yml. `schemas` property must be an object of key: value pairs where value must be either valid JSON Schema object or file containing schema in src directory of socket.\n\nTo use model from socket for example you can do this:\n\n```yaml\nendpoints:\n  hello:\n    inputs:\n      GET:\n        $ref: '#/Model'\nModel:\n  type: object\n  properties:\n    world:\n      type: string\n  required:\n    - world\n```\n\nTo use extra schemas you can do:\n\nsocket.yml:\n```yaml\nendpoints:\n  hello:\n    inputs:\n      GET:\n        $ref: 'main#/Model'\nschemas:\n  main: schema.yml\n```\n\nsrc/schema.yml\n```yaml\nModel:\n  type: object\n  properties:\n    world:\n      type: string\n  required:\n    - world\n```\n\nTODO:\n* Support extension detection for extra schemas.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faexol%2Fsyncano-middleware-validate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faexol%2Fsyncano-middleware-validate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faexol%2Fsyncano-middleware-validate/lists"}