/Node-TS

๐Ÿ“ Template -> NodeJS + Typescript + Express + Mongodb + Mongoose + Heroku

Primary LanguageTypeScriptMIT LicenseMIT

๐Ÿƒโ€โ™‚๏ธ 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
  • Create CREATE
  • Find USERS
  • FindOne USER
  • Update PUT
  • Delete DELETE

๐Ÿ‡ Heroku deploy

DASHBOARD

  • Once there create a new app

NEWAPP

  • Go to the settings page and select buildpacks then choose nodejs

BUILDPACK

  • After that you can go into deploys and deploy the app, for this method you have multiple options I often use github

DEPLOY

  • 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)

ADEPLOY

  • And for last if u haven't done already there is the manual deploy where you select the branch and deploy the app

MANUAL

๐Ÿ 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