Bingo meetings–deploying to heroku–part 19

Bingo

Bingo is a small project, written in TypeScript , and developed with Alexandru Badita in launch break (one hour - more or less). You can find sources at https://github.com/alexandru360/PresentationBingoCards/ . Those are my blog posts for Bingo : ( scroll below for the post)

We have decided to deploy on heroku, since it has some free dynos. Heroku is integrated with GitHub and has “automatic deploys” – that means that every push will automatically deploy to Heroku. That will be an opportunity for AzureDevOps to verify correct deploy ( even if appears different …)

Some points here:

1. Heroku is calling web npm start . So  in the root of the project we should have a package.json with a start script that starts our api

“start”: “cd bingo-cards-api && yarn start”,

2. Heroku is stripping dev dependecies. So, if you did not compile the project – and want too use tsc or other dependemcies, you should add on Heroku site the setting  NPM_CO NFIG_PRODUCTION false

3. The swagger from nestjs is , somehow, calling the HTTP, not the HTTPS . So the https://bingo-meeting-api.herokuapp.com/api/ does not work, but http://bingo-meeting-api.herokuapp.com/api/ works

4.Because we can call from other sites, the CORS should be enabled .

app.enableCors();

5. Also , we should enable dynamic port for Heroku

const port: string = process.env.PORT || “3000”;
await app.listen(parseInt(port, 10));

 

After this, you can try the API at http://bingo-meeting-api.herokuapp.com/api/