Using different ormconfig.json files depending on env

Don't use the ormconfig.json. You can pass a config object directly to createConnection() like

import { createConnection } from "typeorm";

const config:any = {
       "port": process.env.port || "28017",
       "entities": [
          // ...
       ],
       "migrations": [
          // ...
       ],
       "subscribers": [
         // ...
       ],
       "cli": {
          // ...
       }
    }
    createConnection(config).then(async connection => {
        await loadPosts(connection);
    }).catch(error => console.log(error));

For the moment, I was able to just change ormconfig.json, to ormconfig.js, and then use env variables, like this:

module.exports = {
   "port": process.env.port,
   "entities": [
      // ...
   ],
   "migrations": [
      // ...
   ],
   "subscribers": [
     // ...
   ],
   "cli": {
      // ...
   }
}