Introduction to nodejs
Introduction to nodejs
Backend language
[fetching and manipulating data from db] =>api => application program interface
database (DB)
where we store all the data like users, products etc
Signup(example)
Front end (UI-react) -> frontend page(sign up page) -> submit button -> /signup api call (fetch,axios,http)
Backend (Node) -> receive /signup request -> save data in db -> send success response
Database(Mongo) -> connected with node for CRUD
3)Scalable
4)Very Fast
5)No Buffering − Node.js applications never buffer any data. These applications
simply output the data in chunks.
Installation of Node.Js and NPM:
https://nodejs.org/en/download/
To confirm Node installation, type node -v command.
•npm init -f
YARN: NPM:NPX:
• Similar to npm
• Earlier it was fast
• npm install --global yarn
• Yarn uses the yarn command to install dependencies. It installs
dependencies in parallel, allowing you to add multiple files at the
same time.
Core Modules
let module = require('module_name') HTTP, FS, OS, Path and URL.
• Reading File
• fs.readFile(fileName [,options], callback)
• fs.readFileSync()
• Write File
• fs.writeFile(filename, data[, options], callback)
• fs.appendFile() method to append the content to an existing file.
• OpenFile
• fs.open(path, flags[, mode], callback)
const fs = require('fs');