-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add account, nonce, and user schemas, and mock Postgres #285
Conversation
3f75041
to
ad83c4d
Compare
ad83c4d
to
3af8805
Compare
@ccali11 also added a seed script to
With some optimization as we go, this can become much faster and convenient with better database bootstrapping and type generation (@hawyar is looking into schema-to-type generation). |
This sets great foundation for schema changes and using the JSON schema allows us to safely generate TS types. I have a working example that works with all our current schemas. To generate correct types for properties of type Example: "snapshot": {
"type": "array",
"description": "The account snapshots",
"items": {
"type": "object",
"properties": {
"date": {
"type": "string",
"description": "The date of the snapshot in ISO 8601 format"
},
"balance": {
"type": "number",
"description": "The balance of the snapshot"
},
"anotherprop": {
"type": "string"
},
},
"required": [
"date",
"balance"
]
}
} and the type output would look something similar to: interface Snapshot {
date: string;
balance: number;
}
interface Account {
snapshots: Array<Snapshot>;
transactions: string[];
// the rest
} |
@hawyar Great! Thank you and nice work. Thinking one other PR will also be to move some of this typegen logic into @casimir/data (or the existing @casimir/types, since that would be a nice place to output types), and then hook into the existing workflow (in the repo prepare and dev scripts for convenience). Happy to plug in the last part if you take up the first (maybe a PR off of this branch or after it's merged). |
Sounds good. After this is merged I will add typegen and update the rest of the schema as needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shanejearley @hawyar Looks great, guys. Will dive into this with my tasks this week and note any opportunities for changes/improvements.
Ready to review workflow and merge whenever. Schema reloads will be slow but will become much faster once we add proper migrations for schemas (which will be required when we add the deployment infra anyways). |
@shanejearley - did you want a sync review before merging? up to you. |
See the @casimir/data README for background (and ignore the Jupyter notebooks).
For convenient iteration, running
npm run dev
(scripts/local/dev.ts) now hitsnpm run watch:postgres --workspace @casimir/data
when local mock is enabled (default). The database reloads any changes from the @casimir/data schema files.See a usage example in the @casimir/users service
/user
route (getUser from useDB).Remaining task(s):
Infrastructure, migrations, and environment variables are coming in a PR next week.