Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Client schemas #24

Closed
wants to merge 4 commits into from
Closed

WIP: Client schemas #24

wants to merge 4 commits into from

Conversation

SomeoneWeird
Copy link
Member

This PR will (eventually) allow clients to pull, and cache remote method schemas, so data can be locally validated before being sent to the server.

@joshgillies
Copy link
Member

So nice! Will see if I can make the time to offer a hand with this. 👍

@SomeoneWeird
Copy link
Member Author

ref: #22

So, for this I’m thinking client.fetchSchemas(true/false)
and either: when you call a new method, it goes off and asynchronously fetches the schema for that
or: we add an endpoint that lets you request all remote methods for a service, then fetch all the schemas up front.

@SomeoneWeird
Copy link
Member Author

Alright, I think this is nearly done.

Couple more changes needed (actually making it validate against the local schemas before it attempts a req)

Client.requestSchemas() can take an optional object, which allows you to map custom schema types against remote services.

If your remote service s1 is using JSON schema (using ht-tv4) and s2 is using Joi, you can do something like:

client.requestSchemas({
  s1: httv4,
  s2: htjoi
});

So the local service knows how to generate the 'stringified' schemas back into functions it can use to validate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants