πββοΈ Run project locally
>> npm i -g yarn
>> git clone https://github.com/jd-apprentice/Node-TS.git
>> cd ./Node-TS
>> yarn install
>> yarn dev
π§ͺ Test locally
- These are the routes with insomnia
>> GET {{ _.BASE_URL }}/users
>> POST {{ _.BASE_URL }}/users
>> GET {{ _.BASE_URL }}/users/:id
>> DELETE {{ _.BASE_URL }}/users/:id
>> PUT {{ _.BASE_URL }}/users/:id
π Heroku deploy
- Go ahead to https://www.heroku.com/ create an account then log in into the dashboard
- Once there create a new app
- Go to the settings page and select buildpacks then choose nodejs
- After that you can go into deploys and deploy the app, for this method you have multiple options I often use github
- And below that there is the option for automatic deploys (when you push something to your selected branch ej main it will automatically deploy to heroku)
- And for last if u haven't done already there is the manual deploy where you select the branch and deploy the app
π Finish
-
And we are done! if everything was done correctly your app should be up and running on heroku, you can check it in the
Open App
button on their dashboard -
Here are some example apps i've build in the past with this structure
-
A simple crud app CRUD-BE
-
Get news from Infobae Infobae-API
-
Get random waifus Waifuland
π Folder structure
|--> @types
|--> config
|--> controllers
>user-controller.ts
|--> models
|--> interfaces
>user.ts
|--> repositories
>user-repository.ts
|--> routes
>user-route.ts
>index.ts
|--> services
>user-service.ts
>database.ts (Connection with the database)
>index.ts (Run the app)
>server.ts (App instance)
π Stack & Technologies
- Nodejs
- Typescript
- Express
- Mongodb
- Mongoose
- Heroku