TitBits of Node.js — Part-2

📄 Table of contents

Create a connection between Node and JS

◉ Serve Static Files (Include CSS and JS files in Node.js)

app.use(express.static(path.join(__dirname, 'public')));
var express = require('express');
var path = require('path');
<link rel='stylesheet' href='/style.css' />

Template Engines with Express

app.set("view engine", "hbs"); // mandatory to write in same format

◉ run both client & server simultaneously

npm install concurrently

◉ View Engines

// to send something (raw text) from expressJS to FE
res.send("send sthg to FE");
// to send HTML tag from expressJS to FE
res.send("<h1> sending html tag</h1>");
res.sendFile() // send file to frontend from nodejs//renders a view (when we are using render engines) in express
res.render(‘index’);
# Whenever we have to send data (POST) to backend…we need to use a package body-parser .

Experience with Front-end Technologies and MERN / MEAN Stack. Working on all Major UI Frameworks like React, Angular.