[🧹] Rewrite sequelize models in proper TypeScript
See original GitHub issueA significant amount of remaining TypeScript errors comes from the way the Sequelize models are currently defined and created. The models defined in /models
as well as the dynamic creation in /models/index.ts
should be rewritten in TypeScript-style.
Recommended steps
- Inspect files in https://github.com/juice-shop/juice-shop/tree/master/models to understand the current implementation
- Run
npm run build:server
and analyze TypeScript errors for function calls onmodels.Challenges
,models.User
and other models - Read https://sequelize.org/master/manual/typescript.html to understand implementation recommended by Seqeuelize
- Identify necessary migration steps
- Gradually migrate all models and adapt all places where they are used to the new implementation
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
TypeScript - Sequelize
We're working hard on making Sequelize a breeze to use in TypeScript. ... Sequelize Models accept two generic types to define what the...
Read more >Using Sequelize with TypeScript - LogRocket Blog
Sequelize provides two ways to register models: using sequelize.define or extending the Sequelize model class. In this tutorial, we'll use the ...
Read more >Sequelize + TypeScript - What you need to know
Sequelize -typescript package is very helpful, it allows to define model with decorators and transpiles into easily usable objects to pass ...
Read more >sequelize-typescript - npm
With the creation of a relation, sequelize generates some method on the corresponding models. So when you create a 1:n relation between ModelA ......
Read more >How to use TypeScript with Sequelize - node.js - Stack Overflow
`./src/models/index.ts` import * as sequelize from "sequelize"; import {userFactory} from ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Upgrading is fine, as long as we do not accidentally fix the SQL Injection challenges by doing so.
ℹ️ Please make sure to rebase with origin develop before opening a PR, because I’ve been doing some TypeScript conversion as well, and those definitely affect some of the same files. It’s mostly parameter typing etc.