Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sundramsharma1/backend-nodejs-express
Backend With Node.js ( Express.js )
https://github.com/sundramsharma1/backend-nodejs-express
backend expressjs mern-stack nodejs
Last synced: 4 days ago
JSON representation
Backend With Node.js ( Express.js )
- Host: GitHub
- URL: https://github.com/sundramsharma1/backend-nodejs-express
- Owner: sundramsharma1
- Created: 2024-08-16T09:57:17.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-08-23T05:14:18.000Z (3 months ago)
- Last Synced: 2024-08-23T06:27:49.276Z (3 months ago)
- Topics: backend, expressjs, mern-stack, nodejs
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![GitHub repo size](https://img.shields.io/github/repo-size/sundramsharma1/Backend-Nodejs-Express)
![GitHub stars](https://img.shields.io/github/stars/sundramsharma1/Backend-Nodejs-Express?style=social)
![GitHub forks](https://img.shields.io/github/forks/sundramsharma1/Backend-Nodejs-Express?style=social)
[![Twitter Follow](https://img.shields.io/twitter/follow/StarkSundram?style=social)](https://twitter.com/intent/follow?screen_name=StarkSundram)
Backend (Node.js, Express.js)
In this repo, we will learn about backend development using Node.js with Express.js in depth.
## Prerequisites
Before you begin, ensure you have met the following requirements:
* [Node.js](https://nodejs.org/en) must be installed on your operating system.### Run Locally
To run your program on your local machine, type this command in your command prompt and hit enter:
```bash
node .js
```Start
# Chapter_1(Basics)
* Process = Process command is use to get details about node which is install on your local machine
```bash
node <-|
process <-|
```
* Process.argv = Process.argv is use to take command line argument to run our programm
```bash
let n = process.argv;
for(let i = 2; i < n.length; i++){
console.log("Hiii", n[i]);
};
```
* To run this program type this command on command prompt
```bash
node .js
```lets suppose i type this
```bash
node process.js sundram mohit
```it will produce the output as
```bash
Hii sundram
Hii mohit
```# Chapter_2 (Exporting File or Folder)
* Require() = A built-in-function to include modules that exist in seperate files
* Modules.export = A special object
### Exporting a Single File =>
## Example =>
File.js
```bash
module.exports = 123;
```
script.js
```bash
const data = require('./File');
console.log(data);
```
O/P = 123### Exporting a Entire Directories =>
## Example =>
* Folder Structure
```bash
main/
│
├── Fruits/
│ ├── Apple.js
│ ├── Banana.js
│ ├── Orange.js
│ └── index.js
│
└── script.js
```
* Apple.js
```bash
const apple = {
name: 'Apple',
color: 'Red',
price: 90
};module.exports = Apple;
```
* Banana.js
```bash
const Banana = {
name: 'Banana',
color: 'Yellow',
price: 50
};module.exports = Banana;
```
* Orange.js
```bash
const Orange = {
name: 'Orange',
color: 'Yellow',
price: 60
};module.exports = Orange;
```
* index.js
```bash
const apple = require('./Apple');
const banana = require('./Banana');
const orange = require('./Orange');module.exports = {apple, banana, orange};
```
* Script.js
```bash
const info = require('./Fruits');
console.log(info);
```
* O/P =
{
apple: { name: 'Apple', color: 'Red', price: 90 },
banana: { name: 'Banana', color: 'Yellow', price: 50 },
orange: { name: 'Orange', color: 'Yellow', price: 60 }
}
## Require() Vs Import
### Require() =
* We Can't Selectively load only the pices we need
* It is a old method to load any file before (ES6)
* It is used to load whole file at a time
* module.exports = file_name;
* In this method Loading is Synchronous Means line wise module loaded
### Import() =
* We can selectively load only the pices we need, which can save the memory
* It is a new method after (ES6) version and it is use to load a single module which is faster than require
* export
* In this method loading can be Asynchronous means we can be use first function or last function or any functionExpress.js
## Library Vs Framework
### Library =
* A library is a collection of pre written code that can be used to perform specific tasks
* Ex - Axios### Framework =
* A Framework is a set of pre-written code that provides a structure for developing software applications
* Ex - express.js