Posts

Showing posts with the label Project Setup

Standard Way To Setup Node JS Project With TypeScript

Image
As you know in programming world  JavaScript  is becoming quite famous programming language so in this blog we will discuss how we can create fresh project of  NodeJS with TypeScript  in standard way. What is Node JS? It s a cross-platform, open-source, and server-side JavaScript runtime environment that executes JavaScript code outside a web browser. What is TypeScript? TypeScript is an open-source language maintained and developed by Microsoft. It's loved and used by a lot of software developers around the world. If you want to Setup with only Node JS Then here is the Link . Requirements Any server should be installed either Apache or Nginx. NodeJS and NPM should be  installed  in the operating system.  First open your terminal and go to your project directory then run following commands ~ npm init (after hitting this command it will ask some basic questions you can answer it as per your needs) { " name " : " kafka-nodejs-real-time-app " , ...

NodeJS Standard Way to Write Models with Sequelize

Image
As we all know in our node js project there is one main file which is generally index.js or app.js . so if we put all code related to models file load so that is not an standard way of coding so for solving this problem we can create model directory , inside this directory we can create one index.js file in which we load all the models then call in models/index.js file in our main file.  Node JS Here is our app.js file: "use strict" require ( 'dotenv' ). config (); //for calling process.env.VAR_NAME globally const server = require ( './config/server' ), express = require ( 'express' ), app = express (), port = server . port ; require ( './src/models' ); // all routing app . get ( '/' , ( req , res ) => { res . send ( server . appName ) }) app . use ( '/api' , require ( './src/routes/index' )); //listen server on mentioned port app . listen ( port , "0.0.0.0" , () => { console . log ( ` ...