storyblocks-schema-tool

Tool used by the Storyblocks team to register event schemas

Usage no npm install needed!

<script type="module">
  import storyblocksSchemaTool from 'https://cdn.skypack.dev/storyblocks-schema-tool';
</script>

README

Storyblocks Schema Tool

Quick Start

Install the schema tool:

npm i -S storyblocks-schema-tool

Create a config file in your project, for example schemas.yml

staging:
  env: 'staging'
  schemasPath: './events/schemas'
  registryUrl: 'http://schema-registry-staging.mysite.com'
  apiKey: 'api_key_goes_here'

prod:
  env: 'prod'
  schemasPath: './events/schemas'
  registryUrl: 'http://schema-registry-prod.mysite.com'
  apiKey: 'api_key_goes_here'

The schema tool requires 2 parameters, env (staging, prod, etc) and config (path to the config)

The easiest way to use this tool is to add scripts to your project's package.json

"scripts": {
  "register-schemas:staging": "register-schemas --config ./path/to/schemas.yml --env staging"
  "register-schemas:prod": "register-schemas --config ./path/to/schemas.yml --env prod"
}

and then running them via npm

npm run register-schemas:staging
npm run register-schemas:prod

Notes

The schema tool expects the schemas directory to be laid out like so:

MySite
    ├── TestEvent1
    │   └── jsonschema
    │       └── 1.0.2 <- this file contains the schema
    └── TestEvent2
        └── jsonschema
            └── 1.0.5
            
MyOtherSite
    ├── TestEvent3
    │   └── jsonschema
    │       └── 2.0.0
    └── TestEvent4
        └── jsonschema
            └── 1.5.2

Todo

  • add tests
  • ???
  • profit!