w3tecch / express-typescript-boilerplate

A delightful way to building a RESTful API with NodeJs & TypeScript by @w3tecch
MIT License
3.29k stars 904 forks source link

npm production migrate? #79

Closed lopezm94 closed 6 years ago

lopezm94 commented 6 years ago

I have run with an issue recently when pushing code to production. commands/ormconfig.ts has src/env hardcoded instead of src/dist. This presents a "problem" when doing migrations with the built code, would you mind if I add a new command in package.json?

P.S Awesome work in the package!

et commented 6 years ago

I'm experiencing the same thing. @lopezm94 what did you change this to to fix it?

et commented 6 years ago

It feels to me that like the ormconfig.json should be eliminated. Right now there's duped information between that and the env file.

dweber019 commented 6 years ago

Currently we only need the ormconfig.json because of the TypeORM CLI.

It feels to me that like the ormconfig.json should be eliminated. Right now there's duped information between that and the env file.

The single truth is env.ts, which uses .env and is used for ormconfig.json generation.

@lopezm94 & @et: Would I make sense if the ormconfig.json is copyed to dist after a build?

et commented 6 years ago

@dweber019 - copying the ormconfig.json would work. If that workflow seems complicated though, typeorm can just pluck environment variables from the .env file: https://github.com/typeorm/typeorm/blob/master/docs/using-ormconfig.md#using-environment-variables

dweber019 commented 6 years ago

@et you're right. Setting the environment variables is the proper way. Will close this issue.

What we do is deploy the whole project (not only the dist) and therefore it works.

et commented 6 years ago

@dweber019 - what would help though for people though is to provide uniformity with the db env variables. So in the .env file, they should be renamed to TYPEORM_ variables.

dweber019 commented 6 years ago

@et could you have a look at https://github.com/w3tecch/express-typescript-boilerplate/pull/95 and provide some feedback what you think. Thanks