question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[🧹] Rewrite sequelize models in proper TypeScript

See original GitHub issue

A 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

  1. Inspect files in https://github.com/juice-shop/juice-shop/tree/master/models to understand the current implementation
  2. Run npm run build:server and analyze TypeScript errors for function calls on models.Challenges, models.User and other models
  3. Read https://sequelize.org/master/manual/typescript.html to understand implementation recommended by Seqeuelize
  4. Identify necessary migration steps
  5. Gradually migrate all models and adapt all places where they are used to the new implementation

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
bkimminichcommented, Feb 8, 2022

Upgrading is fine, as long as we do not accidentally fix the SQL Injection challenges by doing so.

1reaction
bkimminichcommented, Feb 16, 2022

ℹ️ 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found