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.

How can development and production modes be separated?

See original GitHub issue

Issue type:

[ O ] question [ ] bug report [ ] feature request [ ] documentation issue

TypeORM version:

[ O ] latest [ ] @next [ ] 0.x.x (or put your version here)

I want to divide the development and deployment mode into .env files or ormconfig.json.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

15reactions
kieuminhcanhcommented, Sep 14, 2019

I recommended use ormconfig.js to setting.

ormconfig.js

const rootDir = process.env.NODE_ENV === "development" ?
  "src" :
  "build/src"

module.exports = {
  ...
  "entities": [rootDir + "/entities/**/*.{js,ts}"],
  "migrations": [rootDir + "/migrations/*.{js,ts}"],
  "subscribers": [rootDir + "/subscribers/**/*.{js,ts}"],
  "seeds": [rootDir + "/migrations/seeds/**/*.{js,ts}"],
  "factories": [rootDir + "/migrations/factories/**/*.{js,ts}"],
  ...
}

tsconfig.json

{
  "compilerOptions": {
    ...
    "outDir": "./build",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    ...
  },
  ...
}

And then, update your scripts in package.json package.json

"scripts": {
    "start": "set debug=* && ts-node-dev --respawn --transpileOnly ./src/index.ts",
    "prod": "tsc && node ./build/src/index.js",    <== Focus to this line
  }
4reactions
Kononnablecommented, Dec 2, 2018

@havenchyk I’m not sure if this should be added to documentation, maybe as an example. This can be achieved many different ways and it’s not completely typeorm problem.

But to be honest I don’t like an idea of ormconfig file at all. It is good for CLI but I think libraries shouldn’t have specific configurations files - configuration should be provided by the application which uses library and should be kept with other app configuration options.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How-to | Separation of Production and Development ...
This tutorial explains some of the key considerations when deciding how to separate your development, test, and production infrastructure ...
Read more >
Separation of machine learning environments | by Kevin Du
During the model building phase, DS / MLE need to have access to “real” data, the environment could be an exploration environment, but...
Read more >
Why separate Production and Test infrastructures - LinkedIn
1- Remove development, test and/or custom application accounts, user IDs, and passwords before applications become active or are released to ...
Read more >
How can we keep separation between development team ...
The notion that DevOps means that development teams or developers need access to production systems, go into an on-call rotation, or in any...
Read more >
Separation of development and production environments
Separation of development, test (homologation) and production environments are important to achieve segregation of functions involved.
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