export const handleCreateSpace = async (props: CreateSpaceProps) => {
try {
const { apiKey, map, name, reason, sourceSpace } = await createSpaceSchema.validate(props);
// here we handle if everything else is okay
} catch (err) {
// here we throw the validation errors as well as the errors from gathertowns' endpoint
const error: any = err;
throw new Error(error.message);
}
this PR resolves #21
How it works
create a schema for each request:
then validate the passed props in each request: