Coder Social home page Coder Social logo

xurpas-typeorm's Introduction

Node JS and TypeOrm Setup and Deployment Prerequisites

  1. Creating the Bolierplate code for TypeORM
  • install typeorm on local npm install -g typeorm
  • execute the command to generate the typeorm basecode
    typeorm --name <projectname> --database <database>
  • after boilerplate codes have been generated, execute npm install to download all dependencies for node
  • install express framework using the following command npm install express --save
  • install body-parder using the following command npm install body-parser --save
  • install nodemon for watching code changes npm install -g nodemon
  • add the following scripts on package.json "snm": "nodemon src/index.ts"
  1. Connecting to MongoDB Atlas
  • Create a User in MongoDB Atlas
  • Build a New Cluster and after successful cluster creation, go to connect and copy the connection string provided. ex string: mongodb+srv://sa:<password>@cl0sh0uf.mongodb.net/test?retryWrites=true&w=majority
  • make sure you have a database user.
  • check network access and eddit your whitelist entry to global ip 0.0.0.0/0
  • copy the connection string on your ormconfig.json
    "type": "mongodb",
    "url": "mongodb+srv://sa:[email protected]/test?retryWrites=true&w=majority",
    "database": "test",
    "useUnifiedTopology": true,
    "synchronize": true,
    
  1. Deploying the NodeJS App
  • install pm2 to for node js deployment npm install -g pm2
  • install babel-cli for building the typeorm applications npm install -g babel-cli
  • add the following scripts on package.json
"build-ts": "tsc -p ."
"build": "npm run build-ts && npm run build-babel"
"build-babel": "babel -d ./dist ./src -s"
"pm2-start":  "pm2 start build/index.js --watch"
  • run npm run build-babel to produce a build file and run pm2-start to deploy the app

Repo for sample Typeorm code: https://github.com/SeijiV13/xurpas-typeorm

xurpas-typeorm's People

Contributors

seijiv13 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.