Skip to content
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

The port option should be either number or string type #13025

Closed
2 of 7 tasks
mattdeluco opened this issue Feb 11, 2021 · 2 comments
Closed
2 of 7 tasks

The port option should be either number or string type #13025

mattdeluco opened this issue Feb 11, 2021 · 2 comments
Labels

Comments

@mattdeluco
Copy link

Issue Description

The port option should accept both strings and numbers. The NodeJS URL
API defines port as a string, where this value ultimately ends up.

It should not be necessary to parseInt(process.env.PORT), for example.

What are you doing?

I am trying to create an instance of Sequelize, configuring the port for the connection using an environment variable process.env.PORT.

import { Sequelize } from 'sequelize';

const seq = new Sequelize({
  port: process.env.PORT || '5432'
});

What do you expect to happen?

I wanted to use environment variables for the port option

What is actually happening?

I am having to use parseInt() to convert a string to a number

No overload matches this call.
  Overload 1 of 4, '(options?: Options): Sequelize', gave the following error.
    Type 'string' is not assignable to type 'number'.
  Overload 2 of 4, '(uri: string, options?: Options): Sequelize', gave the following error.
    Argument of type '{ port: string; }' is not assignable to parameter of type 'string'.ts(2769)
sequelize.d.ts(239, 3): The expected type comes from property 'port' which is declared here on type 'Options'

Additional context

Environment

  • Sequelize version: 4063c2a
  • Node.js version: v14.5.0
  • Operating System: macOS 11.1
  • If TypeScript related: TypeScript version: XXX

Issue Template Checklist

How does this problem relate to dialects?

  • I think this problem happens regardless of the dialect.
  • I think this problem happens only for the following dialect(s):
  • I don't know, I was using PUT-YOUR-DIALECT-HERE, with connector library version XXX and database version XXX

Would you be willing to resolve this issue by submitting a Pull Request?

I have created draft pull request #13024, I do not have time to carry it further.

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I don't know how to start, I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.
@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

@arman-amiri
Copy link

port: Number(process.env?.DB_PORT),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants