https://github.com/sanjaraiy/nodejs_work
📂🚀 This repository explores the fs, os, http, and events modules in Node.js. Dive in and master these core functionalities! 💻📊
https://github.com/sanjaraiy/nodejs_work
crud events http javascript nodejs operating-system
Last synced: about 1 year ago
JSON representation
📂🚀 This repository explores the fs, os, http, and events modules in Node.js. Dive in and master these core functionalities! 💻📊
- Host: GitHub
- URL: https://github.com/sanjaraiy/nodejs_work
- Owner: sanjaraiy
- Created: 2023-07-30T16:19:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-23T02:26:17.000Z (almost 2 years ago)
- Last Synced: 2025-01-05T03:12:13.333Z (about 1 year ago)
- Topics: crud, events, http, javascript, nodejs, operating-system
- Language: JavaScript
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Node.js Modules Exploration 🚀
Welcome to the Node.js Modules Exploration repository! This repository is dedicated to understanding and implementing the core modules in Node.js, including `fs`, `os`, `http`, and `events`. Dive in and master these essential functionalities of Node.js! 💻📊
## Introduction
This repository is your guide to mastering some of the most important modules in Node.js. Each module is covered with examples and explanations to help you understand their usage and applications in real-world scenarios.
## Modules Covered
- **File System (`fs`)**: Learn how to work with the file system to read, write, and manipulate files.
- **Operating System (`os`)**: Get insights into the operating system-related information and methods.
- **HTTP (`http`)**: Understand how to create HTTP servers and handle requests and responses.
- **Events (`events`)**: Explore the events module to handle asynchronous events in your applications.
## Installation
To get started, clone the repository and install the necessary dependencies:
```bash
git clone https://github.com/sanjaraiy/nodejs_work.git
cd nodejs_work
npm install
```
## Usage
Each module has its own directory with detailed examples and explanations. Navigate to the desired module and run the example scripts:
```bash
cd fs
node example.js
```
## Examples
### File System (fs)
Example of reading a file:
```javascript
const fs = require('fs');
fs.readFile('example.txt', 'utf8', (err, data) => {
if (err) throw err;
console.log(data);
});
```
### Operating System (os)
Example of getting OS information:
```javascript
const os = require('os');
console.log('Platform:', os.platform());
console.log('CPU Architecture:', os.arch());
console.log('Total Memory:', os.totalmem());
```
### HTTP (http)
Example of creating an HTTP server:
```javascript
const http = require('http');
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello, World!\n');
});
server.listen(3000, () => {
console.log('Server running at http://localhost:3000/');
});
```
### Events (events)
Example of using EventEmitter:
```javascript
const EventEmitter = require('events');
const eventEmitter = new EventEmitter();
eventEmitter.on('start', () => {
console.log('Started!');
});
eventEmitter.emit('start');
```
## Contributing
We welcome contributions! Please read our content and to get started.
Happy coding! 🎉✨