@aimee-blue/ab-contracts

Transport layer types and schemas shared by clients, services and serverless functions

Usage no npm install needed!

<script type="module">
  import aimeeBlueAbContracts from 'https://cdn.skypack.dev/@aimee-blue/ab-contracts';
</script>

README

Aimee-Blue Client/Server/Functions Contract

Structure

schemas
  {feature}
    funcParam1.ts    <-- types specific to function params
    action1.ts       <-- types specific to actions
    type1.ts         <-- types specific to entity (e.g. re-used by params/actions ^ above)
    ...
    api.ts               <-- all types above collected into API interface
    index.ts             <-- reexport all dir types for namespacing
  ...
  index.ts  <-- reexport all features

Examples?

Looking for examples - dig deeper into code.

Conventions

  1. Do not put code that is specific only to Functions or only to Client. The purpose of this repo is to define a contract between them.

  2. Do not share code between feature modules. Subsequent changes to contract of a module should not break other module contracts. Copy-paste is good in this case.

  3. Difference between Action and Params:

    • Action - received in PubSub stream by client

    • Params - received as parameter to function

  4. Please try to suffix your types with Shape. Suffix your schemas with Schema. Suffix function params with Params and suffix action schemas with ActionSchema.

  5. Typically whenever a feature is being developed by more than one dev - any changes to schemas directory should be approved by both FE and BE devs developing the feature

Happy coding!