Skip to content

Commit 18b60e4

Browse files
committed
upload course content
0 parents  commit 18b60e4

File tree

2,619 files changed

+1431770
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,619 files changed

+1431770
-0
lines changed

.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
node_modules
5+
node_modules/
6+
/.pnp
7+
.pnp.js
8+
9+
# testing
10+
/coverage
11+
12+
# production
13+
/build
14+
15+
# misc
16+
.DS_Store
17+
.env.local
18+
.env.development.local
19+
.env.test.local
20+
.env.production.local
21+
22+
npm-debug.log*
23+
yarn-debug.log*
24+
yarn-error.log*
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const promise = new Promise((resolve,reject)=>{
2+
setTimeout(()=>{
3+
resolve("success");
4+
},1000)
5+
})
6+
7+
8+
const getData = async() => {
9+
const res = await promise;
10+
console.log(res);
11+
}
12+
getData();
13+
14+
15+
16+
//fetch method using async await
17+
const getUser = async() => {
18+
const res = await fetch();
19+
const data = await res.json();
20+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const myPromise = new Promise((resolve, reject) => {
2+
const user = {id: 1};
3+
if (!user) {
4+
reject("Something went wrong..");
5+
}
6+
setTimeout(() => {
7+
resolve({name: "John"});
8+
}, 1000);
9+
});
10+
11+
const ids = [1,2,3,4];
12+
let userData = [];
13+
for(let i = 0; i < ids.length; i++){
14+
const userId = ids[i];
15+
userData.push(myPromise);
16+
}
17+
18+
Promise.all(userData).then(res => console.log(res));
19+

ACC/Node-Mongo/Module-1/Promise.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const myPromise = new Promise((resolve, reject) => {
2+
const user = null;
3+
if (!user) {
4+
reject("Something went wrong..");
5+
}
6+
setTimeout(() => {
7+
resolve("Successfully got the data");
8+
}, 1000);
9+
});
10+
11+
myPromise.then((res) => console.log(res)).catch((err) => console.log(err));
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const fyn1 = () => {
2+
console.log("This is from function 1");
3+
}
4+
5+
const fyn2 = () => {
6+
console.log("this is from function 2");
7+
}
8+
9+
module.exports.fyn1 = fyn1;
10+
module.exports.fyn2 = fyn2;
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const errorHandler = () => {
2+
console.log("This is from error handler function");
3+
}
4+
5+
module.exports = errorHandler;

ACC/Node-Mongo/Module-1/useExport.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const errorHandler = require("./singleExport.js");
2+
const {fyn1, fyn2} = require("./multipleExports.js");
3+
4+
errorHandler();
5+
6+
fyn1();
7+
fyn2();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const http = require("http");
2+
const PORT = 5000;
3+
const server = http.createServer((req,res)=>{
4+
5+
if(req.url == "/"){ //user jodi url home dei
6+
res.writeHead(200,{"content-type": "text/html"}); //status code, & file type
7+
res.write("<div><h1>Home</h1><p>This is our home page.</p></div>"); // our html that will be returned.
8+
res.end(); // sob response end korte hoi.
9+
}
10+
else if(req.url == "/contact"){ //user jodi url home dei
11+
res.writeHead(200,{"content-type": "text/html"}); //status code, & file type
12+
res.write("<div><h1>Contact</h1><p>This is our contact page.</p></div>"); // our html that will be returned.
13+
res.end(); // sob response end korte hoi.
14+
}
15+
else if(req.url == "/about"){ //user jodi url home dei
16+
res.writeHead(200,{"content-type": "application/json"}); //status code, & file type
17+
res.write(JSON.stringify({name: "Uttam Kumar Saha"})); // our html that will be returned.
18+
res.end(); // sob response end korte hoi.
19+
}
20+
// res.end("Hello node js ");
21+
})
22+
server.listen(PORT);
23+
console.log("Server is running on port",PORT);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const http = require("http");
2+
const url = require('url');
3+
const PORT = 5000;
4+
const server = http.createServer((req,res)=>{
5+
6+
const address_url = 'http://localhost:5000/contact?name=uttam&country=bangladesh';
7+
const parsedUrl = url.parse(address_url,true);
8+
const objectQuery = parsedUrl.query;
9+
console.log(objectQuery);
10+
// console.log(parsedUrl);
11+
// res.end("Hello node js ");
12+
})
13+
server.listen(PORT);
14+
console.log("Server is running on port",PORT);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const {name, add} = require("./other");
2+
3+
console.log(name);
4+
console.log(add(2,3));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const name = "uttam kumar saha";
2+
3+
const add = (num1, num2) => {
4+
return num1 + num2;
5+
}
6+
7+
module.exports = {name, add};

ACC/Node-Mongo/Module-2/export-import/package-lock.json

+51
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "export-import",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC",
12+
"dependencies": {
13+
"node": "^19.0.1"
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello node js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const http = require("http");
2+
const fs = require('fs');
3+
4+
const server = http.createServer((req,res)=> {
5+
if(req.url == "/"){
6+
//asynchronous read
7+
/*
8+
fs.readFile('data.txt', (err,data)=> {
9+
if(err){
10+
res.write("Data read failed.");
11+
res.end();
12+
}else{
13+
res.write(data);
14+
res.end()
15+
}
16+
})*/
17+
18+
//synchronous read
19+
/*
20+
const data = fs.readFileSync('data.txt');
21+
res.write(data);
22+
res.end()*/
23+
24+
25+
//asynchronous data write
26+
fs.writeFile('data.txt', "Hello node js ", (err)=> {
27+
if(err){
28+
res.write("data failed to write");
29+
res.end();
30+
} else {
31+
res.write("data written successfully");
32+
res.end();
33+
}
34+
})
35+
}
36+
})
37+
38+
const PORT = 5000;
39+
server.listen(PORT);
40+
console.log('server is running on port, ',PORT);

ACC/Node-Mongo/Module-2/file-system/package-lock.json

+51
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "file-system",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC",
12+
"dependencies": {
13+
"node": "^19.0.1"
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.env
3+
yarn.lock

ACC/Node-Mongo/Module-3/express-mvc-acc/README.md

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const limiter = require("../middleware/limiter");
2+
3+
let tools = [
4+
{id: 1, name: "Hammer"},
5+
{id: 1, name: "Hammer-2"},
6+
{id: 1, name: "Hammer-3"},
7+
{id: 1, name: "Hammer-4"},
8+
]
9+
const getAllTools = (req,res)=>{
10+
// res.download(__dirname + "/README.md");
11+
//res.redirect("/login");
12+
//res.send("tools found");
13+
const {limit, page} = req.query; // query
14+
15+
res.json(tools.slice(0,limit));
16+
}
17+
18+
const saveATool = (req,res) => {
19+
console.log(req.body);
20+
tools.push(req.body);
21+
res.send(tools);
22+
}
23+
24+
const getToolsDetails = (req, res) => {
25+
const {id} = req.params;
26+
res.send("Tools details found");
27+
}
28+
29+
30+
const updateTool = (req, res) => {
31+
//const newData = req.body;
32+
const {id} = req.params;
33+
const filter = {_id: id};
34+
const newData = tools.find(tool => tool.id == id);
35+
newData.id = id;
36+
newData.name = req.body.name;
37+
res.send(newData);
38+
}
39+
40+
const deleteTool = (req, res) => {
41+
const {id} = req.params;
42+
const filter = {_id: id};
43+
tools = tools.filter(tool => tool.id !== parseInt(id) );
44+
res.send(tools);
45+
}
46+
module.exports = {getAllTools, saveATool, getToolsDetails, updateTool, deleteTool};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hi me

0 commit comments

Comments
 (0)