├── .gitignore
├── Capstone
└── Backend
│ ├── .env
│ ├── .gitIgnore
│ ├── Controllers
│ ├── admin
│ │ └── auth.controller.js
│ ├── auth.controller.js
│ ├── cart.controller.js
│ ├── category.controller.js
│ └── product.controller.js
│ ├── Models
│ ├── cart.model.js
│ ├── category.model.js
│ ├── product.model.js
│ └── user.model.js
│ ├── Routes
│ ├── admin
│ │ ├── auth.route.js
│ │ └── index.route.js
│ ├── auth.route.js
│ ├── cart.route.js
│ ├── category.route.js
│ ├── index.route.js
│ └── product.route.js
│ ├── database
│ └── db.js
│ ├── helpers
│ └── helper.js
│ ├── middleware
│ ├── auth.middleware.js
│ ├── common.middleware.js
│ └── request.validator.js
│ ├── package-lock.json
│ ├── package.json
│ ├── readme.md
│ ├── server.js
│ └── uploads
│ ├── 15.381034810400562-samsung-guru-fm-plus-side.jpeg
│ ├── 27.0571917227052-samsung-guru-fm-plus.jpeg
│ ├── 29.852015591065673-samsung-guru-fm-plus-sm-b110e-d-sm-b110e-d-original-imaea9fqzyqdwm3r.jpeg
│ ├── 34.92758743931679-samsung-guru-fm-plus-sm-b110e-d-sm-b110e-d-original-imaea9fqzyqdwm3r.jpeg
│ ├── 4.930121625296668-samsung-guru-fm-plus.jpeg
│ ├── 41.581756917683975-samsung-guru-fm-plus.jpeg
│ ├── 42.57039326432608-samsung-guru-fm-plus-back.jpeg
│ ├── 55.176086837053816-samsung-guru-fm-plus-side.jpeg
│ ├── 62.455371775117065-samsung-guru-fm-plus.jpeg
│ ├── 69.06201890297314-samsung-guru-fm-plus-back.jpeg
│ ├── 97.80426030498037-samsung-guru-fm-plus-back.jpeg
│ ├── 99.3994107514538-samsung-guru-fm-plus-back.jpeg
│ ├── samsung-guru-fm-plus-back.jpeg
│ └── samsung-guru-fm-plus.jpeg
├── Code-base
├── Day10
│ ├── assets
│ │ ├── css
│ │ │ └── style.css
│ │ └── images
│ │ │ ├── W3Schools_logo.svg
│ │ │ └── logo.png
│ └── index.html
├── Day13
│ ├── assets
│ │ ├── css
│ │ │ └── style.css
│ │ └── js
│ │ │ └── main.js
│ └── index.html
├── Day14
│ ├── assets
│ │ ├── css
│ │ │ └── style.css
│ │ └── js
│ │ │ └── main.js
│ └── index.html
├── Day15
│ ├── assets
│ │ ├── css
│ │ │ └── style.css
│ │ ├── images
│ │ │ ├── black-widow.jpg
│ │ │ ├── captain-marvel.jpg
│ │ │ ├── dr-strange.jpg
│ │ │ ├── hawk-eye.jpg
│ │ │ ├── iron-man.jpg
│ │ │ ├── spiderman.jpg
│ │ │ ├── the-hulk.jpg
│ │ │ └── thor.jpg
│ │ └── js
│ │ │ ├── main.js
│ │ │ └── main2.js
│ └── index.html
├── Day16
│ ├── assets
│ │ ├── css
│ │ │ └── style.css
│ │ ├── images
│ │ │ ├── black-widow.jpg
│ │ │ ├── captain-marvel.jpg
│ │ │ ├── dr-strange.jpg
│ │ │ ├── hawk-eye.jpg
│ │ │ ├── iron-man.jpg
│ │ │ ├── spiderman.jpg
│ │ │ ├── the-hulk.jpg
│ │ │ └── thor.jpg
│ │ └── js
│ │ │ ├── main.js
│ │ │ └── main2.js
│ └── index.html
├── Day17
│ ├── assets
│ │ ├── css
│ │ │ └── style.css
│ │ ├── images
│ │ │ ├── black-widow.jpg
│ │ │ ├── captain-marvel.jpg
│ │ │ ├── dr-strange.jpg
│ │ │ ├── hawk-eye.jpg
│ │ │ ├── iron-man.jpg
│ │ │ ├── spiderman.jpg
│ │ │ ├── the-hulk.jpg
│ │ │ └── thor.jpg
│ │ └── js
│ │ │ └── main.js
│ └── index.html
├── Day19
│ ├── assets
│ │ ├── css
│ │ │ └── style.css
│ │ └── js
│ │ │ └── main.js
│ └── index.html
├── Day20
│ ├── index.js
│ ├── node_modules
│ │ └── http
│ │ │ ├── README.md
│ │ │ └── package.json
│ ├── package-lock.json
│ └── package.json
├── Day21
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── Day22
│ ├── database
│ │ └── db.js
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── Day23
│ ├── controllers
│ │ └── author.controller.js
│ ├── database
│ │ └── db.js
│ ├── helpers
│ │ └── validation.helper.js
│ ├── index.js
│ ├── models
│ │ ├── authorModel.js
│ │ ├── bookModel.js
│ │ └── publicationModel.js
│ ├── package-lock.json
│ ├── package.json
│ └── routes
│ │ └── authorRoutor.js
├── Day30
│ ├── assets
│ │ ├── css
│ │ │ └── style.css
│ │ └── js
│ │ │ └── main.js
│ └── index.html
├── Day5
│ ├── assets
│ │ └── css
│ │ │ └── style.css
│ └── index.html
├── Day6
│ ├── Display.html
│ ├── assets
│ │ └── css
│ │ │ ├── Display.css
│ │ │ └── position.css
│ └── position.html
├── Day7
│ ├── assets
│ │ └── css
│ │ │ ├── flex.css
│ │ │ └── pseudo.css
│ ├── flex.html
│ ├── flexbox.html
│ └── pseudo.html
└── Day8
│ ├── assets
│ └── css
│ │ ├── media.css
│ │ └── pseudo.css
│ ├── flex.html
│ └── pseudo.html
├── Front-end
├── Javascript
│ ├── Assignment-1
│ │ └── README.md
│ ├── Assignment-2
│ │ └── README.md
│ ├── Assignment-3
│ │ └── README.md
│ ├── Assignment-4
│ │ └── README.md
│ ├── Assignment-5
│ │ └── Readme.md
│ └── Assignment-6
│ │ └── readme.md
└── Pure HTML CSS
│ ├── Assignment-1
│ └── README.md
│ ├── Assignment-2
│ └── README.md
│ ├── Assignment-3
│ └── README.md
│ └── Assignment-4
│ └── README.md
├── Mini-projects
└── candy-crush
│ ├── assets
│ ├── css
│ │ └── style.css
│ ├── images
│ │ ├── blue-candy.png
│ │ ├── green-candy.png
│ │ ├── orange-candy.png
│ │ ├── purple-candy.png
│ │ ├── red-candy.png
│ │ └── yellow-candy.png
│ └── js
│ │ └── main.js
│ └── index.html
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | **/node_modules
--------------------------------------------------------------------------------
/Capstone/Backend/.env:
--------------------------------------------------------------------------------
1 | PORT=8081
2 | DB_USER=vjtron
3 | DB_PASSWORD=pass_123
4 | DB_NAME=amazon_prd
5 | JWT_SECRET_KEY=secretkey
--------------------------------------------------------------------------------
/Capstone/Backend/.gitIgnore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 |
--------------------------------------------------------------------------------
/Capstone/Backend/Controllers/admin/auth.controller.js:
--------------------------------------------------------------------------------
1 | const {
2 | nanoid
3 | } = require('nanoid')
4 |
5 | const userModel = require('../../models/user.model');
6 | const {
7 | generateJwtToken
8 | } = require('../../helpers/helper');
9 |
10 |
11 | const signup = (req, res) => {
12 |
13 | const {
14 | email,
15 | firstname,
16 | lastname,
17 | password
18 | } = req.body;
19 |
20 | userModel.findOne({
21 | email: email
22 | }).exec((error, data) => {
23 |
24 | if (error) {
25 | console.log(error);
26 |
27 | return res.status(500).json({
28 | success: false,
29 | message: "Some Error occurred while searching for existing email. Contact your administrator"
30 | });
31 | }
32 |
33 |
34 | if (data) {
35 | return res.json({
36 | success: false,
37 | message: "Admin Email Already Exists."
38 | })
39 | }
40 |
41 |
42 | const _admin = new userModel({
43 | email,
44 | firstname,
45 | lastname,
46 | password,
47 | role: 'admin',
48 | username: nanoid(10),
49 | });
50 |
51 | _admin.save((error, admin) => {
52 | if (error) {
53 | console.log(error);
54 |
55 | return res.status(500).json({
56 | success: false,
57 | message: "Some Error occurred while saving the admin. Contact your administrator"
58 | });
59 | }
60 | if (admin) {
61 |
62 | const token = generateJwtToken(admin._id, admin.role);
63 | return res.json({
64 | success: true,
65 | message: "Admin has been successfully saved",
66 | data: {
67 | admin,
68 | token: token
69 | }
70 | })
71 | }
72 | })
73 | })
74 | }
75 |
76 | const signin = (req, res) => {
77 |
78 | const {
79 | email,
80 | password
81 | } = req.body;
82 |
83 | userModel.findOne({
84 | email: email
85 | }).exec((error, data) => {
86 |
87 | if (error) {
88 | console.log(error);
89 |
90 | return res.status(500).json({
91 | success: false,
92 | message: "DB Error occurred. Contact your administrator"
93 | });
94 | }
95 |
96 | if (data) {
97 | if (data.role != 'admin') {
98 | return res.status(403).json({
99 | success: false,
100 | message: "Access Forbidden."
101 | });
102 | }
103 |
104 | const isAuthenticated = data.authenticate(password);
105 | if (isAuthenticated) {
106 |
107 | const token = generateJwtToken(data._id, data.role);
108 | return res.json({
109 | success: true,
110 | message: "Admin Login successfully",
111 | data: {
112 | user: {
113 | fullname: data.fullname,
114 | email: data.email
115 | },
116 | "token": token
117 | }
118 | })
119 |
120 | } else {
121 | return res.json({
122 | success: false,
123 | message: "Admin Login failed. Bad Authentication"
124 | })
125 | }
126 |
127 | } else {
128 | return res.json({
129 | success: false,
130 | message: "Admin Email Does not exist."
131 | });
132 | }
133 | })
134 |
135 | }
136 |
137 |
138 | module.exports = {
139 | signup,
140 | signin
141 | }
--------------------------------------------------------------------------------
/Capstone/Backend/Controllers/auth.controller.js:
--------------------------------------------------------------------------------
1 | const userModel = require('../models/user.model');
2 | const {
3 | nanoid
4 | } = require('nanoid')
5 |
6 | const {
7 | generateJwtToken
8 | } = require('../helpers/helper');
9 |
10 |
11 |
12 | const signup = (req, res) => {
13 |
14 | const {
15 | email,
16 | firstname,
17 | lastname,
18 | password
19 | } = req.body;
20 |
21 | userModel.findOne({
22 | email: email
23 | }).exec((error, data) => {
24 |
25 | if (error) {
26 | console.log(error);
27 |
28 | return res.status(500).json({
29 | success: false,
30 | message: "Some Error occurred while searching for existing email. Contact your administrator"
31 | });
32 | }
33 |
34 |
35 | if (data) {
36 | return res.json({
37 | success: false,
38 | message: "User Email Already Exists."
39 | })
40 | }
41 |
42 |
43 | const _user = new userModel({
44 | email,
45 | firstname,
46 | lastname,
47 | password,
48 | username: nanoid(10),
49 | });
50 |
51 | _user.save((error, user) => {
52 | if (error) {
53 | console.log(error);
54 |
55 | return res.status(500).json({
56 | success: false,
57 | message: "Some Error occurred while saving the user. Contact your administrator"
58 | });
59 | }
60 | if (user) {
61 |
62 | const token = generateJwtToken(user._id, user.role);
63 | return res.json({
64 | success: true,
65 | message: "User has been successfully saved",
66 | data: {
67 | user: {
68 | fullname: user.fullname,
69 | email: user.email
70 | },
71 | token: token
72 | }
73 | })
74 | }
75 | })
76 | })
77 | }
78 |
79 | const signin = (req, res) => {
80 |
81 | const {
82 | email,
83 | password
84 | } = req.body;
85 |
86 | userModel.findOne({
87 | email: email
88 | }).exec((error, data) => {
89 |
90 | if (error) {
91 | console.log(error);
92 |
93 | return res.status(500).json({
94 | success: false,
95 | message: "DB Error occurred. Contact your administrator"
96 | });
97 | }
98 |
99 | if (data) {
100 |
101 | const isAuthenticated = data.authenticate(password);
102 | if (isAuthenticated) {
103 |
104 | const token = generateJwtToken(data._id, data.role);
105 | return res.json({
106 | success: true,
107 | message: "User Login successfully",
108 | data: {
109 | user: {
110 | fullname: data.fullname,
111 | email: data.email
112 | },
113 | "token": token
114 | }
115 | })
116 |
117 | } else {
118 | return res.json({
119 | success: false,
120 | message: "User Login failed. Bad Authentication"
121 | })
122 | }
123 |
124 | } else {
125 | return res.json({
126 | success: false,
127 | message: "User Email Does not exist."
128 | });
129 | }
130 | })
131 |
132 | }
133 |
134 |
135 | module.exports = {
136 | signup,
137 | signin
138 | }
--------------------------------------------------------------------------------
/Capstone/Backend/Controllers/cart.controller.js:
--------------------------------------------------------------------------------
1 | const cartModel = require('../models/cart.model')
2 | const {
3 | getErrorResponse,
4 | getResponseV1,
5 | getResponseV2
6 | } = require('../helpers/helper')
7 | const { response } = require('express')
8 |
9 | const validateCart = (new_cart, old_cart) => {
10 | /**
11 | *
12 | * Validate the array of objects
13 | * check for the correct keys, null values.
14 | * return boolean
15 | *
16 | * */
17 |
18 |
19 | /**
20 | *
21 | * old_cart {
22 | * watch 1,
23 | * cable 2
24 | * }
25 | *
26 | * new_cart {
27 | * watch 1
28 | * }
29 | *
30 | * return {
31 | * watch : 2,
32 | * cable : 2
33 | * }
34 | *
35 | */
36 |
37 | return true
38 | }
39 |
40 | function udpateCartModel(condition, update) {
41 | return new Promise((resolve, reject) => {
42 | cartModel.findOneAndUpdate(condition, update)
43 | .then(response => resolve(response))
44 | .catch(error => reject(error))
45 | })
46 | }
47 |
48 |
49 | const addToCart = (req, res) => {
50 | const customer = req.user;
51 | console.log(customer);
52 | cartModel.findOne({
53 | customer: customer.id
54 | }).exec((error, cart) => {
55 | if (error) return getErrorResponse(res, 500, error)
56 | // isRequestCorrect = validateCart(cartData, cart.cartItems);
57 | // if (isRequestCorrect) {
58 | if (cart) {
59 | //Cart is already created. To Update the existing cartItems
60 |
61 | let promises = []
62 | let cartData = req.body.cartItems;
63 | cartData.forEach(cartItem => {
64 | let product = cartItem.product; //p1
65 | let item = cart.cartItems.find(c => c.product == product);
66 | let condition, update;
67 | if (item) {
68 | console.log(item);
69 | const newItemquantity = item.quantity + cartItem.quantity
70 | condition = {
71 | "customer": customer.id,
72 | "cartItems.product": product
73 | }
74 | update = {
75 | "$set": {
76 | "cartItems.$.quantity": newItemquantity
77 | }
78 | }
79 |
80 | } else {
81 |
82 | /**
83 | *
84 | * step 1 find cart based on customer id.
85 | * step 2 push the current item from req.body i.e. cartItem into the cart document found based on the condition in step 1.
86 | * step 3 update the cart document
87 | *
88 | */
89 | condition = {
90 | "customer": customer.id
91 | }
92 | update = {
93 | "$push": {
94 | "cartItems": cartItem
95 | }
96 | }
97 | }
98 | promises.push(udpateCartModel(condition, update));
99 | });
100 |
101 | Promise.all(promises).then(
102 | response => getResponseV1(res, 200, response)
103 | ).catch(
104 | error => getErrorResponse(res, 500, error)
105 | )
106 | } else {
107 | console.log("in else");
108 | const _cart = new cartModel({
109 | customer: customer.id,
110 | cartItems: req.body.cartItems
111 | })
112 |
113 | _cart.save((error, cartData) => {
114 |
115 | if (error) return getErrorResponse(res, 500, error)
116 |
117 | if (cartData) {
118 | return getResponseV1(res, 200, cartData)
119 | }
120 | })
121 | }
122 |
123 | })
124 | }
125 |
126 | const getCart = async (req, res) => {
127 |
128 |
129 | try {
130 | const cart = await cartModel.findOne({
131 | customer: req.user.id
132 | }, '_id cartItems').populate({
133 | path: "cartItems.product",
134 | select: "_id name slug price description productPicture"
135 | });
136 |
137 | return res.json({
138 | "data": cart
139 | })
140 | } catch (error) {
141 | console.log(error);
142 | return res.status(500).json({
143 | success: false,
144 | message: `DB Error occurred.
145 | Contact your administrator`,
146 | error: error
147 | });
148 | }
149 |
150 | }
151 |
152 |
153 | module.exports = {
154 | addToCart,
155 | getCart
156 | }
--------------------------------------------------------------------------------
/Capstone/Backend/Controllers/category.controller.js:
--------------------------------------------------------------------------------
1 | const slugify = require('slugify')
2 | const {
3 | nanoid
4 | } = require('nanoid')
5 |
6 | const categoryModel = require('../models/category.model');
7 |
8 |
9 | const addNewCategory = (req, res) => {
10 |
11 | let slug = slugify(req.body.name, {
12 | lower: true
13 | }) + '-' + nanoid(8);
14 |
15 | const categoryInput = {
16 | name: req.body.name,
17 | slug: slug
18 | };
19 |
20 | categoryInput.createdBy = req.user.id;
21 |
22 |
23 | if (req.body.parentId) {
24 | categoryInput.parentId = req.body.parentId;
25 | }
26 |
27 | const _category = new categoryModel(categoryInput);
28 | _category.save((error, category) => {
29 |
30 | if (error) {
31 | console.log(error);
32 | return res.status(500).json({
33 | success: false,
34 | message: "DB Error occurred. Contact your administrator"
35 | });
36 | }
37 |
38 | if (category) {
39 | return res.status(201).json({
40 | success: true,
41 | message: "Category Saved successfully",
42 | data: category
43 | })
44 | }
45 | })
46 | }
47 |
48 |
49 | /**
50 | * easy
51 | * Get the list
52 | * cate [{ed }, {md}, {samsun}, .....]
53 | *
54 | *
55 | * intermediate
56 | * Get the category tree...
57 | *
58 | * Electronic Devices
59 | * - Mobile Device
60 | * - Samsung
61 | * - iPhone
62 | * - One Plus
63 | * - TVs
64 | * - Sony
65 | * - TCL
66 | * - blah blah blah
67 | * [{
68 | * name : ed ...
69 | * subcategorie : {
70 | * {name : mobile device.... ,
71 | * subcategorie :{
72 | * {name : samsung, ...} ,
73 | * {name : one plus}
74 | * }
75 | * },
76 | * {name : tvs.... ,
77 | * subcategorie :{
78 | * {name : sony, ...} ,
79 | * {name : tcl}
80 | * }
81 | * }
82 | * }
83 | * },
84 | * {
85 | * name : Fashions,
86 | *
87 | * }]
88 | *
89 | */
90 |
91 | const getCategory = async (req, res) => {
92 |
93 | try {
94 | const category = await categoryModel.find({}, '_id name slug parentId type');
95 | const resp = generateCategoryData(category);
96 | return res.json({
97 | "data": resp
98 | })
99 | } catch (error) {
100 | console.log(error);
101 | return res.status(500).json({
102 | success: false,
103 | message: `DB Error occurred.
104 | Contact your administrator`,
105 | error: error
106 | });
107 | }
108 | }
109 |
110 | const generateCategoryData = (allCategories, parentId = null) => {
111 | const CategoryJSON = [];
112 | let _parentId; //undefined
113 | if (parentId != null)
114 | _parentId = parentId;
115 |
116 | let categories = allCategories.filter((cat) => cat.parentId == _parentId);
117 |
118 | for (let i = 0; i < categories.length; i++) {
119 | const element = categories[i];
120 | let categoryObj = {
121 | _id: element._id,
122 | name: element.name,
123 | slug: element.slug,
124 | type: element.type,
125 | parentId: element.parentId,
126 | "subCategory": generateCategoryData(allCategories, element._id)
127 | }
128 | CategoryJSON.push(categoryObj);
129 | }
130 | return CategoryJSON;
131 | }
132 |
133 |
134 | module.exports = {
135 | addNewCategory,
136 | getCategory
137 | }
--------------------------------------------------------------------------------
/Capstone/Backend/Controllers/product.controller.js:
--------------------------------------------------------------------------------
1 | const slugify = require('slugify')
2 |
3 | const productModel = require('../models/product.model');
4 |
5 |
6 | const addNewProduct = (req, res) => {
7 |
8 | const {
9 | name,
10 | price,
11 | description,
12 | quantity,
13 | category,
14 | } = req.body
15 |
16 | let productImageList = []
17 | if (req.files.length > 0) {
18 | productImageList = req.files.map((file) => {
19 | return {
20 | img: file.path
21 | }
22 | })
23 | }
24 |
25 | const _product = new productModel({
26 | name,
27 | slug: slugify(name),
28 | price,
29 | description,
30 | quantity,
31 | category,
32 | "productPicture": productImageList,
33 | createdBy: req.user.id
34 | })
35 |
36 | _product.save((error, product) => {
37 | if (error) {
38 | return res.status(500).json({
39 | error: error,
40 | success: false,
41 | message: "DB Error occurred. Contact your administrator"
42 | })
43 | }
44 |
45 | if (product) {
46 | res.status(201).json({
47 | success: true,
48 | data: product,
49 | message: "Product successfully Saved."
50 | })
51 | }
52 | })
53 |
54 | }
55 |
56 |
57 | const getProduct = async (req, res) => {
58 |
59 | try {
60 | const product = await productModel.find({});
61 | return res.json({
62 | product
63 | })
64 | } catch (error) {
65 | console.log(error);
66 | return res.status(500).json({
67 | success: false,
68 | message: "DB Error occurred. Contact your administrator",
69 | error: error
70 | });
71 | }
72 | }
73 |
74 | module.exports = {
75 | addNewProduct,
76 | getProduct
77 | }
--------------------------------------------------------------------------------
/Capstone/Backend/Models/cart.model.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose');
2 |
3 | const cartSchema = mongoose.Schema({
4 | customer: {
5 | type: mongoose.Schema.Types.ObjectId,
6 | ref: "User",
7 | required: true,
8 | unique: true
9 | },
10 | cartItems: [{
11 | product: {
12 | type: mongoose.Schema.Types.ObjectId,
13 | ref: "Product",
14 | required: true,
15 | },
16 | quantity: {
17 | type: Number,
18 | required: true
19 | }
20 | }]
21 | }, {
22 | timestamps: true
23 | });
24 |
25 | module.exports = mongoose.model('Cart', cartSchema);
26 |
27 |
28 |
29 | /***
30 | * Amazon --
31 | * Mobile -- Cart Mac, Screenguard and airpods
32 | * Desktop -- Empty / Mac, Screenguard and airpods
33 | *
34 | *
35 | */
--------------------------------------------------------------------------------
/Capstone/Backend/Models/category.model.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose');
2 |
3 | const categorySchema = mongoose.Schema({
4 |
5 | name: {
6 | type: String,
7 | required: [true, "Please provide your Category Name"],
8 | trim: true
9 | },
10 | slug: {
11 | type: String,
12 | required: [true, "Please provide your Category Slug"],
13 | trim: true,
14 | unique: true,
15 | },
16 | type: {
17 | type: String,
18 | },
19 | parentId: {
20 | type: String,
21 | },
22 | createdBy: {
23 | type: mongoose.Schema.Types.ObjectId,
24 | ref: "User",
25 | required: true,
26 | }
27 |
28 | }, {
29 | timestamps: true
30 | });
31 |
32 | module.exports = mongoose.model('Category', categorySchema);
--------------------------------------------------------------------------------
/Capstone/Backend/Models/product.model.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose');
2 |
3 | const productSchema = mongoose.Schema({
4 |
5 | name: {
6 | type: String,
7 | required: [true, "Please provide your product Name"],
8 | trim: true
9 | },
10 | slug: {
11 | type: String,
12 | required: [true, "Please provide your product Slug"],
13 | trim: true,
14 | unique: true,
15 | },
16 | price: {
17 | type: Number,
18 | required: [true, "Please provide the product price"],
19 | },
20 | quantity: {
21 | type: Number,
22 | required: [true, "Please provide the product quantity"],
23 | },
24 | productPicture: [{
25 | img: {
26 | type: String,
27 | }
28 | }],
29 | category: {
30 | type: mongoose.Schema.Types.ObjectId,
31 | ref: "Category",
32 | required: true,
33 | },
34 | createdBy: {
35 | type: mongoose.Schema.Types.ObjectId,
36 | ref: "User",
37 | required: true,
38 | },
39 | description: {
40 | type: String,
41 | required: true,
42 | },
43 | reviews: [{
44 | userId: {
45 | type: mongoose.Schema.Types.ObjectId,
46 | ref: "User"
47 | },
48 | review: {
49 | type: String
50 | }
51 | }],
52 | updatedAt: Date
53 |
54 | }, {
55 | timestamps: true
56 | });
57 |
58 | module.exports = mongoose.model('Product', productSchema);
--------------------------------------------------------------------------------
/Capstone/Backend/Models/user.model.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose');
2 | const bcrypt = require('bcrypt');
3 |
4 |
5 | /**
6 | *
7 | * User Schema
8 | *
9 | * @attributes
10 | * firstname
11 | * lastname
12 | * email
13 | * contact_number
14 | * hash_password
15 | * username
16 | * role/type
17 | *
18 | */
19 |
20 | const userSchema = mongoose.Schema({
21 | firstname: {
22 | type: String,
23 | required: [true, "Please provide your FirstName"],
24 | trim: true,
25 | min: 3,
26 | max: 20
27 | },
28 | lastname: {
29 | type: String,
30 | required: [true, "Please provide your LastName"],
31 | trim: true,
32 | min: 3,
33 | max: 20
34 | },
35 | email: {
36 | type: String,
37 | required: [true, "Please provide your email"],
38 | trim: true,
39 | unique: true,
40 | lowercase: true
41 | },
42 | username: {
43 | type: String,
44 | required: [true, "Please provide your Username"],
45 | trim: true,
46 | unique: true,
47 | lowercase: true,
48 | index: true
49 | },
50 | role: {
51 | type: String,
52 | enum: ["user", "admin", "super-admin"],
53 | default: "user"
54 | },
55 | contact_number: {
56 | type: String
57 | },
58 | hash_password: {
59 | type: String,
60 | required: [true, "Please provide your Password"],
61 | }
62 | }, {
63 | timestamps: true
64 | })
65 |
66 |
67 | /**
68 | * Virtuals are properties not stored in the database.
69 | * They are only logically stored to perform computations on the document fields.
70 | *
71 | */
72 |
73 | /**
74 | *
75 | * client --> node server [ server.js <--> route <--> controllers <--> model, save data to db ]
76 | *
77 | * sending data to db , it will check for the virtuals
78 | *
79 | *
80 | * what will be the scope of the 'this' keyword? what will it contain / refer to ?
81 | *
82 | *
83 | * anonymous functions
84 | * arrow functions -> the hash_password property of the const variable userSchema will be overwritten
85 | * general functions
86 | */
87 |
88 |
89 | userSchema.virtual('password').set(function (password) {
90 | this.hash_password = bcrypt.hashSync(password, 12)
91 | })
92 |
93 | userSchema.virtual('fullname').get(function () {
94 | return this.firstname + ' ' + this.lastname;
95 | }).set(function (fullname) {
96 | this.firstname = fullname.split(' ')[0];
97 | this.lastname = fullname.split(' ')[1];
98 | })
99 |
100 |
101 | /***
102 | *
103 | * Methods / Functions that are generic and assoicated to a particular Model
104 | *
105 | */
106 |
107 | userSchema.methods = {
108 |
109 | authenticate: function (password) {
110 | return bcrypt.compareSync(password, this.hash_password)
111 | }
112 |
113 | }
114 |
115 | module.exports = mongoose.model('User', userSchema);
--------------------------------------------------------------------------------
/Capstone/Backend/Routes/admin/auth.route.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 |
4 | const {
5 | signup,
6 | signin
7 | } = require('../../Controllers/admin/auth.controller');
8 |
9 | const {
10 | validateSignUpRequest,
11 | validateSignInRequest,
12 | isRequestCorrect
13 | } = require('../../middleware/request.validator');
14 |
15 |
16 | /**
17 | * route /signup
18 | *
19 | *
20 | * @param
21 | * fullname
22 | * email
23 | * password
24 | *
25 | *
26 | */
27 | router.post('/signup', validateSignUpRequest, isRequestCorrect, signup);
28 | router.post('/signin', validateSignInRequest, isRequestCorrect, signin);
29 |
30 |
31 | module.exports = router;
--------------------------------------------------------------------------------
/Capstone/Backend/Routes/admin/index.route.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 |
4 | const authRoutes = require('./auth.route')
5 |
6 | router.use("/", authRoutes)
7 | module.exports = router;
--------------------------------------------------------------------------------
/Capstone/Backend/Routes/auth.route.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 |
4 | const {
5 | signup,
6 | signin
7 | } = require('../Controllers/auth.controller');
8 |
9 | const {
10 | validateSignUpRequest,
11 | validateSignInRequest,
12 | isRequestCorrect
13 | } = require('../middleware/request.validator');
14 |
15 | /**
16 | * route /signup
17 | *
18 | *
19 | * @param
20 | * fullname
21 | * email
22 | * password
23 | *
24 | *
25 | */
26 | router.post('/signup', validateSignUpRequest, isRequestCorrect, signup);
27 | router.post('/signin', validateSignInRequest, isRequestCorrect, signin);
28 |
29 |
30 | module.exports = router;
--------------------------------------------------------------------------------
/Capstone/Backend/Routes/cart.route.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 |
4 | const {
5 | addToCart,
6 | getCart
7 | } = require('../Controllers/cart.controller')
8 |
9 |
10 | const {
11 | isLoggedIn,
12 | isUser
13 | } = require('../middleware/auth.middleware')
14 |
15 |
16 |
17 | router.post('/addToCart', isLoggedIn, isUser, addToCart);
18 | router.get('/getCart', isLoggedIn, isUser, getCart);
19 |
20 |
21 | module.exports = router;
--------------------------------------------------------------------------------
/Capstone/Backend/Routes/category.route.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 |
4 | const {
5 | addNewCategory,
6 | getCategory
7 | } = require('../Controllers/category.controller')
8 |
9 | const {
10 | isLoggedIn,
11 | isAdmin
12 | } = require('../middleware/auth.middleware');
13 |
14 |
15 | const {
16 | validateCreateCategoryRequest,
17 | isRequestCorrect
18 | } = require('../middleware/request.validator');
19 |
20 |
21 | router.post("/create", isLoggedIn, isAdmin, validateCreateCategoryRequest, isRequestCorrect, addNewCategory)
22 | router.get("/get", getCategory)
23 |
24 | module.exports = router;
--------------------------------------------------------------------------------
/Capstone/Backend/Routes/index.route.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 |
4 | const authRoutes = require('./auth.route')
5 | const categoryRoutes = require('./category.route')
6 | const productRoutes = require('./product.route')
7 | const cartRoutes = require('./cart.route')
8 | const adminIndexRoutes = require('./admin/index.route')
9 |
10 | router.use("/", authRoutes)
11 | router.use("/category", categoryRoutes)
12 | router.use("/admin", adminIndexRoutes)
13 | router.use("/product", productRoutes)
14 | router.use("/cart", cartRoutes)
15 |
16 | module.exports = router;
--------------------------------------------------------------------------------
/Capstone/Backend/Routes/product.route.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 |
4 | const {
5 | addNewProduct,
6 | getProduct
7 | } = require('../Controllers/product.controller')
8 |
9 | const {
10 | isLoggedIn,
11 | isAdmin
12 | } = require('../middleware/auth.middleware');
13 |
14 | const {
15 | upload
16 | } = require('../middleware/common.middleware');
17 |
18 |
19 | router.post("/create", isLoggedIn, isAdmin, upload.array('productImages'), addNewProduct)
20 | router.get("/get", getProduct)
21 |
22 | module.exports = router;
--------------------------------------------------------------------------------
/Capstone/Backend/database/db.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose');
2 | const password = encodeURIComponent(process.env.DB_PASSWORD);
3 |
4 | const url = `mongodb+srv://${process.env.DB_USER}:${password}@cluster0.syhxj.mongodb.net/${process.env.DB_NAME}?retryWrites=true&w=majority`;
5 |
6 | mongoose.connect(url, {
7 | useNewUrlParser: true,
8 | useUnifiedTopology: true
9 | })
10 |
11 | const dbConn = mongoose.connection;
12 |
13 | dbConn.on("error", console.error.bind(console, "Connection Error"));
14 | dbConn.on("open", function () {
15 | console.log("DB Connection Successful");
16 | });
17 |
18 | module.exports = dbConn;
--------------------------------------------------------------------------------
/Capstone/Backend/helpers/helper.js:
--------------------------------------------------------------------------------
1 | const jsonwebtoken = require('jsonwebtoken');
2 |
3 | const generateJwtToken = (id, role) => {
4 | return jsonwebtoken.sign({
5 | id,
6 | role
7 | }, process.env.JWT_SECRET_KEY, {
8 | expiresIn: '1d'
9 | });
10 | }
11 |
12 | const ErrorArray = [];
13 | ErrorArray[500] = "DB Error Occurred. Contact your administrator"
14 | ErrorArray[400] = "Bad Request"
15 |
16 | const getErrorResponse = (res, statusCode, message = null, error = null) => {
17 |
18 | return res.status(statusCode).json({
19 | success: false,
20 | message: message || ErrorArray[statusCode],
21 | error: error || ""
22 | })
23 | }
24 |
25 |
26 | const getResponseV1 = (res, statusCode, message = "", data = []) => {
27 |
28 | return res.status(statusCode).json({
29 | success: true,
30 | message: message,
31 | data: data
32 | })
33 | }
34 |
35 |
36 | const getResponseV2 = (res, state, statusCode, message = "", data = []) => {
37 |
38 | return res.status(statusCode).json({
39 | success: state,
40 | message: message,
41 | data: data
42 | })
43 | }
44 |
45 |
46 | module.exports = {
47 | generateJwtToken,
48 | getErrorResponse,
49 | getResponseV1,
50 | getResponseV2
51 | }
--------------------------------------------------------------------------------
/Capstone/Backend/middleware/auth.middleware.js:
--------------------------------------------------------------------------------
1 | const jsonwebtoken = require('jsonwebtoken');
2 |
3 | const isLoggedIn = (req, res, next) => {
4 | if (req.headers.authorization) {
5 | const token = req.headers.authorization.split(' ')[1];
6 | let user = {};
7 | try {
8 | user = jsonwebtoken.verify(token, process.env.JWT_SECRET_KEY);
9 | } catch (error) {
10 | return res.status(400).json({
11 | success: false,
12 | message: 'Bad Request',
13 | error: error
14 | })
15 | }
16 | req.user = user;
17 | } else {
18 | return res.status(401).json({
19 | success: false,
20 | message: 'Unauthorized Request'
21 | })
22 | }
23 | next();
24 | }
25 |
26 | const isUser = (req, res, next) => {
27 | if (req.user.role != 'user') {
28 | return res.status(403).json({
29 | success: false,
30 | message: "Access Forbidden."
31 | });
32 | }
33 | next();
34 | }
35 |
36 | const isAdmin = (req, res, next) => {
37 | if (req.user.role == 'user') {
38 | return res.status(403).json({
39 | success: false,
40 | message: "Access Forbidden."
41 | });
42 | }
43 | next();
44 | }
45 |
46 |
47 | module.exports = {
48 | isLoggedIn,
49 | isUser,
50 | isAdmin
51 | }
--------------------------------------------------------------------------------
/Capstone/Backend/middleware/common.middleware.js:
--------------------------------------------------------------------------------
1 | const multer = require('multer');
2 | const path = require('path');
3 | const {
4 | nanoid
5 | } = require('nanoid');
6 |
7 | const storage = multer.diskStorage({
8 | destination: function (req, file, cb) {
9 | cb(null, path.join(path.dirname(__dirname), "uploads"))
10 | },
11 | filename: function (req, file, cb) {
12 | cb(null, nanoid() + '-' + file.originalname)
13 | }
14 | })
15 |
16 | const upload = multer({
17 | storage: storage
18 | })
19 |
20 | module.exports = {
21 | upload
22 | }
--------------------------------------------------------------------------------
/Capstone/Backend/middleware/request.validator.js:
--------------------------------------------------------------------------------
1 | const {
2 | check,
3 | validationResult
4 | } = require('express-validator');
5 |
6 | const validateSignUpRequest = [
7 | check('firstname').notEmpty().withMessage("First Name is required"),
8 | check('lastname').notEmpty().withMessage("Last Name is required"),
9 | check('email').isEmail().withMessage("Validate Email is required"),
10 | check('password').isLength({
11 | min: 6
12 | }).withMessage("Password Min Length Should be 6 characters"),
13 | ]
14 |
15 | const validateSignInRequest = [
16 | check('email').isEmail().withMessage("Validate Email is required"),
17 | check('password').isLength({
18 | min: 6
19 | }).withMessage("Password Min Length Should be 6 characters"),
20 | ]
21 |
22 |
23 | const validateCreateCategoryRequest = [
24 | check('name').notEmpty().withMessage("Category Name is required")
25 | ]
26 |
27 | /**
28 | * ---Difficult----
29 | * custom validator
30 | *
31 | * https://stackoverflow.com/questions/37339479/express-validator-to-validate-parameter-which-is-an-array
32 | * https://express-validator.github.io/docs/custom-validators-sanitizers.html#example-converting-to-mongodbs-objectid
33 | * */
34 | const validateAddToCartRequest = [
35 | check('cartItems').notEmpty().withMessage("Please add one or more items to the cart")
36 | ]
37 |
38 |
39 | const isRequestCorrect = (req, res, next) => {
40 | const errors = validationResult(req);
41 | if (errors.array().length > 0) {
42 |
43 | return res.status(400).json({
44 | success: false,
45 | message: "Invalid Request",
46 | errors: errors.array()[0].msg
47 | })
48 | }
49 | next();
50 | }
51 |
52 | module.exports = {
53 | validateSignUpRequest,
54 | validateSignInRequest,
55 | validateCreateCategoryRequest,
56 | validateAddToCartRequest,
57 | isRequestCorrect,
58 | }
--------------------------------------------------------------------------------
/Capstone/Backend/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "shape-ai-capstone",
3 | "version": "1.0.0",
4 | "description": "An ecommerce platform",
5 | "main": "server.js",
6 | "scripts": {
7 | "start": "nodemon server.js",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "keywords": [
11 | "Ecommerce",
12 | "Node",
13 | "APIs",
14 | "Mongodb",
15 | "Express"
16 | ],
17 | "author": "Vishal Jain",
18 | "license": "ISC",
19 | "dependencies": {
20 | "bcrypt": "^5.0.1",
21 | "cors": "^2.8.5",
22 | "dotenv": "^10.0.0",
23 | "express": "^4.17.1",
24 | "express-validator": "^6.12.1",
25 | "jsonwebtoken": "^8.5.1",
26 | "mongoose": "^6.0.4",
27 | "multer": "^1.4.3",
28 | "nanoid": "^3.1.25",
29 | "slugify": "^1.6.0"
30 | },
31 | "devDependencies": {
32 | "nodemon": "^2.0.12"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Capstone/Backend/readme.md:
--------------------------------------------------------------------------------
1 | #E-commerce Backend Code-Base
2 |
3 | Resources to Read
4 |
5 |
6 | -packages
7 | -https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
8 | -nodemon // npm i nodemon --save-dev
9 |
10 |
11 | -API
12 | -Sign in
13 | -Sign Up
14 | -Validations.
15 |
16 |
17 |
18 |
19 | --Categories
20 | - Add New Categories - Admin Access is Required
21 | - Get all Categories - No Access
--------------------------------------------------------------------------------
/Capstone/Backend/server.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const cors = require('cors') //Cross-Origin Resource Sharing
3 | const dotenv = require('dotenv')
4 |
5 | //enable environment file
6 | dotenv.config()
7 |
8 | const db = require('./database/db')
9 | const app = express()
10 |
11 | app.use(cors())
12 | app.use(express.json())
13 |
14 | const indexRoutes = require('./Routes/index.route')
15 | app.use('/api', indexRoutes);
16 |
17 | //Start Server Call
18 | app.listen(process.env.PORT, () => {
19 | console.log(`Listening at http://localhost:${process.env.PORT}`)
20 | })
--------------------------------------------------------------------------------
/Capstone/Backend/uploads/15.381034810400562-samsung-guru-fm-plus-side.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Capstone/Backend/uploads/15.381034810400562-samsung-guru-fm-plus-side.jpeg
--------------------------------------------------------------------------------
/Capstone/Backend/uploads/27.0571917227052-samsung-guru-fm-plus.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Capstone/Backend/uploads/27.0571917227052-samsung-guru-fm-plus.jpeg
--------------------------------------------------------------------------------
/Capstone/Backend/uploads/29.852015591065673-samsung-guru-fm-plus-sm-b110e-d-sm-b110e-d-original-imaea9fqzyqdwm3r.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Capstone/Backend/uploads/29.852015591065673-samsung-guru-fm-plus-sm-b110e-d-sm-b110e-d-original-imaea9fqzyqdwm3r.jpeg
--------------------------------------------------------------------------------
/Capstone/Backend/uploads/34.92758743931679-samsung-guru-fm-plus-sm-b110e-d-sm-b110e-d-original-imaea9fqzyqdwm3r.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Capstone/Backend/uploads/34.92758743931679-samsung-guru-fm-plus-sm-b110e-d-sm-b110e-d-original-imaea9fqzyqdwm3r.jpeg
--------------------------------------------------------------------------------
/Capstone/Backend/uploads/4.930121625296668-samsung-guru-fm-plus.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Capstone/Backend/uploads/4.930121625296668-samsung-guru-fm-plus.jpeg
--------------------------------------------------------------------------------
/Capstone/Backend/uploads/41.581756917683975-samsung-guru-fm-plus.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Capstone/Backend/uploads/41.581756917683975-samsung-guru-fm-plus.jpeg
--------------------------------------------------------------------------------
/Capstone/Backend/uploads/42.57039326432608-samsung-guru-fm-plus-back.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Capstone/Backend/uploads/42.57039326432608-samsung-guru-fm-plus-back.jpeg
--------------------------------------------------------------------------------
/Capstone/Backend/uploads/55.176086837053816-samsung-guru-fm-plus-side.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Capstone/Backend/uploads/55.176086837053816-samsung-guru-fm-plus-side.jpeg
--------------------------------------------------------------------------------
/Capstone/Backend/uploads/62.455371775117065-samsung-guru-fm-plus.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Capstone/Backend/uploads/62.455371775117065-samsung-guru-fm-plus.jpeg
--------------------------------------------------------------------------------
/Capstone/Backend/uploads/69.06201890297314-samsung-guru-fm-plus-back.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Capstone/Backend/uploads/69.06201890297314-samsung-guru-fm-plus-back.jpeg
--------------------------------------------------------------------------------
/Capstone/Backend/uploads/97.80426030498037-samsung-guru-fm-plus-back.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Capstone/Backend/uploads/97.80426030498037-samsung-guru-fm-plus-back.jpeg
--------------------------------------------------------------------------------
/Capstone/Backend/uploads/99.3994107514538-samsung-guru-fm-plus-back.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Capstone/Backend/uploads/99.3994107514538-samsung-guru-fm-plus-back.jpeg
--------------------------------------------------------------------------------
/Capstone/Backend/uploads/samsung-guru-fm-plus-back.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Capstone/Backend/uploads/samsung-guru-fm-plus-back.jpeg
--------------------------------------------------------------------------------
/Capstone/Backend/uploads/samsung-guru-fm-plus.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Capstone/Backend/uploads/samsung-guru-fm-plus.jpeg
--------------------------------------------------------------------------------
/Code-base/Day10/assets/css/style.css:
--------------------------------------------------------------------------------
1 | * {
2 | font-family: "Source Sans Pro", sans-serif;
3 | }
4 |
5 |
6 | .header {
7 | box-shadow: 0px 1px 4px #ccc;
8 | height: 75px;
9 | }
10 |
11 |
12 | .bg-primary {
13 | background-color: #04AA6D !important;
14 | }
15 |
16 | .logo {
17 | width: 45px;
18 | height: auto;
19 | }
20 |
21 | .br-50 {
22 | border-radius: 50%;
23 | }
24 |
25 | .login-btn {
26 | border-radius: 25px;
27 | max-width: 100px;
28 | width: 100%;
29 | font-size: 12px;
30 | min-width: 70px;
31 | padding: 8px 0px;
32 | }
33 |
34 |
35 | .span-primary-hover:hover {
36 | border-radius: 25px;
37 | max-width: 150px;
38 | line-height: 2;
39 | padding: 8px 16px;
40 | }
41 |
42 | .header .row>* {
43 | height: 100%;
44 | display: flex;
45 | flex-flow: row nowrap;
46 | align-items: center;
47 | }
48 |
49 | .primary-hover {
50 | min-width: 90px;
51 | }
52 |
53 | i.fa-caret-down{
54 | font-size: 18px;
55 | }
56 |
57 | .primary-hover:hover {
58 | background-color: #04AA6D;
59 | color: white;
60 | }
61 |
62 |
63 | .primary-hover:hover i {
64 | transform: rotateX(180deg);
65 | }
66 |
67 |
68 | .nav-icons {
69 | padding: 0 1em;
70 | font-size: 18px;
71 | }
72 |
73 | .nav-icons:last-child{
74 | padding-right: 0;
75 | }
76 |
77 | @media (min-width:861px) {
78 | .d-xm-flex {
79 | display: flex !important;
80 | }
81 |
82 | .d-xm-none {
83 | display: none !important;
84 | }
85 |
86 | .offset-xm-0{
87 | margin: 0;
88 | }
89 | }
90 |
91 |
92 | @media (min-width:992px) {
93 | .primary-hover {
94 | padding: 0 10px;
95 | }
96 | }
--------------------------------------------------------------------------------
/Code-base/Day10/assets/images/W3Schools_logo.svg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day10/assets/images/W3Schools_logo.svg
--------------------------------------------------------------------------------
/Code-base/Day10/assets/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day10/assets/images/logo.png
--------------------------------------------------------------------------------
/Code-base/Day10/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
12 |
13 |
14 |
17 |
18 |
19 |
20 | Hello, world!
21 |
22 |
23 |
24 |
25 |
67 |
68 |
69 |
70 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/Code-base/Day13/assets/css/style.css:
--------------------------------------------------------------------------------
1 | .font-bold {
2 | font-weight: 800;
3 | color: royalblue;
4 | font-size: 20px;
5 | }
--------------------------------------------------------------------------------
/Code-base/Day13/assets/js/main.js:
--------------------------------------------------------------------------------
1 | var b ,c ='4.0';
2 | console.log(b, c);
3 | b = 4;
4 | console.log(b, c);
5 |
6 | console.log(addFontBoldClass);
7 |
8 | function addFontBoldClass() {
9 | var class_name = "font-bold";
10 | return class_name;
11 | }
12 | /*
13 |
14 | ' b = undefined '
15 | ' c = undefined '
16 | ' addFontBoldClass = { '
17 | ' var class_name = "font-bold"; '
18 | ' return class_name; '
19 | ' } '
20 | '-----------------------------------------'
21 | Memory Space / Global Space
22 |
23 | ' b = undefined '
24 | ' c = undefined '
25 | ' addFontBoldClass = { '
26 | ' var class_name = "font-bold"; '
27 | ' return class_name; '
28 | ' } '
29 | '-----------------------------------------'
30 | Content Execution Space
31 |
32 | var a = document.getElementById('demo').classList; //statement
33 |
34 | everything inside a {} is a block
35 |
36 | == will check only the Value of the variable NOT THE DATA TYPE
37 | number + number = number
38 | string + string/number/boolean = string
39 | js programs is collection of statements.
40 |
41 | */
--------------------------------------------------------------------------------
/Code-base/Day13/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Hello, Javascript!
9 |
10 |
11 |
12 |
16 |
20 |
21 |
22 |
33 |
47 |
48 |
49 |
50 |
51 | JavaScript can change the style of an HTML element.
52 |
53 | add font-bold
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/Code-base/Day14/assets/css/style.css:
--------------------------------------------------------------------------------
1 | /* Create the Outer layout of the Calculator. */
2 | .formstyle {
3 | width: 300px;
4 | height: 330px;
5 | margin: 20px auto;
6 | border: 3px solid skyblue;
7 | border-radius: 5px;
8 | padding: 20px;
9 | text-align: center;
10 | background-color: grey;
11 | }
12 |
13 | /* Display top horizontal bar that contain some information. */
14 | h1 {
15 | text-align: center;
16 | padding: 23px;
17 | background-color: skyblue;
18 | color: white;
19 | }
20 |
21 | input:hover {
22 | background-color: green;
23 | }
24 |
25 | * {
26 | margin: 0;
27 | padding: 0;
28 | }
29 |
30 | /* It is used to create the layout for calculator button. */
31 | .btn {
32 | width: 50px;
33 | height: 50px;
34 | font-size: 25px;
35 | margin: 2px;
36 | cursor: pointer;
37 | background-color: red;
38 | color: white;
39 |
40 | }
41 |
42 | /* It is used to display the numbers, operations and results. */
43 | .textview {
44 | width: 223px;
45 | margin: 5px;
46 | font-size: 25px;
47 | padding: 5px;
48 | background-color: lightgreen;
49 | }
--------------------------------------------------------------------------------
/Code-base/Day14/assets/js/main.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | HOISTING
4 | ' b = undefined '
5 | ' c = undefined '
6 | ' addFontBoldClass = { '
7 | ' var class_name = "font-bold"; '
8 | ' return class_name; '
9 | ' } '
10 | '-----------------------------------------'
11 | Memory Space / Global Space
12 |
13 | ' b = undefined '
14 | ' c = undefined '
15 | ' addFontBoldClass = { '
16 | ' var class_name = "font-bold"; '
17 | ' return class_name; '
18 | ' } '
19 | '-----------------------------------------'
20 | Content Execution Space
21 |
22 | var a = document.getElementById('demo').classList; //statement
23 |
24 | everything inside a {} is a block
25 |
26 | == will check only the Value of the variable NOT THE DATA TYPE
27 | number + number = number
28 | string + string/number/boolean = string
29 | js programs is collection of statements.
30 |
31 | */
32 |
33 | /*
34 | INSERT
35 | CLEAR
36 | BACKSPACE // it will remove the last character from the input
37 | in Java/C++ we have substring
38 |
39 | equal
40 | */
41 |
42 | var expression = document.getElementById("result");
43 |
44 | function insert(param) {
45 | expression.value += param;
46 | }
47 |
48 | function backspace() {
49 | expression.value = expression.value.slice(0, -1);
50 | }
51 |
52 | function clearInput() {
53 | expression.value = "";
54 | }
55 |
56 | function equal() {
57 | console.log(expression.value);
58 | expression.value = eval(expression.value);
59 | }
60 |
61 |
62 |
63 |
64 | function equalWithoutEval() {
65 |
66 | let expArr = [...expression.value];
67 | console.log(expArr);
68 | let ops = "*/+-",
69 | tempNum = "",
70 | result = 0;
71 | //12+23*9;
72 | for (let i = 0; i < expArr.length; i++) {
73 | let ch = expArr[i];
74 |
75 | if (ops.includes(ch)) {
76 |
77 | switch (ch) {
78 | case '+':
79 | result += parseInt(tempNum);
80 | break;
81 | case '-':
82 | result -= parseInt(tempNum);
83 | break;
84 | case '/':
85 | result /= parseInt(tempNum);
86 | break;
87 | case '*':
88 | result *= parseInt(tempNum);
89 | break;
90 | }
91 | tempNum = "";
92 | } else
93 | tempNum += ch;
94 | }
95 |
96 | console.log(tempNum, result);
97 | }
98 | /**
99 | *
100 | *
101 | *
102 | * Eval input is string
103 | *
104 | *
105 | * Processing it will convert the String into Javascript Code
106 | *
107 | * and then it will execute.
108 | *
109 | * **/
110 |
111 |
112 |
113 |
114 | /********************** */
115 |
116 |
117 |
118 | /****
119 | *
120 | *
121 | *
122 | * payment( ac ){
123 | *
124 | * var a = verify(ac) {.....}
125 | *
126 | *
127 | * if(a === true)
128 | * var a = icici(ac){ ..... return [ac , ifsc , actype] };
129 | * else
130 | * throw error )
131 | * }
132 | *
133 | *
134 | *
135 | */
--------------------------------------------------------------------------------
/Code-base/Day14/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Calculator Program in JavaScript
8 |
9 |
10 |
11 |
12 |
13 |
14 | Calculator Program in JavaScript
15 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/Code-base/Day15/assets/css/style.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day15/assets/css/style.css
--------------------------------------------------------------------------------
/Code-base/Day15/assets/images/black-widow.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day15/assets/images/black-widow.jpg
--------------------------------------------------------------------------------
/Code-base/Day15/assets/images/captain-marvel.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day15/assets/images/captain-marvel.jpg
--------------------------------------------------------------------------------
/Code-base/Day15/assets/images/dr-strange.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day15/assets/images/dr-strange.jpg
--------------------------------------------------------------------------------
/Code-base/Day15/assets/images/hawk-eye.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day15/assets/images/hawk-eye.jpg
--------------------------------------------------------------------------------
/Code-base/Day15/assets/images/iron-man.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day15/assets/images/iron-man.jpg
--------------------------------------------------------------------------------
/Code-base/Day15/assets/images/spiderman.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day15/assets/images/spiderman.jpg
--------------------------------------------------------------------------------
/Code-base/Day15/assets/images/the-hulk.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day15/assets/images/the-hulk.jpg
--------------------------------------------------------------------------------
/Code-base/Day15/assets/images/thor.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day15/assets/images/thor.jpg
--------------------------------------------------------------------------------
/Code-base/Day15/assets/js/main.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Use Loops , Functions
4 | *
5 | * And Manipulate the DOM
6 | *
7 | *
8 | *
9 | */
10 |
11 |
12 |
13 |
14 | //This is a JSON.. JavaScript Object Notion
15 | let avengers = [{
16 | name: "black-widow.jpg",
17 | alt: "The Black widow is my fav"
18 | }, {
19 | name: "iron-man.jpg",
20 | alt: "I am IRON MAN"
21 | }, {
22 | name: "captain-marvel.jpg",
23 | alt: "The Prettiest"
24 | }, {
25 | name: "dr-strange.jpg",
26 | alt: "It's precisely what's kept you from greatness"
27 | }, {
28 | name: "the-hulk.jpg",
29 | alt: "It's like I was MEANT FOR THIS"
30 | }, {
31 | name: "thor.jpg",
32 | alt: "Bring me THANOS!!!!"
33 | }, {
34 | name: "hawk-eye.jpg",
35 | alt: "The Black widow forever"
36 | }, {
37 | name: "spiderman.jpg",
38 | alt: "Big FAN Of CAP"
39 | }];
40 |
41 | const imageUrl = "./assets/images";
42 |
43 |
44 | document.getElementById("gallery").innerHTML = function () {
45 | let gridHTML = '';
46 | try {
47 | avengers.forEach(avenger => {
48 | gridHTML += generateColumn(avenger.name, avenger.alt);
49 | });
50 | return gridHTML;
51 | } catch (Error) {
52 | console.log(Error);
53 | return "Avengers in the End Game";
54 | }
55 | }();
56 |
57 |
58 |
59 | function generateColumn(imgSrc, imgAlt) {
60 | return `
61 |
62 |
`;
63 | }
64 |
65 |
66 |
67 | /***
68 | * add_to_avaengers_arr()
69 | *
70 | * Add to avengers json.
71 | * It will create a new column.
72 | *
73 | * create a form. Handle to onsubmit of the form.
74 | * take values from two inputs(text)
75 | * one for image name
76 | * other for image alternative text
77 | *
78 | *
79 | * onclick of submit get the values /
80 | *
81 | *
82 | * -------------Tricky part----------------
83 | * Add to array and update the grid
84 | *
85 | */
--------------------------------------------------------------------------------
/Code-base/Day15/assets/js/main2.js:
--------------------------------------------------------------------------------
1 | var dc_cHAR = [{
2 |
3 |
4 |
5 | }];
6 |
7 |
8 |
9 |
10 |
11 | init();
--------------------------------------------------------------------------------
/Code-base/Day15/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Calculator Program in JavaScript
8 |
9 |
10 |
11 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/Code-base/Day16/assets/css/style.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day16/assets/css/style.css
--------------------------------------------------------------------------------
/Code-base/Day16/assets/images/black-widow.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day16/assets/images/black-widow.jpg
--------------------------------------------------------------------------------
/Code-base/Day16/assets/images/captain-marvel.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day16/assets/images/captain-marvel.jpg
--------------------------------------------------------------------------------
/Code-base/Day16/assets/images/dr-strange.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day16/assets/images/dr-strange.jpg
--------------------------------------------------------------------------------
/Code-base/Day16/assets/images/hawk-eye.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day16/assets/images/hawk-eye.jpg
--------------------------------------------------------------------------------
/Code-base/Day16/assets/images/iron-man.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day16/assets/images/iron-man.jpg
--------------------------------------------------------------------------------
/Code-base/Day16/assets/images/spiderman.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day16/assets/images/spiderman.jpg
--------------------------------------------------------------------------------
/Code-base/Day16/assets/images/the-hulk.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day16/assets/images/the-hulk.jpg
--------------------------------------------------------------------------------
/Code-base/Day16/assets/images/thor.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day16/assets/images/thor.jpg
--------------------------------------------------------------------------------
/Code-base/Day16/assets/js/main.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Use Loops , Functions
4 | *
5 | * And Manipulate the DOM
6 | *
7 | *
8 | *
9 | */
10 |
11 |
12 |
13 |
14 | //This is a JSON.. JavaScript Object Notion
15 | let avengers = [{
16 | name: "black-widow.jpg",
17 | alt: "The Black widow is my fav"
18 | }, {
19 | name: "iron-man.jpg",
20 | alt: "I am IRON MAN"
21 | }, {
22 | name: "captain-marvel.jpg",
23 | alt: "The Prettiest"
24 | }, {
25 | name: "dr-strange.jpg",
26 | alt: "It's precisely what's kept you from greatness"
27 | }, {
28 | name: "the-hulk.jpg",
29 | alt: "It's like I was MEANT FOR THIS"
30 | }, {
31 | name: "thor.jpg",
32 | alt: "Bring me THANOS!!!!"
33 | }, {
34 | name: "hawk-eye.jpg",
35 | alt: "The Black widow forever"
36 | }, {
37 | name: "spiderman.jpg",
38 | alt: "Big FAN Of CAP"
39 | }];
40 |
41 | const imageUrl = "./assets/images";
42 |
43 |
44 | document.getElementById("gallery").innerHTML = function () {
45 | let gridHTML = '';
46 | try {
47 | avengers.forEach(avenger => {
48 | gridHTML += generateColumn(avenger.name, avenger.alt);
49 | });
50 | return gridHTML;
51 | } catch (Error) {
52 | console.log(Error);
53 | return "Avengers in the End Game";
54 | }
55 | }();
56 |
57 |
58 |
59 | function generateColumn(imgSrc, imgAlt) {
60 | return `
61 |
62 |
`;
63 | }
64 |
65 |
66 |
67 | /***
68 | * add_to_avaengers_arr()
69 | *
70 | * Add to avengers json.
71 | * It will create a new column.
72 | *
73 | */
74 |
75 |
76 | /***
77 | * remove_an_avaengers_arr()
78 | *
79 | * remove to avengers json.
80 | * It will delete a column when you click on the avenger image
81 | *
82 | */
83 |
84 |
85 |
86 |
87 | function add_to_avaengers_arr() {
88 |
89 |
90 |
91 | }
--------------------------------------------------------------------------------
/Code-base/Day16/assets/js/main2.js:
--------------------------------------------------------------------------------
1 | var dc_cHAR = [{
2 |
3 |
4 |
5 | }];
6 |
7 |
8 |
9 |
10 |
11 | init();
--------------------------------------------------------------------------------
/Code-base/Day16/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Calculator Program in JavaScript
8 |
9 |
10 |
11 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/Code-base/Day17/assets/css/style.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day17/assets/css/style.css
--------------------------------------------------------------------------------
/Code-base/Day17/assets/images/black-widow.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day17/assets/images/black-widow.jpg
--------------------------------------------------------------------------------
/Code-base/Day17/assets/images/captain-marvel.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day17/assets/images/captain-marvel.jpg
--------------------------------------------------------------------------------
/Code-base/Day17/assets/images/dr-strange.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day17/assets/images/dr-strange.jpg
--------------------------------------------------------------------------------
/Code-base/Day17/assets/images/hawk-eye.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day17/assets/images/hawk-eye.jpg
--------------------------------------------------------------------------------
/Code-base/Day17/assets/images/iron-man.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day17/assets/images/iron-man.jpg
--------------------------------------------------------------------------------
/Code-base/Day17/assets/images/spiderman.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day17/assets/images/spiderman.jpg
--------------------------------------------------------------------------------
/Code-base/Day17/assets/images/the-hulk.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day17/assets/images/the-hulk.jpg
--------------------------------------------------------------------------------
/Code-base/Day17/assets/images/thor.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day17/assets/images/thor.jpg
--------------------------------------------------------------------------------
/Code-base/Day17/assets/js/main.js:
--------------------------------------------------------------------------------
1 | //This is a JSON.. JavaScript Object Notion
2 | let avengers = [{
3 | name: "black-widow.jpg",
4 | alt: "The Black widow is my fav"
5 | }, {
6 | name: "iron-man.jpg",
7 | alt: "I am IRON MAN"
8 | }, {
9 | name: "captain-marvel.jpg",
10 | alt: "The Prettiest"
11 | }, {
12 | name: "dr-strange.jpg",
13 | alt: "It's precisely what's kept you from greatness"
14 | }, {
15 | name: "the-hulk.jpg",
16 | alt: "It's like I was MEANT FOR THIS"
17 | }, {
18 | name: "thor.jpg",
19 | alt: "Bring me THANOS!!!!"
20 | }, {
21 | name: "hawk-eye.jpg",
22 | alt: "The Black widow forever"
23 | }, {
24 | name: "spiderman.jpg",
25 | alt: "Big FAN Of CAP"
26 | }];
27 |
28 | var b = ["String", 5, 50.1, {
29 | name: "iron-man.jpg",
30 | alt: "I am IRON MAN"
31 | }]
32 |
33 | /**
34 | * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push
35 | *
36 | *
37 | *
38 | */
39 |
40 | b.push("This is element at index 4");
41 | console.log(b[3]);
42 |
43 | b[10] = 200;
44 | b[7] = avengers;
45 | console.log(b);
46 |
47 |
48 | /**
49 | * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift
50 | *
51 | * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join
52 | */
53 | b.unshift("At the start")
54 | console.log(b.join(" | "))
55 | console.log(b)
56 | /**
57 | * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop
58 | *
59 | */
60 | var last_el = b.pop();
61 |
62 | ////6 7,8,9 10=200
63 | console.log(last_el)
64 | console.log(b)
65 |
66 |
67 | /**
68 | * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
69 | */
70 |
71 | var first_el = b.shift();
72 | console.log(first_el);
73 |
74 |
75 | /**
76 | * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
77 | */
78 | var start = 0,
79 | end = 4;
80 | var a = b.slice(start, end)
81 |
82 |
83 | /**
84 | * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
85 | */
86 | var start = 0,
87 | end = 4;
88 | var c = b.splice(start, end, ...avengers)
89 |
90 |
91 | console.log(a, c);
92 |
93 | console.log(b)
--------------------------------------------------------------------------------
/Code-base/Day17/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Arrays in JavaScript
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Code-base/Day19/assets/css/style.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day19/assets/css/style.css
--------------------------------------------------------------------------------
/Code-base/Day19/assets/js/main.js:
--------------------------------------------------------------------------------
1 | // function expression(exp) {
2 | // let temp = "VJ";
3 |
4 | // const greet = (who) => {
5 | // console.log(who, exp, temp)
6 | // }
7 | // greet("PR")
8 | // return greet;
9 | // }
10 |
11 |
12 |
13 | // var greetFn = expression("Annoyed");
14 |
15 |
16 | // console.log("Expression Memmory is removed")
17 |
18 | // greetFn("Harvey");
19 |
20 |
21 |
22 |
23 | function expression(exp, callback) {
24 | let temp = "VJ";
25 | console.log("Inside expression ",
26 | exp, temp)
27 | callback(temp);
28 | }
29 |
30 | const greet = (who) => {
31 | console.log("Inside Greet");
32 | console.log("Great", who);
33 | // expression(who,slap);
34 | }
35 |
36 | const slap = (who) => {
37 | console.log("Inside slap");
38 | console.log("Great", who);
39 | greet(who);
40 | }
41 |
42 |
43 | expression("Happy", happy_ads);
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Code-base/Day19/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Arrays in JavaScript
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Code-base/Day20/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * HTTP is a built-in module. It allows node to transfer data using Hyper Text Trasfer Protocol (HTTP)
3 | *
4 | *
5 | */
6 |
7 |
8 | var http = require('http');
9 |
10 |
11 | http.createServer(function (req, res) {
12 |
13 | console.log(req);
14 | console.log("Listening to 8080")
15 | res.write("Hello World");
16 | res.end();
17 |
18 | }).listen('8080');
--------------------------------------------------------------------------------
/Code-base/Day20/node_modules/http/README.md:
--------------------------------------------------------------------------------
1 | # Security holding package
2 |
3 | This package name is not currently in use, but was formerly occupied
4 | by another package. To avoid malicious use, npm is hanging on to the
5 | package name, but loosely, and we'll probably give it to you if you
6 | want it.
7 |
8 | You may adopt this package by contacting support@npmjs.com and
9 | requesting the name.
10 |
--------------------------------------------------------------------------------
/Code-base/Day20/node_modules/http/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "_from": "http",
3 | "_id": "http@0.0.1-security",
4 | "_inBundle": false,
5 | "_integrity": "sha512-RnDvP10Ty9FxqOtPZuxtebw1j4L/WiqNMDtuc1YMH1XQm5TgDRaR1G9u8upL6KD1bXHSp9eSXo/ED+8Q7FAr+g==",
6 | "_location": "/http",
7 | "_phantomChildren": {},
8 | "_requested": {
9 | "type": "tag",
10 | "registry": true,
11 | "raw": "http",
12 | "name": "http",
13 | "escapedName": "http",
14 | "rawSpec": "",
15 | "saveSpec": null,
16 | "fetchSpec": "latest"
17 | },
18 | "_requiredBy": [
19 | "#USER",
20 | "/"
21 | ],
22 | "_resolved": "https://registry.npmjs.org/http/-/http-0.0.1-security.tgz",
23 | "_shasum": "3aac09129d12dc2747bbce4157afde20ad1f7995",
24 | "_spec": "http",
25 | "_where": "C:\\Users\\visjjain\\Desktop\\desktop\\ShapeAi-Assignments\\Code-base\\Day20",
26 | "bugs": {
27 | "url": "https://github.com/npm/security-holder/issues"
28 | },
29 | "bundleDependencies": false,
30 | "deprecated": false,
31 | "description": "security holding package",
32 | "homepage": "https://github.com/npm/security-holder#readme",
33 | "name": "http",
34 | "repository": {
35 | "type": "git",
36 | "url": "git+https://github.com/npm/security-holder.git"
37 | },
38 | "version": "0.0.1-security"
39 | }
40 |
--------------------------------------------------------------------------------
/Code-base/Day20/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "day20",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "http": {
8 | "version": "0.0.1-security",
9 | "resolved": "https://registry.npmjs.org/http/-/http-0.0.1-security.tgz",
10 | "integrity": "sha512-RnDvP10Ty9FxqOtPZuxtebw1j4L/WiqNMDtuc1YMH1XQm5TgDRaR1G9u8upL6KD1bXHSp9eSXo/ED+8Q7FAr+g=="
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Code-base/Day20/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "day20",
3 | "version": "1.0.0",
4 | "description": "Understanding Node",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "Vishal Jain",
10 | "license": "ISC",
11 | "dependencies": {
12 | "http": "0.0.1-security"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Code-base/Day21/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const app = express();
3 | const port = "8080";
4 |
5 |
6 |
7 | //Route I have created
8 | // app.get('/articles', (req, res) => {
9 | // res.send("On Articles Page!")
10 | // });
11 |
12 | app.get('/articles', (req, res) => {
13 | res.setHeader('content-type', 'text/html');
14 |
15 | res.send("On Articles Page! POST METHOD ")
16 | });
17 |
18 | app.get('/articles/rest-api', (req, res) => {
19 |
20 | const responseObj = {
21 | data: 'Article Info',
22 | messsage: 'API Call Successful'
23 | };
24 | res.json(responseObj)
25 | });
26 |
27 |
28 |
29 | app.get('/getAvengers', (req, res) => {
30 | res.json([{
31 | name: "black-widow.jpg",
32 | alt: "The Black widow is my fav"
33 | }, {
34 | name: "iron-man.jpg",
35 | alt: "I am IRON MAN"
36 | }, {
37 | name: "captain-marvel.jpg",
38 | alt: "The Prettiest"
39 | }, {
40 | name: "dr-strange.jpg",
41 | alt: "It's precisely what's kept you from greatness"
42 | }, {
43 | name: "the-hulk.jpg",
44 | alt: "It's like I was MEANT FOR THIS"
45 | }, {
46 | name: "thor.jpg",
47 | alt: "Bring me THANOS!!!!"
48 | }, {
49 | name: "hawk-eye.jpg",
50 | alt: "The Black widow forever"
51 | }, {
52 | name: "spiderman.jpg",
53 | alt: "Big FAN Of CAP"
54 | }]);
55 | })
56 | app.get('/articles/:article_id', (req, res) => {
57 |
58 | var article_id = req.params.article_id;
59 |
60 |
61 | const Article = get_article_by_id(article_id);
62 | const responseObj = {
63 | data: {
64 | res: Article
65 | },
66 | messsage: 'API Call Successful'
67 | }
68 |
69 | res.json(responseObj)
70 | });
71 |
72 |
73 | app.get('/:city/:location', (req, res) => {
74 |
75 | var city = req.params.city;
76 | var location = req.params.location;
77 | res.send(`My URL has city as ${city} and location as ${location}`)
78 |
79 | });
80 |
81 |
82 | app.get('*', (req, res) => {
83 |
84 | res.send(`My Default URL`)
85 |
86 | });
87 |
88 |
89 |
90 |
91 |
92 | app.listen(port, () => {
93 | console.log(`Listening at http://localhost:${port} `)
94 | })
--------------------------------------------------------------------------------
/Code-base/Day21/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "day21",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "accepts": {
8 | "version": "1.3.7",
9 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
10 | "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
11 | "requires": {
12 | "mime-types": "~2.1.24",
13 | "negotiator": "0.6.2"
14 | }
15 | },
16 | "array-flatten": {
17 | "version": "1.1.1",
18 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
19 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
20 | },
21 | "body-parser": {
22 | "version": "1.19.0",
23 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
24 | "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==",
25 | "requires": {
26 | "bytes": "3.1.0",
27 | "content-type": "~1.0.4",
28 | "debug": "2.6.9",
29 | "depd": "~1.1.2",
30 | "http-errors": "1.7.2",
31 | "iconv-lite": "0.4.24",
32 | "on-finished": "~2.3.0",
33 | "qs": "6.7.0",
34 | "raw-body": "2.4.0",
35 | "type-is": "~1.6.17"
36 | }
37 | },
38 | "bytes": {
39 | "version": "3.1.0",
40 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
41 | "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg=="
42 | },
43 | "content-disposition": {
44 | "version": "0.5.3",
45 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
46 | "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==",
47 | "requires": {
48 | "safe-buffer": "5.1.2"
49 | }
50 | },
51 | "content-type": {
52 | "version": "1.0.4",
53 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
54 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA=="
55 | },
56 | "cookie": {
57 | "version": "0.4.0",
58 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
59 | "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg=="
60 | },
61 | "cookie-signature": {
62 | "version": "1.0.6",
63 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
64 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
65 | },
66 | "debug": {
67 | "version": "2.6.9",
68 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
69 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
70 | "requires": {
71 | "ms": "2.0.0"
72 | }
73 | },
74 | "depd": {
75 | "version": "1.1.2",
76 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
77 | "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
78 | },
79 | "destroy": {
80 | "version": "1.0.4",
81 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
82 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
83 | },
84 | "ee-first": {
85 | "version": "1.1.1",
86 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
87 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
88 | },
89 | "encodeurl": {
90 | "version": "1.0.2",
91 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
92 | "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
93 | },
94 | "escape-html": {
95 | "version": "1.0.3",
96 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
97 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
98 | },
99 | "etag": {
100 | "version": "1.8.1",
101 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
102 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
103 | },
104 | "express": {
105 | "version": "4.17.1",
106 | "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
107 | "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==",
108 | "requires": {
109 | "accepts": "~1.3.7",
110 | "array-flatten": "1.1.1",
111 | "body-parser": "1.19.0",
112 | "content-disposition": "0.5.3",
113 | "content-type": "~1.0.4",
114 | "cookie": "0.4.0",
115 | "cookie-signature": "1.0.6",
116 | "debug": "2.6.9",
117 | "depd": "~1.1.2",
118 | "encodeurl": "~1.0.2",
119 | "escape-html": "~1.0.3",
120 | "etag": "~1.8.1",
121 | "finalhandler": "~1.1.2",
122 | "fresh": "0.5.2",
123 | "merge-descriptors": "1.0.1",
124 | "methods": "~1.1.2",
125 | "on-finished": "~2.3.0",
126 | "parseurl": "~1.3.3",
127 | "path-to-regexp": "0.1.7",
128 | "proxy-addr": "~2.0.5",
129 | "qs": "6.7.0",
130 | "range-parser": "~1.2.1",
131 | "safe-buffer": "5.1.2",
132 | "send": "0.17.1",
133 | "serve-static": "1.14.1",
134 | "setprototypeof": "1.1.1",
135 | "statuses": "~1.5.0",
136 | "type-is": "~1.6.18",
137 | "utils-merge": "1.0.1",
138 | "vary": "~1.1.2"
139 | }
140 | },
141 | "finalhandler": {
142 | "version": "1.1.2",
143 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
144 | "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==",
145 | "requires": {
146 | "debug": "2.6.9",
147 | "encodeurl": "~1.0.2",
148 | "escape-html": "~1.0.3",
149 | "on-finished": "~2.3.0",
150 | "parseurl": "~1.3.3",
151 | "statuses": "~1.5.0",
152 | "unpipe": "~1.0.0"
153 | }
154 | },
155 | "forwarded": {
156 | "version": "0.2.0",
157 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
158 | "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow=="
159 | },
160 | "fresh": {
161 | "version": "0.5.2",
162 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
163 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
164 | },
165 | "http-errors": {
166 | "version": "1.7.2",
167 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
168 | "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==",
169 | "requires": {
170 | "depd": "~1.1.2",
171 | "inherits": "2.0.3",
172 | "setprototypeof": "1.1.1",
173 | "statuses": ">= 1.5.0 < 2",
174 | "toidentifier": "1.0.0"
175 | }
176 | },
177 | "iconv-lite": {
178 | "version": "0.4.24",
179 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
180 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
181 | "requires": {
182 | "safer-buffer": ">= 2.1.2 < 3"
183 | }
184 | },
185 | "inherits": {
186 | "version": "2.0.3",
187 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
188 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
189 | },
190 | "ipaddr.js": {
191 | "version": "1.9.1",
192 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
193 | "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g=="
194 | },
195 | "media-typer": {
196 | "version": "0.3.0",
197 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
198 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
199 | },
200 | "merge-descriptors": {
201 | "version": "1.0.1",
202 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
203 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
204 | },
205 | "methods": {
206 | "version": "1.1.2",
207 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
208 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
209 | },
210 | "mime": {
211 | "version": "1.6.0",
212 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
213 | "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
214 | },
215 | "mime-db": {
216 | "version": "1.49.0",
217 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.49.0.tgz",
218 | "integrity": "sha512-CIc8j9URtOVApSFCQIF+VBkX1RwXp/oMMOrqdyXSBXq5RWNEsRfyj1kiRnQgmNXmHxPoFIxOroKA3zcU9P+nAA=="
219 | },
220 | "mime-types": {
221 | "version": "2.1.32",
222 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.32.tgz",
223 | "integrity": "sha512-hJGaVS4G4c9TSMYh2n6SQAGrC4RnfU+daP8G7cSCmaqNjiOoUY0VHCMS42pxnQmVF1GWwFhbHWn3RIxCqTmZ9A==",
224 | "requires": {
225 | "mime-db": "1.49.0"
226 | }
227 | },
228 | "ms": {
229 | "version": "2.0.0",
230 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
231 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
232 | },
233 | "negotiator": {
234 | "version": "0.6.2",
235 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
236 | "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
237 | },
238 | "on-finished": {
239 | "version": "2.3.0",
240 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
241 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
242 | "requires": {
243 | "ee-first": "1.1.1"
244 | }
245 | },
246 | "parseurl": {
247 | "version": "1.3.3",
248 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
249 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="
250 | },
251 | "path-to-regexp": {
252 | "version": "0.1.7",
253 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
254 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
255 | },
256 | "proxy-addr": {
257 | "version": "2.0.7",
258 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
259 | "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
260 | "requires": {
261 | "forwarded": "0.2.0",
262 | "ipaddr.js": "1.9.1"
263 | }
264 | },
265 | "qs": {
266 | "version": "6.7.0",
267 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
268 | "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
269 | },
270 | "range-parser": {
271 | "version": "1.2.1",
272 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
273 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
274 | },
275 | "raw-body": {
276 | "version": "2.4.0",
277 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz",
278 | "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==",
279 | "requires": {
280 | "bytes": "3.1.0",
281 | "http-errors": "1.7.2",
282 | "iconv-lite": "0.4.24",
283 | "unpipe": "1.0.0"
284 | }
285 | },
286 | "safe-buffer": {
287 | "version": "5.1.2",
288 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
289 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
290 | },
291 | "safer-buffer": {
292 | "version": "2.1.2",
293 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
294 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
295 | },
296 | "send": {
297 | "version": "0.17.1",
298 | "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz",
299 | "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==",
300 | "requires": {
301 | "debug": "2.6.9",
302 | "depd": "~1.1.2",
303 | "destroy": "~1.0.4",
304 | "encodeurl": "~1.0.2",
305 | "escape-html": "~1.0.3",
306 | "etag": "~1.8.1",
307 | "fresh": "0.5.2",
308 | "http-errors": "~1.7.2",
309 | "mime": "1.6.0",
310 | "ms": "2.1.1",
311 | "on-finished": "~2.3.0",
312 | "range-parser": "~1.2.1",
313 | "statuses": "~1.5.0"
314 | },
315 | "dependencies": {
316 | "ms": {
317 | "version": "2.1.1",
318 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
319 | "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
320 | }
321 | }
322 | },
323 | "serve-static": {
324 | "version": "1.14.1",
325 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz",
326 | "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==",
327 | "requires": {
328 | "encodeurl": "~1.0.2",
329 | "escape-html": "~1.0.3",
330 | "parseurl": "~1.3.3",
331 | "send": "0.17.1"
332 | }
333 | },
334 | "setprototypeof": {
335 | "version": "1.1.1",
336 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
337 | "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
338 | },
339 | "statuses": {
340 | "version": "1.5.0",
341 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
342 | "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
343 | },
344 | "toidentifier": {
345 | "version": "1.0.0",
346 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
347 | "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
348 | },
349 | "type-is": {
350 | "version": "1.6.18",
351 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
352 | "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
353 | "requires": {
354 | "media-typer": "0.3.0",
355 | "mime-types": "~2.1.24"
356 | }
357 | },
358 | "unpipe": {
359 | "version": "1.0.0",
360 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
361 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
362 | },
363 | "utils-merge": {
364 | "version": "1.0.1",
365 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
366 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
367 | },
368 | "vary": {
369 | "version": "1.1.2",
370 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
371 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
372 | }
373 | }
374 | }
375 |
--------------------------------------------------------------------------------
/Code-base/Day21/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "day21",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "express": "^4.17.1"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Code-base/Day22/database/db.js:
--------------------------------------------------------------------------------
1 | let books = [{
2 | book_id: "12345ONE",
3 | title: "Getting started with MERN",
4 | authors: [1, 2],
5 | language: "en",
6 | pubDate: "2021-07-07",
7 | numOfPage: 225,
8 | category: ["fiction", "programming", "tech", "web dev"],
9 | publication: 1,
10 | },
11 | {
12 | book_id: "12345Two",
13 | title: "Getting started with Python",
14 | authors: [1, 3],
15 | language: "en",
16 | pubDate: "2021-07-07",
17 | numOfPage: 225,
18 | category: ["fiction", "tech", "web dev"],
19 | publication: 2,
20 | },
21 | ];
22 |
23 |
24 | let authors = [{
25 | id: 1,
26 | name: "pavan",
27 | books: ["12345ONE", "12345Two"],
28 | },
29 | {
30 | id: 2,
31 | name: "Deepak",
32 | books: ["12345ONE"],
33 | },
34 | {
35 | id: 3,
36 | name: "VJ",
37 | books: ["12345Two"],
38 | }
39 | ];
40 |
41 |
42 | let publications = [{
43 | id: 1,
44 | name: "Chakra",
45 | books: ["12345ONE"],
46 | },
47 | {
48 | id: 2,
49 | name: "Vickie Publications",
50 | books: ["12345Two"],
51 | },
52 | ];
53 |
54 |
55 | module.exports = {
56 | books,
57 | authors,
58 | publications
59 | };
--------------------------------------------------------------------------------
/Code-base/Day22/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const db = require("./database/db");
3 | // const bodyParser = require('body-parser');
4 |
5 | const app = express();
6 |
7 | // parse application/json
8 | app.use(express.json())
9 | const port = '8000';
10 |
11 | /**
12 | *
13 | * APIs for a Book Management System
14 | *
15 | * Book, Author and then Publications
16 | *
17 | * GET
18 | *
19 | * ## All Books
20 | * ## Get specific book based on ISBN
21 | * ## Get specific book based on Category
22 | *
23 | * ## All Authors
24 | * ## Authors based on a book isbn
25 | *
26 | * ## All Publications
27 | * ## Authors Belonging to specific Publication
28 | *
29 | *
30 | * ## Get Book based on Author Name.
31 | *
32 | *
33 | *
34 | */
35 |
36 |
37 | app.get("/", (req, res) => {
38 | res.send("Welcome to Book Management APIs")
39 | })
40 |
41 | /**
42 | *
43 | * @route /books?book_id=&category=
44 | * @description "API To Get All Books"
45 | * @method GET
46 | * @params book_id string --> Query Params
47 | * category string --> Query Params
48 | * @return_Type JSON Object
49 | *
50 | */
51 |
52 | app.get("/books", (req, res) => {
53 | var books = db.books;
54 |
55 | const {
56 | book_id,
57 | category
58 | } = req.query;
59 |
60 |
61 | console.log(book_id, category);
62 |
63 |
64 | if (book_id !== undefined) {
65 | books = books.filter(book => book.book_id === book_id);
66 | }
67 |
68 | if (category !== undefined) {
69 | books = books.filter(book => book.category.includes(category));
70 | }
71 |
72 | var responseObj = {};
73 | if (books.length == 0) {
74 | responseObj = {
75 | data: {},
76 | message: `No book found for the BOOK ID of ${category}`,
77 | status: 404
78 | }
79 | } else {
80 | responseObj = {
81 | data: books,
82 | message: `Found ${books.length} BOOKs beloning to ${category}`,
83 | status: 200
84 | }
85 | }
86 | res.json(responseObj);
87 | })
88 |
89 |
90 | app.post('/books', (req, res) => {
91 | console.log(req);
92 |
93 | const {
94 | book
95 | } = req.body;
96 |
97 |
98 | if (db.books === undefined) db.books = [book];
99 | else db.books.push(book);
100 | res.json(db.books);
101 | })
102 |
103 |
104 |
105 | app.post('/authors', (req, res) => {
106 | console.log(req);
107 |
108 | const {
109 | author
110 | } = req.body;
111 |
112 | if (db.authors === undefined) db.authors = [author];
113 | else db.authors.push(author);
114 | res.json(db.authors);
115 | })
116 |
117 | /**
118 | *
119 | * @route /books/id/:book_id
120 | * @description "API To Get Book by BOOK_ID"
121 | * @method GET
122 | * @params book_id -- Route Param
123 | * @return_Type JSON Object
124 | *
125 | */
126 |
127 |
128 | app.get("/books/id/:book_id", (req, res) => {
129 | const {
130 | book_id
131 | } = req.params;
132 |
133 |
134 | var result = db.books.filter(book => book.book_id === book_id);
135 | console.log(result);
136 |
137 | var responseObj = {};
138 |
139 | if (result.length == 0) {
140 | responseObj = {
141 | data: {},
142 | message: `No book found for the BOOK ID of ${book_id}`,
143 | status: 404
144 | }
145 | } else {
146 | responseObj = {
147 | data: result,
148 | message: `${result[0].title} found for the BOOK ID of ${book_id}`,
149 | status: 200
150 | }
151 | }
152 | res.json(responseObj);
153 | })
154 |
155 |
156 | /**
157 | *
158 | * @route /books/category/:category
159 | * @description "API To Get All of Books based category"
160 | * @method GET
161 | * @params category -- Route Param
162 | * @return_Type JSON Object
163 | *
164 | */
165 |
166 |
167 | app.get("/books/category/:category/author/:author", (req, res) => {
168 | const {
169 | category
170 | } = req.params;
171 |
172 | var result = db.books.filter(book => book.category.includes(category));
173 | console.log(result);
174 |
175 | var responseObj = {};
176 |
177 | if (result.length == 0) {
178 | responseObj = {
179 | data: {},
180 | message: `No book found for the BOOK ID of ${category}`,
181 | status: 404
182 | }
183 | } else {
184 |
185 | var titles;
186 | for (let i = 0; i < result.length; i++)
187 | titles += " " + result[i].title;
188 |
189 | responseObj = {
190 | data: result,
191 | message: `Found ${titles} BOOKs belonging to ${category}`,
192 | status: 200
193 | }
194 | }
195 | res.json(responseObj);
196 | })
197 |
198 |
199 |
200 | app.get("/authors/publications/:publisher_id", (req, res) => {
201 | const {
202 | publisher_id,
203 | } = req.params;
204 |
205 |
206 | var publisher = db.publications.filter((publisher) => publisher.id == publisher_id)[0],
207 | result = [];
208 |
209 | /***
210 | * AL*ABL*PBL
211 | *
212 | * */
213 | for (let i = 0; i < db.authors.length; i++) {
214 | const author = db.authors[i];
215 | console.log(author);
216 | if (author.books.some(item => publisher.books.includes(item)))
217 | result.push(author);
218 |
219 | // for (let j = 0; j < author.books.length; j++) {
220 | // if (publisher.books.includes(author.books[i])) {
221 | // result.push(author);
222 | // break;
223 | // }
224 | // }
225 | }
226 |
227 | var responseObj = {};
228 | if (result.length == 0) {
229 | responseObj = {
230 | data: {},
231 | message: `No authors found for publisher of ${publisher.name}`,
232 | status: 404
233 | }
234 | } else {
235 | responseObj = {
236 | data: result,
237 | message: `${result.length} authors found for book ID of ${publisher.name}`,
238 | status: 200
239 | }
240 | }
241 |
242 | res.json(responseObj);
243 | })
244 |
245 |
246 |
247 |
248 |
249 | /*********** post *************
250 | *
251 | *
252 | * /BOOK/NEW
253 | * /AUTHOR
254 | * /PUBLICATION
255 | *
256 | *
257 | *
258 | *
259 | *
260 | *
261 | */
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 | app.listen(port, () => {
271 | console.log(`Listening at http://localhost:${port} `)
272 | })
--------------------------------------------------------------------------------
/Code-base/Day22/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "day22",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "accepts": {
8 | "version": "1.3.7",
9 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
10 | "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
11 | "requires": {
12 | "mime-types": "~2.1.24",
13 | "negotiator": "0.6.2"
14 | }
15 | },
16 | "array-flatten": {
17 | "version": "1.1.1",
18 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
19 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
20 | },
21 | "body-parser": {
22 | "version": "1.19.0",
23 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
24 | "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==",
25 | "requires": {
26 | "bytes": "3.1.0",
27 | "content-type": "~1.0.4",
28 | "debug": "2.6.9",
29 | "depd": "~1.1.2",
30 | "http-errors": "1.7.2",
31 | "iconv-lite": "0.4.24",
32 | "on-finished": "~2.3.0",
33 | "qs": "6.7.0",
34 | "raw-body": "2.4.0",
35 | "type-is": "~1.6.17"
36 | }
37 | },
38 | "bytes": {
39 | "version": "3.1.0",
40 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
41 | "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg=="
42 | },
43 | "content-disposition": {
44 | "version": "0.5.3",
45 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
46 | "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==",
47 | "requires": {
48 | "safe-buffer": "5.1.2"
49 | }
50 | },
51 | "content-type": {
52 | "version": "1.0.4",
53 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
54 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA=="
55 | },
56 | "cookie": {
57 | "version": "0.4.0",
58 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
59 | "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg=="
60 | },
61 | "cookie-signature": {
62 | "version": "1.0.6",
63 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
64 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
65 | },
66 | "debug": {
67 | "version": "2.6.9",
68 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
69 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
70 | "requires": {
71 | "ms": "2.0.0"
72 | }
73 | },
74 | "depd": {
75 | "version": "1.1.2",
76 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
77 | "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
78 | },
79 | "destroy": {
80 | "version": "1.0.4",
81 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
82 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
83 | },
84 | "ee-first": {
85 | "version": "1.1.1",
86 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
87 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
88 | },
89 | "encodeurl": {
90 | "version": "1.0.2",
91 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
92 | "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
93 | },
94 | "escape-html": {
95 | "version": "1.0.3",
96 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
97 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
98 | },
99 | "etag": {
100 | "version": "1.8.1",
101 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
102 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
103 | },
104 | "express": {
105 | "version": "4.17.1",
106 | "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
107 | "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==",
108 | "requires": {
109 | "accepts": "~1.3.7",
110 | "array-flatten": "1.1.1",
111 | "body-parser": "1.19.0",
112 | "content-disposition": "0.5.3",
113 | "content-type": "~1.0.4",
114 | "cookie": "0.4.0",
115 | "cookie-signature": "1.0.6",
116 | "debug": "2.6.9",
117 | "depd": "~1.1.2",
118 | "encodeurl": "~1.0.2",
119 | "escape-html": "~1.0.3",
120 | "etag": "~1.8.1",
121 | "finalhandler": "~1.1.2",
122 | "fresh": "0.5.2",
123 | "merge-descriptors": "1.0.1",
124 | "methods": "~1.1.2",
125 | "on-finished": "~2.3.0",
126 | "parseurl": "~1.3.3",
127 | "path-to-regexp": "0.1.7",
128 | "proxy-addr": "~2.0.5",
129 | "qs": "6.7.0",
130 | "range-parser": "~1.2.1",
131 | "safe-buffer": "5.1.2",
132 | "send": "0.17.1",
133 | "serve-static": "1.14.1",
134 | "setprototypeof": "1.1.1",
135 | "statuses": "~1.5.0",
136 | "type-is": "~1.6.18",
137 | "utils-merge": "1.0.1",
138 | "vary": "~1.1.2"
139 | }
140 | },
141 | "finalhandler": {
142 | "version": "1.1.2",
143 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
144 | "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==",
145 | "requires": {
146 | "debug": "2.6.9",
147 | "encodeurl": "~1.0.2",
148 | "escape-html": "~1.0.3",
149 | "on-finished": "~2.3.0",
150 | "parseurl": "~1.3.3",
151 | "statuses": "~1.5.0",
152 | "unpipe": "~1.0.0"
153 | }
154 | },
155 | "forwarded": {
156 | "version": "0.2.0",
157 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
158 | "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow=="
159 | },
160 | "fresh": {
161 | "version": "0.5.2",
162 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
163 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
164 | },
165 | "http-errors": {
166 | "version": "1.7.2",
167 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
168 | "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==",
169 | "requires": {
170 | "depd": "~1.1.2",
171 | "inherits": "2.0.3",
172 | "setprototypeof": "1.1.1",
173 | "statuses": ">= 1.5.0 < 2",
174 | "toidentifier": "1.0.0"
175 | }
176 | },
177 | "iconv-lite": {
178 | "version": "0.4.24",
179 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
180 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
181 | "requires": {
182 | "safer-buffer": ">= 2.1.2 < 3"
183 | }
184 | },
185 | "inherits": {
186 | "version": "2.0.3",
187 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
188 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
189 | },
190 | "ipaddr.js": {
191 | "version": "1.9.1",
192 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
193 | "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g=="
194 | },
195 | "media-typer": {
196 | "version": "0.3.0",
197 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
198 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
199 | },
200 | "merge-descriptors": {
201 | "version": "1.0.1",
202 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
203 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
204 | },
205 | "methods": {
206 | "version": "1.1.2",
207 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
208 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
209 | },
210 | "mime": {
211 | "version": "1.6.0",
212 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
213 | "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
214 | },
215 | "mime-db": {
216 | "version": "1.49.0",
217 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.49.0.tgz",
218 | "integrity": "sha512-CIc8j9URtOVApSFCQIF+VBkX1RwXp/oMMOrqdyXSBXq5RWNEsRfyj1kiRnQgmNXmHxPoFIxOroKA3zcU9P+nAA=="
219 | },
220 | "mime-types": {
221 | "version": "2.1.32",
222 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.32.tgz",
223 | "integrity": "sha512-hJGaVS4G4c9TSMYh2n6SQAGrC4RnfU+daP8G7cSCmaqNjiOoUY0VHCMS42pxnQmVF1GWwFhbHWn3RIxCqTmZ9A==",
224 | "requires": {
225 | "mime-db": "1.49.0"
226 | }
227 | },
228 | "ms": {
229 | "version": "2.0.0",
230 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
231 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
232 | },
233 | "negotiator": {
234 | "version": "0.6.2",
235 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
236 | "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
237 | },
238 | "on-finished": {
239 | "version": "2.3.0",
240 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
241 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
242 | "requires": {
243 | "ee-first": "1.1.1"
244 | }
245 | },
246 | "parseurl": {
247 | "version": "1.3.3",
248 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
249 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="
250 | },
251 | "path-to-regexp": {
252 | "version": "0.1.7",
253 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
254 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
255 | },
256 | "proxy-addr": {
257 | "version": "2.0.7",
258 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
259 | "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
260 | "requires": {
261 | "forwarded": "0.2.0",
262 | "ipaddr.js": "1.9.1"
263 | }
264 | },
265 | "qs": {
266 | "version": "6.7.0",
267 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
268 | "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
269 | },
270 | "range-parser": {
271 | "version": "1.2.1",
272 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
273 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
274 | },
275 | "raw-body": {
276 | "version": "2.4.0",
277 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz",
278 | "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==",
279 | "requires": {
280 | "bytes": "3.1.0",
281 | "http-errors": "1.7.2",
282 | "iconv-lite": "0.4.24",
283 | "unpipe": "1.0.0"
284 | }
285 | },
286 | "safe-buffer": {
287 | "version": "5.1.2",
288 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
289 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
290 | },
291 | "safer-buffer": {
292 | "version": "2.1.2",
293 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
294 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
295 | },
296 | "send": {
297 | "version": "0.17.1",
298 | "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz",
299 | "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==",
300 | "requires": {
301 | "debug": "2.6.9",
302 | "depd": "~1.1.2",
303 | "destroy": "~1.0.4",
304 | "encodeurl": "~1.0.2",
305 | "escape-html": "~1.0.3",
306 | "etag": "~1.8.1",
307 | "fresh": "0.5.2",
308 | "http-errors": "~1.7.2",
309 | "mime": "1.6.0",
310 | "ms": "2.1.1",
311 | "on-finished": "~2.3.0",
312 | "range-parser": "~1.2.1",
313 | "statuses": "~1.5.0"
314 | },
315 | "dependencies": {
316 | "ms": {
317 | "version": "2.1.1",
318 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
319 | "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
320 | }
321 | }
322 | },
323 | "serve-static": {
324 | "version": "1.14.1",
325 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz",
326 | "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==",
327 | "requires": {
328 | "encodeurl": "~1.0.2",
329 | "escape-html": "~1.0.3",
330 | "parseurl": "~1.3.3",
331 | "send": "0.17.1"
332 | }
333 | },
334 | "setprototypeof": {
335 | "version": "1.1.1",
336 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
337 | "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
338 | },
339 | "statuses": {
340 | "version": "1.5.0",
341 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
342 | "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
343 | },
344 | "toidentifier": {
345 | "version": "1.0.0",
346 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
347 | "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
348 | },
349 | "type-is": {
350 | "version": "1.6.18",
351 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
352 | "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
353 | "requires": {
354 | "media-typer": "0.3.0",
355 | "mime-types": "~2.1.24"
356 | }
357 | },
358 | "unpipe": {
359 | "version": "1.0.0",
360 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
361 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
362 | },
363 | "utils-merge": {
364 | "version": "1.0.1",
365 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
366 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
367 | },
368 | "vary": {
369 | "version": "1.1.2",
370 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
371 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
372 | }
373 | }
374 | }
375 |
--------------------------------------------------------------------------------
/Code-base/Day22/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "day22",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "Vishal Jain",
10 | "license": "ISC",
11 | "dependencies": {
12 | "body-parser": "^1.19.0",
13 | "express": "^4.17.1"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Code-base/Day23/controllers/author.controller.js:
--------------------------------------------------------------------------------
1 | const {
2 | checkUndefNul,
3 | validateEmail,
4 | validateNumber
5 | } = require('../helpers/validation.helper')
6 |
7 | const authorModel = require("../models/authorModel")
8 | const bookModel = require("../models/bookModel")
9 |
10 | const addAuthor = async (req, res) => {
11 | console.log(req);
12 |
13 | const {
14 | id,
15 | age,
16 | name,
17 | email,
18 | contact_number,
19 | country,
20 | gender,
21 | books_published,
22 | publications_associated
23 | } = req.body;
24 | console.log(req.body)
25 | var errorMessage = [];
26 |
27 |
28 |
29 |
30 | if (checkUndefNul(id)) {
31 | errorMessage.push("ID is invalid");
32 | }
33 |
34 | if (checkUndefNul(age) || age <= 0) {
35 | errorMessage.push("Age is invalid");
36 | }
37 |
38 | if (checkUndefNul(name)) {
39 | errorMessage.push("Name is invalid");
40 | }
41 |
42 | if (checkUndefNul(country)) {
43 | errorMessage.push("Country is invalid");
44 | }
45 |
46 | if (!validateEmail(email)) {
47 | errorMessage.push("Email is invalid");
48 | }
49 |
50 | if (!validateNumber(contact_number)) {
51 | errorMessage.push("Contact Number is invalid");
52 | }
53 |
54 | if (!["male", "female", "others"].includes(gender.toLowerCase()) || checkUndefNul(gender)) {
55 | errorMessage.push("Gender is invalid");
56 | }
57 |
58 |
59 | /***
60 | * Validate Books_publication and publications_associated
61 | *
62 | *
63 | * if there is a book published 1st check if it's in book collection
64 | * false if not present.
65 | *
66 | * if yes, check publication of that book. map it with publications_associated.
67 | */
68 |
69 |
70 | try {
71 |
72 | if (errorMessage.length > 0) {
73 | return res.json({
74 | data: errorMessage,
75 | message: "Invalid Params sent"
76 | })
77 | }
78 |
79 |
80 | const author = await authorModel.create({
81 | ...req.body
82 | });
83 |
84 | return res.json({
85 | data: author,
86 | message: "Successfull"
87 | });
88 | } catch (error) {
89 | return res.json({
90 | data: [],
91 | message: error
92 | });
93 | }
94 | }
95 |
96 | const getAuthors = async (req, res) => {
97 | try {
98 | const authors = await authorModel.find({});
99 | res.json({
100 | data: authors,
101 | message: "Successfull"
102 | });
103 | } catch (error) {
104 | res.json({
105 | data: [],
106 | message: error
107 | });
108 | }
109 | }
110 |
111 | const getAuthorbyId = async (req, res) => {
112 | const {
113 | author_id
114 | } = req.params
115 | try {
116 | const authors = await authorModel.find({
117 | "id": author_id
118 | }, '-_id -__v');
119 | res.json({
120 | data: authors,
121 | message: "Successfull"
122 | });
123 | } catch (error) {
124 | res.json({
125 | data: [],
126 | message: error
127 | });
128 | }
129 | }
130 |
131 | const getBooksofAuthor = async (req, res) => {
132 | const {
133 | author_id
134 | } = req.params
135 | try {
136 | const books_published = await authorModel.find({
137 | "id": author_id
138 | }, 'books_published -_id -__v');
139 |
140 | console.log(books_published);
141 |
142 | // get all books whose id is present IN books_published
143 | const books_data = await bookModel.find({
144 | id: {
145 | $in: books_published
146 | }
147 | })
148 |
149 | res.json({
150 | data: books_data,
151 | message: "Successfull"
152 | });
153 | } catch (error) {
154 | res.json({
155 | data: [],
156 | message: error
157 | });
158 | }
159 | }
160 |
161 | const updateAuthorName = async (req, res) => {
162 |
163 | const {
164 | author_name,
165 | author_id
166 | } = req.body
167 | try {
168 | const authors = await authorModel.updateMany({
169 | "id": author_id
170 | }, {
171 | "name": author_name
172 | });
173 | res.json({
174 | data: authors,
175 | message: "Successfull"
176 | });
177 | } catch (error) {
178 | res.json({
179 | data: [],
180 | message: error
181 | });
182 | }
183 | }
184 |
185 | const deleteAuthorbyId = async (req, res) => {
186 | const {
187 | author_id
188 | } = req.params
189 | try {
190 | const authors = await authorModel.deleteOne({
191 | "id": author_id
192 | });
193 | res.json({
194 | data: authors,
195 | message: "Successfull"
196 | });
197 | } catch (error) {
198 | console.log(error)
199 | res.json({
200 | data: [],
201 | message: error
202 | });
203 | }
204 | }
205 |
206 | const deleteAllAuthors = async (req, res) => {
207 |
208 | try {
209 | const authors = await authorModel.deleteMany({});
210 | res.json({
211 | data: authors,
212 | message: "Successfull"
213 | });
214 | } catch (error) {
215 | console.log(error)
216 | res.json({
217 | data: [],
218 | message: error
219 | });
220 | }
221 | }
222 |
223 | module.exports = {
224 | addAuthor,
225 | getAuthors,
226 | getAuthorbyId,
227 | getBooksofAuthor,
228 | updateAuthorName,
229 | deleteAuthorbyId,
230 | deleteAllAuthors
231 | }
--------------------------------------------------------------------------------
/Code-base/Day23/database/db.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose');
2 |
3 | const password = encodeURIComponent('pass_123');
4 |
5 | const url = `mongodb+srv://vjtron:${password}@cluster0.syhxj.mongodb.net/sample_airbnb?retryWrites=true&w=majority`;
6 |
7 | mongoose.connect(url, {
8 | useNewUrlParser: true,
9 | useUnifiedTopology: true
10 | })
11 |
12 | const dbConn = mongoose.connection;
13 |
14 | dbConn.on("error", console.error.bind(console, "Connection Error"));
15 | dbConn.on("open", function () {
16 | console.log("DB Connection Successful");
17 | });
18 |
19 | module.exports = dbConn;
--------------------------------------------------------------------------------
/Code-base/Day23/helpers/validation.helper.js:
--------------------------------------------------------------------------------
1 | function checkUndefNul(param) {
2 | return param == undefined || param == null || param == "";
3 | }
4 |
5 | function validateEmail(email) {
6 | const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
7 | return re.test(String(email).toLowerCase());
8 | }
9 |
10 |
11 | function validateNumber(number) {
12 | const re = /^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$/;
13 | return re.test(String(number).toLowerCase());
14 | }
15 |
16 |
17 | module.exports = {
18 | checkUndefNul,
19 | validateEmail,
20 | validateNumber
21 | }
--------------------------------------------------------------------------------
/Code-base/Day23/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const app = express();
3 | const cors = require("cors");
4 |
5 |
6 | app.use(cors());
7 | app.use(express.json());
8 |
9 |
10 | /**
11 | *
12 | * APIs for a Book Management System
13 | *
14 | * Book, Author and then Publications
15 | *
16 | * GET
17 | *
18 | * ## All Books
19 | * ## Get specific book based on id
20 | * ## Get specific book based on Category
21 | *
22 | * ## All Authors
23 | * ## Authors based on a book id
24 | *
25 | * ## All Publications
26 | * ## Authors Belonging to specific Publication
27 | *
28 | *
29 | * ## Get Book based on Author Name.
30 | *
31 | *
32 | * Post
33 | * ## Add New Author
34 | * ## Add new Book
35 | * ## Add new Publication
36 | *
37 | * Put
38 | * ## Add new book to an author
39 | * book should have that author id in authors array.
40 | * update the publication as well
41 | *
42 | * ## Add
43 | *
44 | *
45 | *
46 | */
47 |
48 |
49 |
50 | const db = require("./database/db");
51 | const authorRouter = require("./routes/authorRoutor");
52 | const port = '8080';
53 |
54 | app.use("/authors", authorRouter);
55 |
56 |
57 | // method is post
58 | app.listen(port, () => {
59 | console.log(`Listening at http://localhost:${port} `)
60 | });
--------------------------------------------------------------------------------
/Code-base/Day23/models/authorModel.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | var authorSchema = mongoose.Schema({
4 | id: Number,
5 | age: {
6 | type: Number,
7 | required: true
8 | },
9 | email: {
10 | type: String,
11 | required: true
12 | },
13 | name: String,
14 | contact_numebr: String,
15 | country: String,
16 | gender: String,
17 | books_published: Array,
18 | publications_associated: Array
19 | });
20 |
21 | const author = mongoose.model("Author", authorSchema);
22 |
23 | module.exports = author;
--------------------------------------------------------------------------------
/Code-base/Day23/models/bookModel.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | var bookSchema = mongoose.Schema({
4 | id: Number,
5 | ratings: Number,
6 | price: Number,
7 | pages: Number,
8 | name: String,
9 | language: String,
10 | category: Array,
11 | author: Array,
12 | publication: Array
13 | });
14 |
15 | const book = mongoose.model("Book", bookSchema);
16 |
17 | module.exports = book;
--------------------------------------------------------------------------------
/Code-base/Day23/models/publicationModel.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | var publicationSchema = mongoose.Schema({
4 | id: Number,
5 | revenue: Number,
6 | year_of_establishment: Number,
7 | email: String,
8 | name: String,
9 | contact_numebr: String,
10 | address: String,
11 | books_published: Array,
12 | authors_associated: Array
13 | });
14 |
15 | const publication = mongoose.model("Publication", publicationSchema);
16 |
17 | module.exports = publication;
--------------------------------------------------------------------------------
/Code-base/Day23/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "day23",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "@types/node": {
8 | "version": "16.7.1",
9 | "resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.1.tgz",
10 | "integrity": "sha512-ncRdc45SoYJ2H4eWU9ReDfp3vtFqDYhjOsKlFFUDEn8V1Bgr2RjYal8YT5byfadWIRluhPFU6JiDOl0H6Sl87A=="
11 | },
12 | "@types/webidl-conversions": {
13 | "version": "6.1.1",
14 | "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-6.1.1.tgz",
15 | "integrity": "sha512-XAahCdThVuCFDQLT7R7Pk/vqeObFNL3YqRyFZg+AqAP/W1/w3xHaIxuW7WszQqTbIBOPRcItYJIou3i/mppu3Q=="
16 | },
17 | "@types/whatwg-url": {
18 | "version": "8.2.1",
19 | "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-8.2.1.tgz",
20 | "integrity": "sha512-2YubE1sjj5ifxievI5Ge1sckb9k/Er66HyR2c+3+I6VDUUg1TLPdYYTEbQ+DjRkS4nTxMJhgWfSfMRD2sl2EYQ==",
21 | "requires": {
22 | "@types/node": "*",
23 | "@types/webidl-conversions": "*"
24 | }
25 | },
26 | "accepts": {
27 | "version": "1.3.7",
28 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
29 | "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
30 | "requires": {
31 | "mime-types": "~2.1.24",
32 | "negotiator": "0.6.2"
33 | }
34 | },
35 | "array-flatten": {
36 | "version": "1.1.1",
37 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
38 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
39 | },
40 | "base64-js": {
41 | "version": "1.5.1",
42 | "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
43 | "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
44 | },
45 | "body-parser": {
46 | "version": "1.19.0",
47 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
48 | "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==",
49 | "requires": {
50 | "bytes": "3.1.0",
51 | "content-type": "~1.0.4",
52 | "debug": "2.6.9",
53 | "depd": "~1.1.2",
54 | "http-errors": "1.7.2",
55 | "iconv-lite": "0.4.24",
56 | "on-finished": "~2.3.0",
57 | "qs": "6.7.0",
58 | "raw-body": "2.4.0",
59 | "type-is": "~1.6.17"
60 | }
61 | },
62 | "bson": {
63 | "version": "4.5.1",
64 | "resolved": "https://registry.npmjs.org/bson/-/bson-4.5.1.tgz",
65 | "integrity": "sha512-XqFP74pbTVLyLy5KFxVfTUyRrC1mgOlmu/iXHfXqfCKT59jyP9lwbotGfbN59cHBRbJSamZNkrSopjv+N0SqAA==",
66 | "requires": {
67 | "buffer": "^5.6.0"
68 | }
69 | },
70 | "buffer": {
71 | "version": "5.7.1",
72 | "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
73 | "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
74 | "requires": {
75 | "base64-js": "^1.3.1",
76 | "ieee754": "^1.1.13"
77 | }
78 | },
79 | "bytes": {
80 | "version": "3.1.0",
81 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
82 | "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg=="
83 | },
84 | "content-disposition": {
85 | "version": "0.5.3",
86 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
87 | "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==",
88 | "requires": {
89 | "safe-buffer": "5.1.2"
90 | }
91 | },
92 | "content-type": {
93 | "version": "1.0.4",
94 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
95 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA=="
96 | },
97 | "cookie": {
98 | "version": "0.4.0",
99 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
100 | "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg=="
101 | },
102 | "cookie-signature": {
103 | "version": "1.0.6",
104 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
105 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
106 | },
107 | "cors": {
108 | "version": "2.8.5",
109 | "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
110 | "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
111 | "requires": {
112 | "object-assign": "^4",
113 | "vary": "^1"
114 | }
115 | },
116 | "debug": {
117 | "version": "2.6.9",
118 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
119 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
120 | "requires": {
121 | "ms": "2.0.0"
122 | }
123 | },
124 | "denque": {
125 | "version": "1.5.1",
126 | "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.1.tgz",
127 | "integrity": "sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw=="
128 | },
129 | "depd": {
130 | "version": "1.1.2",
131 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
132 | "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
133 | },
134 | "destroy": {
135 | "version": "1.0.4",
136 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
137 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
138 | },
139 | "ee-first": {
140 | "version": "1.1.1",
141 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
142 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
143 | },
144 | "encodeurl": {
145 | "version": "1.0.2",
146 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
147 | "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
148 | },
149 | "escape-html": {
150 | "version": "1.0.3",
151 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
152 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
153 | },
154 | "etag": {
155 | "version": "1.8.1",
156 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
157 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
158 | },
159 | "express": {
160 | "version": "4.17.1",
161 | "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
162 | "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==",
163 | "requires": {
164 | "accepts": "~1.3.7",
165 | "array-flatten": "1.1.1",
166 | "body-parser": "1.19.0",
167 | "content-disposition": "0.5.3",
168 | "content-type": "~1.0.4",
169 | "cookie": "0.4.0",
170 | "cookie-signature": "1.0.6",
171 | "debug": "2.6.9",
172 | "depd": "~1.1.2",
173 | "encodeurl": "~1.0.2",
174 | "escape-html": "~1.0.3",
175 | "etag": "~1.8.1",
176 | "finalhandler": "~1.1.2",
177 | "fresh": "0.5.2",
178 | "merge-descriptors": "1.0.1",
179 | "methods": "~1.1.2",
180 | "on-finished": "~2.3.0",
181 | "parseurl": "~1.3.3",
182 | "path-to-regexp": "0.1.7",
183 | "proxy-addr": "~2.0.5",
184 | "qs": "6.7.0",
185 | "range-parser": "~1.2.1",
186 | "safe-buffer": "5.1.2",
187 | "send": "0.17.1",
188 | "serve-static": "1.14.1",
189 | "setprototypeof": "1.1.1",
190 | "statuses": "~1.5.0",
191 | "type-is": "~1.6.18",
192 | "utils-merge": "1.0.1",
193 | "vary": "~1.1.2"
194 | }
195 | },
196 | "finalhandler": {
197 | "version": "1.1.2",
198 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
199 | "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==",
200 | "requires": {
201 | "debug": "2.6.9",
202 | "encodeurl": "~1.0.2",
203 | "escape-html": "~1.0.3",
204 | "on-finished": "~2.3.0",
205 | "parseurl": "~1.3.3",
206 | "statuses": "~1.5.0",
207 | "unpipe": "~1.0.0"
208 | }
209 | },
210 | "forwarded": {
211 | "version": "0.2.0",
212 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
213 | "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow=="
214 | },
215 | "fresh": {
216 | "version": "0.5.2",
217 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
218 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
219 | },
220 | "http-errors": {
221 | "version": "1.7.2",
222 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
223 | "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==",
224 | "requires": {
225 | "depd": "~1.1.2",
226 | "inherits": "2.0.3",
227 | "setprototypeof": "1.1.1",
228 | "statuses": ">= 1.5.0 < 2",
229 | "toidentifier": "1.0.0"
230 | }
231 | },
232 | "iconv-lite": {
233 | "version": "0.4.24",
234 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
235 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
236 | "requires": {
237 | "safer-buffer": ">= 2.1.2 < 3"
238 | }
239 | },
240 | "ieee754": {
241 | "version": "1.2.1",
242 | "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
243 | "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="
244 | },
245 | "inherits": {
246 | "version": "2.0.3",
247 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
248 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
249 | },
250 | "ipaddr.js": {
251 | "version": "1.9.1",
252 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
253 | "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g=="
254 | },
255 | "kareem": {
256 | "version": "2.3.2",
257 | "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.2.tgz",
258 | "integrity": "sha512-STHz9P7X2L4Kwn72fA4rGyqyXdmrMSdxqHx9IXon/FXluXieaFA6KJ2upcHAHxQPQ0LeM/OjLrhFxifHewOALQ=="
259 | },
260 | "media-typer": {
261 | "version": "0.3.0",
262 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
263 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
264 | },
265 | "memory-pager": {
266 | "version": "1.5.0",
267 | "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz",
268 | "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==",
269 | "optional": true
270 | },
271 | "merge-descriptors": {
272 | "version": "1.0.1",
273 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
274 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
275 | },
276 | "methods": {
277 | "version": "1.1.2",
278 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
279 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
280 | },
281 | "mime": {
282 | "version": "1.6.0",
283 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
284 | "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
285 | },
286 | "mime-db": {
287 | "version": "1.49.0",
288 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.49.0.tgz",
289 | "integrity": "sha512-CIc8j9URtOVApSFCQIF+VBkX1RwXp/oMMOrqdyXSBXq5RWNEsRfyj1kiRnQgmNXmHxPoFIxOroKA3zcU9P+nAA=="
290 | },
291 | "mime-types": {
292 | "version": "2.1.32",
293 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.32.tgz",
294 | "integrity": "sha512-hJGaVS4G4c9TSMYh2n6SQAGrC4RnfU+daP8G7cSCmaqNjiOoUY0VHCMS42pxnQmVF1GWwFhbHWn3RIxCqTmZ9A==",
295 | "requires": {
296 | "mime-db": "1.49.0"
297 | }
298 | },
299 | "mongodb": {
300 | "version": "4.1.1",
301 | "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.1.1.tgz",
302 | "integrity": "sha512-fbACrWEyvr6yl0sSiCGV0sqEiBwTtDJ8iSojmkDjAfw9JnOZSAkUyv9seFSPYhPPKwxp1PDtyjvBNfMDz0WBLQ==",
303 | "requires": {
304 | "bson": "^4.5.1",
305 | "denque": "^1.5.0",
306 | "mongodb-connection-string-url": "^2.0.0",
307 | "saslprep": "^1.0.0"
308 | }
309 | },
310 | "mongodb-connection-string-url": {
311 | "version": "2.0.0",
312 | "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.0.0.tgz",
313 | "integrity": "sha512-M0I1vyLoq5+HQTuPSJWbt+hIXsMCfE8sS1fS5mvP9R2DOMoi2ZD32yWqgBIITyu0dFu4qtS50erxKjvUeBiyog==",
314 | "requires": {
315 | "@types/whatwg-url": "^8.2.1",
316 | "whatwg-url": "^9.1.0"
317 | }
318 | },
319 | "mongoose": {
320 | "version": "6.0.0",
321 | "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.0.0.tgz",
322 | "integrity": "sha512-aS1y1xEjFLz8wYVvJiI9T/ut/BssC2Q4K/XtG1oqHcyiMuV+qPOpRpklSmC2Z/Q7A2fE2NlBZatQGf7FnoAlrA==",
323 | "requires": {
324 | "bson": "^4.2.2",
325 | "kareem": "2.3.2",
326 | "mongodb": "4.1.1",
327 | "mpath": "0.8.3",
328 | "mquery": "4.0.0",
329 | "ms": "2.1.2",
330 | "regexp-clone": "1.0.0",
331 | "sift": "13.5.2",
332 | "sliced": "1.0.1"
333 | },
334 | "dependencies": {
335 | "ms": {
336 | "version": "2.1.2",
337 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
338 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
339 | }
340 | }
341 | },
342 | "mpath": {
343 | "version": "0.8.3",
344 | "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.8.3.tgz",
345 | "integrity": "sha512-eb9rRvhDltXVNL6Fxd2zM9D4vKBxjVVQNLNijlj7uoXUy19zNDsIif5zR+pWmPCWNKwAtqyo4JveQm4nfD5+eA=="
346 | },
347 | "mquery": {
348 | "version": "4.0.0",
349 | "resolved": "https://registry.npmjs.org/mquery/-/mquery-4.0.0.tgz",
350 | "integrity": "sha512-nGjm89lHja+T/b8cybAby6H0YgA4qYC/lx6UlwvHGqvTq8bDaNeCwl1sY8uRELrNbVWJzIihxVd+vphGGn1vBw==",
351 | "requires": {
352 | "debug": "4.x",
353 | "regexp-clone": "^1.0.0",
354 | "sliced": "1.0.1"
355 | },
356 | "dependencies": {
357 | "debug": {
358 | "version": "4.3.2",
359 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
360 | "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==",
361 | "requires": {
362 | "ms": "2.1.2"
363 | }
364 | },
365 | "ms": {
366 | "version": "2.1.2",
367 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
368 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
369 | }
370 | }
371 | },
372 | "ms": {
373 | "version": "2.0.0",
374 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
375 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
376 | },
377 | "negotiator": {
378 | "version": "0.6.2",
379 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
380 | "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
381 | },
382 | "object-assign": {
383 | "version": "4.1.1",
384 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
385 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
386 | },
387 | "on-finished": {
388 | "version": "2.3.0",
389 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
390 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
391 | "requires": {
392 | "ee-first": "1.1.1"
393 | }
394 | },
395 | "parseurl": {
396 | "version": "1.3.3",
397 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
398 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="
399 | },
400 | "path-to-regexp": {
401 | "version": "0.1.7",
402 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
403 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
404 | },
405 | "proxy-addr": {
406 | "version": "2.0.7",
407 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
408 | "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
409 | "requires": {
410 | "forwarded": "0.2.0",
411 | "ipaddr.js": "1.9.1"
412 | }
413 | },
414 | "punycode": {
415 | "version": "2.1.1",
416 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
417 | "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
418 | },
419 | "qs": {
420 | "version": "6.7.0",
421 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
422 | "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
423 | },
424 | "range-parser": {
425 | "version": "1.2.1",
426 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
427 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
428 | },
429 | "raw-body": {
430 | "version": "2.4.0",
431 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz",
432 | "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==",
433 | "requires": {
434 | "bytes": "3.1.0",
435 | "http-errors": "1.7.2",
436 | "iconv-lite": "0.4.24",
437 | "unpipe": "1.0.0"
438 | }
439 | },
440 | "regexp-clone": {
441 | "version": "1.0.0",
442 | "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-1.0.0.tgz",
443 | "integrity": "sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw=="
444 | },
445 | "safe-buffer": {
446 | "version": "5.1.2",
447 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
448 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
449 | },
450 | "safer-buffer": {
451 | "version": "2.1.2",
452 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
453 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
454 | },
455 | "saslprep": {
456 | "version": "1.0.3",
457 | "resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz",
458 | "integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==",
459 | "optional": true,
460 | "requires": {
461 | "sparse-bitfield": "^3.0.3"
462 | }
463 | },
464 | "send": {
465 | "version": "0.17.1",
466 | "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz",
467 | "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==",
468 | "requires": {
469 | "debug": "2.6.9",
470 | "depd": "~1.1.2",
471 | "destroy": "~1.0.4",
472 | "encodeurl": "~1.0.2",
473 | "escape-html": "~1.0.3",
474 | "etag": "~1.8.1",
475 | "fresh": "0.5.2",
476 | "http-errors": "~1.7.2",
477 | "mime": "1.6.0",
478 | "ms": "2.1.1",
479 | "on-finished": "~2.3.0",
480 | "range-parser": "~1.2.1",
481 | "statuses": "~1.5.0"
482 | },
483 | "dependencies": {
484 | "ms": {
485 | "version": "2.1.1",
486 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
487 | "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
488 | }
489 | }
490 | },
491 | "serve-static": {
492 | "version": "1.14.1",
493 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz",
494 | "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==",
495 | "requires": {
496 | "encodeurl": "~1.0.2",
497 | "escape-html": "~1.0.3",
498 | "parseurl": "~1.3.3",
499 | "send": "0.17.1"
500 | }
501 | },
502 | "setprototypeof": {
503 | "version": "1.1.1",
504 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
505 | "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
506 | },
507 | "sift": {
508 | "version": "13.5.2",
509 | "resolved": "https://registry.npmjs.org/sift/-/sift-13.5.2.tgz",
510 | "integrity": "sha512-+gxdEOMA2J+AI+fVsCqeNn7Tgx3M9ZN9jdi95939l1IJ8cZsqS8sqpJyOkic2SJk+1+98Uwryt/gL6XDaV+UZA=="
511 | },
512 | "sliced": {
513 | "version": "1.0.1",
514 | "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz",
515 | "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E="
516 | },
517 | "sparse-bitfield": {
518 | "version": "3.0.3",
519 | "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz",
520 | "integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=",
521 | "optional": true,
522 | "requires": {
523 | "memory-pager": "^1.0.2"
524 | }
525 | },
526 | "statuses": {
527 | "version": "1.5.0",
528 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
529 | "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
530 | },
531 | "toidentifier": {
532 | "version": "1.0.0",
533 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
534 | "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
535 | },
536 | "tr46": {
537 | "version": "2.1.0",
538 | "resolved": "https://registry.npmjs.org/tr46/-/tr46-2.1.0.tgz",
539 | "integrity": "sha512-15Ih7phfcdP5YxqiB+iDtLoaTz4Nd35+IiAv0kQ5FNKHzXgdWqPoTIqEDDJmXceQt4JZk6lVPT8lnDlPpGDppw==",
540 | "requires": {
541 | "punycode": "^2.1.1"
542 | }
543 | },
544 | "type-is": {
545 | "version": "1.6.18",
546 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
547 | "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
548 | "requires": {
549 | "media-typer": "0.3.0",
550 | "mime-types": "~2.1.24"
551 | }
552 | },
553 | "unpipe": {
554 | "version": "1.0.0",
555 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
556 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
557 | },
558 | "utils-merge": {
559 | "version": "1.0.1",
560 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
561 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
562 | },
563 | "vary": {
564 | "version": "1.1.2",
565 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
566 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
567 | },
568 | "webidl-conversions": {
569 | "version": "6.1.0",
570 | "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz",
571 | "integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w=="
572 | },
573 | "whatwg-url": {
574 | "version": "9.1.0",
575 | "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-9.1.0.tgz",
576 | "integrity": "sha512-CQ0UcrPHyomtlOCot1TL77WyMIm/bCwrJ2D6AOKGwEczU9EpyoqAokfqrf/MioU9kHcMsmJZcg1egXix2KYEsA==",
577 | "requires": {
578 | "tr46": "^2.1.0",
579 | "webidl-conversions": "^6.1.0"
580 | }
581 | }
582 | }
583 | }
584 |
--------------------------------------------------------------------------------
/Code-base/Day23/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "day23",
3 | "version": "1.0.0",
4 | "description": "Understanding Mongo DB",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "cors": "^2.8.5",
13 | "express": "^4.17.1",
14 | "mongoose": "^6.0.0"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Code-base/Day23/routes/authorRoutor.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 |
4 |
5 | const authorController = require("../controllers/author.controller")
6 |
7 | router.get('/', authorController.getAuthors)
8 | router.get('/:author_id', authorController.getAuthorbyId)
9 | router.get('/:author_id/getBooks', authorController.getBooksofAuthor);
10 |
11 | router.post('/', authorController.addAuthor)
12 |
13 | router.put('/updateName', authorController.updateAuthorName);
14 |
15 | router.delete('/:author_id', authorController.deleteAuthorbyId)
16 | router.delete('/', authorController.deleteAllAuthors)
17 |
18 |
19 | module.exports = router;
--------------------------------------------------------------------------------
/Code-base/Day30/assets/css/style.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Code-base/Day30/assets/css/style.css
--------------------------------------------------------------------------------
/Code-base/Day30/assets/js/main.js:
--------------------------------------------------------------------------------
1 | const baseURL = 'http://localhost:8080';
2 | let data = {
3 | id: 1,
4 | age: 23,
5 | email: 'assd@asd.com',
6 | contact_number: '213123',
7 | country: 'in',
8 | gender: 'Mle',
9 | name: "KC",
10 | books_published: [],
11 | publications_associated: []
12 | }
13 |
14 | fetch(`${baseURL}/authors`, {
15 | headers: {
16 | 'Accept': 'application/json',
17 | 'Content-Type': 'application/json'
18 | },
19 | method: "POST",
20 | body: JSON.stringify(data)
21 | })
22 | .then(res => res.json())
23 | .then(res =>
24 | console.log(res)
25 | )
26 | .catch(function (res) {
27 | console.log(res)
28 | })
29 |
30 |
31 | fetch(`${baseURL}/authors/1`)
32 | .then(res => res.json())
33 | .then(res =>
34 | console.log(res)
35 | )
36 | .catch(function (res) {
37 | console.log(res)
38 | })
39 |
40 |
41 |
42 |
43 | /*****
44 | *
45 | * fetch --> browser hits the node api -->
46 | * node > index.js > cors express.json > routes > author.roues > authorcontroller > helper.js >
47 | * 1/ if valid > author Model > mongoose > mongodb > authorcontroll > json is returned
48 | * 2/ if invalid > json is returned
49 | * ----------------------->
50 | *
51 | * then you come back to main.js -> 1st then get actually resquest obj --> 2nd then is your front-end logic.
52 | *
53 | *
54 | */
--------------------------------------------------------------------------------
/Code-base/Day30/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Ajax in JavaScript
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | This is grid
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Code-base/Day5/assets/css/style.css:
--------------------------------------------------------------------------------
1 | body, html {
2 | height: 100%;
3 | }
4 |
5 |
6 | .parent {
7 | height: 300px;
8 | background-color: lightgreen;
9 | width: 50px;
10 | padding: 10px;
11 | }
12 |
13 |
14 |
15 | .child {
16 | height: 100%;
17 | background-color: purple;
18 | width: 50px;
19 | width: 100%;
20 | }
21 |
22 |
23 | .viewport-height {
24 | background-color: black;
25 | height: 100vh;
26 | width: 75px;
27 | }
--------------------------------------------------------------------------------
/Code-base/Day5/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | A basic simple web page
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | Go to Form
14 |
15 |
17 |
18 |
19 |
20 | 100% height
21 |
22 |
23 |
24 | 100% height
25 |
26 |
27 |
28 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/Code-base/Day6/Display.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Display Property
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
27 |
28 |
29 | The display Property
30 |
39 |
40 |
41 | display: inline
42 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum consequat scelerisque elit sit amet
43 | consequat. Aliquam erat volutpat. Aliquam venenatis gravida nisl
44 | sit amet facilisis. Nullam cursus fermentum velit sed laoreet.
45 |
46 |
54 | display: inline-block
55 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum consequat scelerisque elit sit amet
56 | consequat. Aliquam erat volutpat. Aliquam venenatis gravida nisl
57 | sit amet facilisis. Nullam cursus fermentum velit sed laoreet.
58 |
59 |
72 |
73 | display: block
74 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum consequat scelerisque elit sit amet
75 | consequat. Aliquam erat volutpat. DISPLAY NONE DISPLAY NONE gravida nisl
77 | sit amet facilisis. Nullam cursus fermentum velit sed laoreet.
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/Code-base/Day6/assets/css/Display.css:
--------------------------------------------------------------------------------
1 | span.a {
2 | display: inline;
3 | /* the default for span */
4 | }
5 |
6 | span.b {
7 | display: inline-block;
8 | }
9 |
10 | span.c {
11 | display: block;
12 |
13 | }
14 |
15 | .general {
16 | width: 100px;
17 | height: 100px;
18 | padding: 5px;
19 | margin: 10px;
20 | border: 1px solid blue;
21 | background-color: yellow;
22 | }
--------------------------------------------------------------------------------
/Code-base/Day6/assets/css/position.css:
--------------------------------------------------------------------------------
1 |
2 | body, html {
3 | height: 2000px;
4 | }
5 |
6 | div.static {
7 | position: static;
8 | border: 3px solid #73AD21;
9 | top: 30px;
10 |
11 | }
12 |
13 | div.relative {
14 | position: relative;
15 | top: 30px;
16 | margin-top: 30px;
17 | border: 3px solid #73AD21;
18 | }
19 |
20 |
21 | div.fixed {
22 | position: fixed;
23 | bottom: 0;
24 | right: 0;
25 | width: 300px;
26 | border: 3px solid #73AD21;
27 | }
28 |
29 | div.relative-abs {
30 | /* position: relative; */
31 | width: 400px;
32 | top: 40px;
33 | height: 200px;
34 | border: 3px solid darkgreen;
35 | }
36 |
37 | div.absolute {
38 | position: absolute;
39 | margin-top: 80px;
40 | right: 0;
41 | width: 200px;
42 | height: 100px;
43 | border: 3px solid #73AD21;
44 | }
45 |
46 | div.res {
47 | width: 900px;
48 | height: 900px;
49 | border: 3px solid #ade3ad;
50 | /* position: relative; */
51 | }
52 |
53 | div.sticky {
54 | position: -webkit-sticky;
55 | position: sticky;
56 | top: 0;
57 | padding: 5px;
58 | background-color: #cae8ca;
59 | border: 2px solid #4CAF50;
60 | }
61 |
62 |
63 | /*
64 |
65 | Display
66 | position : sticky , chorme , firefox
67 | Safari : -webkit- prefix
68 |
69 | */
--------------------------------------------------------------------------------
/Code-base/Day6/position.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Position
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
30 |
31 | position: static;
32 |
33 | An element with position: static; is not positioned in any special way; it is
34 | always positioned according to the normal flow of the page:
35 |
36 |
37 | This div element has position: static;
38 |
39 |
40 |
41 |
42 | position: relative;
43 |
44 | An element with position: relative; is positioned relative to its normal position:
45 |
46 |
47 | This div element has position: relative;
48 |
49 |
50 |
51 | position: fixed;
52 |
53 | An element with position: fixed; is positioned relative to the viewport, which means it always stays in the same
54 | place even if the page is scrolled:
55 |
56 |
57 | This div element has position: fixed;
58 |
59 |
60 |
61 | position: absolute;
62 |
63 | An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of
64 | positioned relative to the viewport, like fixed):
65 |
66 |
67 |
This div element has position: relative;
68 |
This div element has position: absolute;
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | Try to scroll inside this frame to understand how sticky positioning works.
77 |
78 | I am sticky!
79 |
80 |
81 |
In this example, the sticky element sticks to the top of the page (top: 0), when you reach its scroll
82 | position.
83 |
Scroll back up to remove the stickyness.
84 |
Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset
85 | concludaturque et eum, altera fabulas ut quo. Atqui causae gloriatur ius te, id agam omnis evertitur eum.
86 | Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.
87 |
Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset
88 | concludaturque et eum, altera fabulas ut quo. Atqui causae gloriatur ius te, id agam omnis evertitur eum.
89 | Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/Code-base/Day7/assets/css/flex.css:
--------------------------------------------------------------------------------
1 | .flex-container {
2 | /* /* We first create a flex layout context */
3 | display: flex;
4 | width: 900px;
5 | /* Then we define the flow direction
6 | and if we allow the items to wrap
7 | * Remember this is the same as:
8 | * flex-direction: row;
9 | * flex-wrap: wrap;
10 |
11 | /* /* flex-wrap: wrap; */
12 | padding: 0;
13 | /* flex-direction: row; */
14 | flex-flow: row wrap;
15 |
16 | /* /* Then we define how is distributed the remaining space */
17 | justify-content: center;
18 | /* align-items: center; */
19 | background-color: gray;
20 | height: 500px;
21 | padding: 10px;
22 | list-style: none;
23 | }
24 |
25 | .flex-item {
26 | background: tomato;
27 | padding: 5px;
28 | margin: 10px;
29 | width: 200px;
30 | height: 150px;
31 | margin-top: 10px;
32 | line-height: 150px;
33 | color: white;
34 | font-weight: bold;
35 | font-size: 3em;
36 | text-align: center;
37 | }
38 |
39 | .flex-item:first-child {
40 | width: 300px;
41 | height: 100px;
42 | list-style: 100px;
43 | }
44 |
45 |
46 | body {
47 | margin: 0;
48 | }
49 |
50 | /*
51 | .navigation {
52 | display: flex;
53 | flex-flow: row wrap;
54 | justify-content: flex-end;
55 | list-style: none;
56 | margin: 0;
57 | background: deepskyblue;
58 | }
59 |
60 | .navigation a {
61 | text-decoration: none;
62 | display: block;
63 | padding: 1em;
64 | color: white;
65 | }
66 |
67 | .navigation a:hover {
68 | background: #1565C0;
69 | text-decoration: underline;
70 | }
71 |
72 |
73 | @media all and (max-width: 800px) {
74 | .navigation {
75 | justify-content: space-around;
76 | }
77 | }
78 |
79 | @media all and (max-width: 600px) {
80 | .navigation {
81 | flex-flow: column wrap;
82 | padding: 0;
83 | }
84 |
85 | .navigation a {
86 | text-align: center;
87 | padding: 10px;
88 | border-top: 1px solid rgba(255, 255, 255, 0.3);
89 | border-bottom: 1px solid rgba(0, 0, 0, 0.1);
90 | }
91 |
92 | .navigation li:last-of-type a {
93 | border-bottom: none;
94 | }
95 | } */
96 |
97 | .wrapper {
98 | display: flex;
99 | flex-flow: row wrap;
100 | font-weight: bold;
101 | text-align: center;
102 | }
103 |
104 | .wrapper>* {
105 | padding: 10px;
106 | flex: 1 100%;
107 | }
108 |
109 | .header {
110 | background: tomato;
111 | }
112 |
113 | .footer {
114 | background: lightgreen;
115 | }
116 |
117 | .main {
118 | text-align: left;
119 | background: deepskyblue;
120 | }
121 |
122 | .aside-1 {
123 | background: gold;
124 | }
125 |
126 | .aside-2 {
127 | background: hotpink;
128 | }
129 | /*
130 | @media all and (min-width: 600px) {
131 | .aside {
132 | flex: 1 0 0;
133 | }
134 | } */
135 | /*
136 | @media all and (min-width: 800px) {
137 | .main {
138 | flex: 3 0px;
139 | }
140 |
141 | .aside-1 {
142 | order: 1;
143 | }
144 |
145 | .main {
146 | order: 2;
147 | }
148 |
149 | .aside-2 {
150 | order: 3;
151 | }
152 |
153 | .footer {
154 | order: 4;
155 | }
156 | } */
--------------------------------------------------------------------------------
/Code-base/Day7/assets/css/pseudo.css:
--------------------------------------------------------------------------------
1 | .parent {
2 | width: 500px;
3 | height: 500px;
4 | overflow: hidden;
5 | background-color: grey;
6 | /* padding: 10px; */
7 | }
8 |
9 | .child {
10 | /* width: 150px;
11 | height: 150px; */
12 | background-color: lightblue;
13 | color: black;
14 | margin: 5px;
15 | padding: 10px;
16 | display: inline-block;
17 | border: 0;
18 | }
19 |
20 | /*
21 | Pseudo-class will be
22 |
23 | selector:pseudo-class
24 |
25 | :hover is when you hover on the elem
26 |
27 | :active is when you have clicked and have NOT left the click
28 |
29 | :focus after the active state
30 | */
31 | /* .child:hover {
32 | background-color: blue;
33 | color: white;
34 | outline: 1px solid blue;
35 | outline-offset: 2px;
36 | }
37 |
38 |
39 | .child:active {
40 | background-color: darkblue;
41 | color: white;
42 | outline: 1px solid darkblue;
43 | outline-offset: 2px;
44 | } */
45 |
46 |
47 | /* .child:first-child {
48 | background-color: darkslategrey;
49 | color: white;
50 | text-transform: uppercase;
51 | }
52 |
53 | .child:last-child {
54 | background-color: darkgreen;
55 | color: lightgray;
56 | text-transform: uppercase;
57 | }
58 | */
59 |
60 |
61 | /*
62 | number , keywords , formulae
63 | */
64 |
65 | /* .child:nth-child(3n) {
66 | background-color: white;
67 | color: darkblue;
68 | border: 1px solid blue;
69 | } */
70 |
71 | /*
72 | .child:nth-child(even) {
73 | background-color: white;
74 | color: darkred;
75 | border: 1px solid darkred;
76 | } */
77 |
78 | .child::selection {
79 | background-color: azure;
80 | }
81 |
82 | input::placeholder{
83 | color: darkblue;
84 | }
85 |
86 | input:hover::placeholder {
87 | /* font-size: 0; */
88 | color: aquamarine;
89 | }
90 |
91 |
92 | .child::before {
93 | content: "~~";
94 | }
95 |
96 | .span-before{
97 |
98 | }
--------------------------------------------------------------------------------
/Code-base/Day7/flex.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Position
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | 1
14 | 2
15 | 3
16 | 4
17 | 5
18 | 6
19 |
20 |
21 |
22 |
28 |
29 |
30 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/Code-base/Day7/flexbox.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
113 |
114 |
115 |
116 |
117 |
123 |
124 |
125 |
126 |
127 |
128 | Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum
129 | tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas
130 | semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
--------------------------------------------------------------------------------
/Code-base/Day7/pseudo.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | pseudo
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | ~~
17 |
18 | Hello child 1
19 |
20 |
21 |
23 |
32 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/Code-base/Day8/assets/css/media.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | }
4 |
5 | /*
6 | .navigation {
7 | display: flex;
8 | flex-flow: row wrap;
9 | justify-content: flex-end;
10 | list-style: none;
11 | margin: 0;
12 | background: deepskyblue;
13 | }
14 |
15 | .navigation a {
16 | text-decoration: none;
17 | display: block;
18 | padding: 1em;
19 | color: white;
20 | }
21 |
22 | .navigation a:hover {
23 | background: #1565C0;
24 | text-decoration: underline;
25 | }
26 |
27 |
28 | @media all and (max-width: 800px) {
29 | .navigation {
30 | justify-content: space-evenly;
31 | }
32 | }
33 |
34 | @media all and (max-width: 600px) {
35 | .navigation {
36 | flex-flow: column wrap;
37 | padding: 0;
38 | }
39 |
40 | .navigation a {
41 | text-align: center;
42 | padding: 10px;
43 | border-top: 1px solid rgba(255, 255, 255, 0.3);
44 | border-bottom: 1px solid rgba(0, 0, 0, 0.1);
45 | }
46 |
47 | .navigation li:last-of-type a {
48 | border-bottom: none;
49 | }
50 | } */
51 |
52 | .wrapper {
53 | display: flex;
54 | flex-flow: row wrap;
55 | font-weight: bold;
56 | text-align: center;
57 | }
58 |
59 | /* Select ALL Immediate Child nodes/elements of .wrapper */
60 | .wrapper>* {
61 | padding: 10px;
62 | flex: 1 1 100%;
63 | }
64 |
65 | .header {
66 | background: tomato;
67 | }
68 |
69 | .footer {
70 | background: lightgreen;
71 | }
72 |
73 | .main {
74 | text-align: left;
75 | background: deepskyblue;
76 | }
77 |
78 | .aside-1 {
79 | background: gold;
80 | }
81 |
82 | .aside-2 {
83 | background: hotpink;
84 | }
85 |
86 |
87 | @media all and (min-width: 600px) {
88 | .aside {
89 | flex: 1 0 0;
90 | }
91 | }
92 |
93 | @media all and (min-width: 800px) {
94 | .main {
95 | flex: 3 0px;
96 | }
97 |
98 | .aside-1 {
99 | order: 1;
100 | }
101 |
102 | .main {
103 | order: 2;
104 | }
105 |
106 | .aside-2 {
107 | order: 3;
108 | }
109 |
110 | .footer {
111 | order: 4;
112 | }
113 | }
--------------------------------------------------------------------------------
/Code-base/Day8/assets/css/pseudo.css:
--------------------------------------------------------------------------------
1 | .parent {
2 | width: 500px;
3 | height: 500px;
4 | overflow: hidden;
5 | background-color: grey;
6 | /* padding: 10px; */
7 | }
8 |
9 | .child {
10 | /* width: 150px;
11 | height: 150px; */
12 | background-color: lightblue;
13 | color: black;
14 | margin: 5px;
15 | padding: 10px;
16 | display: inline-block;
17 | border: 0;
18 | }
19 |
20 | /*
21 | Pseudo-class will be
22 |
23 | selector:pseudo-class
24 |
25 | :hover is when you hover on the elem
26 |
27 | :active is when you have clicked and have NOT left the click
28 |
29 | :focus after the active state
30 | */
31 | /* .child:hover {
32 | background-color: blue;
33 | color: white;
34 | outline: 1px solid blue;
35 | outline-offset: 2px;
36 | }
37 |
38 |
39 | .child:active {
40 | background-color: darkblue;
41 | color: white;
42 | outline: 1px solid darkblue;
43 | outline-offset: 2px;
44 | } */
45 |
46 |
47 | /* .child:first-child {
48 | background-color: darkslategrey;
49 | color: white;
50 | text-transform: uppercase;
51 | }
52 |
53 | .child:last-child {
54 | background-color: darkgreen;
55 | color: lightgray;
56 | text-transform: uppercase;
57 | }
58 | */
59 |
60 |
61 | /*
62 | number , keywords , formulae
63 | */
64 |
65 | /* .child:nth-child(3n) {
66 | background-color: white;
67 | color: darkblue;
68 | border: 1px solid blue;
69 | } */
70 |
71 | /*
72 | .child:nth-child(even) {
73 | background-color: white;
74 | color: darkred;
75 | border: 1px solid darkred;
76 | } */
77 |
78 | .child::selection {
79 | background-color: azure;
80 | }
81 |
82 | input::placeholder{
83 | color: darkblue;
84 | }
85 |
86 | input:hover::placeholder {
87 | /* font-size: 0; */
88 | color: aquamarine;
89 | }
90 |
91 |
92 | .child::before {
93 | content: "~~";
94 | }
95 |
96 | .span-before{
97 |
98 | }
--------------------------------------------------------------------------------
/Code-base/Day8/flex.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Media
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum
17 | tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas
18 | semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Code-base/Day8/pseudo.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | pseudo
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | ~~
17 |
18 | Hello child 1
19 |
20 |
21 |
23 |
32 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/Front-end/Javascript/Assignment-1/README.md:
--------------------------------------------------------------------------------
1 | # Online Code Editor (JQuery)
2 |
3 | Create an online code editor for HTML, CSS and JS code snippets using HTML, CSS and JQuery. The code editor’s functionality will be similar to that of https://jsbin.com/?html,output
4 |
5 | For any developer, be it amateur or professional, often the liberty of using a local code editor may be unavailable. As online code-editors are fast, efficient and greatly popular, it is a familiar tool among developers. If you have used one, ever wondered how it can be made?
6 |
7 | You are free to use JavaScript instead of JQuery but it is recommended to use JQuery as it is lighter to implement.
--------------------------------------------------------------------------------
/Front-end/Javascript/Assignment-2/README.md:
--------------------------------------------------------------------------------
1 | # Sorting Algorithm's Visualizer
2 |
3 | Create a web application using HTML, CSS, Javascript to visualize how various sorting algorithms work. This project’s functionality will be similar to [this](https://www.cs.usfca.edu/~galles/visualization/ComparisonSort.html) application
4 |
5 | ### High Level Approach :
6 | 1. Creating the website's User Interface (UI) using HTML, CSS and enhancing it further using Bootstrap; without actually implementing any of the app's core features.
7 | 1. Implementation of animations, effects and core functionalities (sorting algorithms) using JavaScript.
--------------------------------------------------------------------------------
/Front-end/Javascript/Assignment-3/README.md:
--------------------------------------------------------------------------------
1 | # JavaScript Calculator
2 |
3 | Don't have to explain any thing here :/
4 |
5 | ## If you want a change try implementing calculus :)
--------------------------------------------------------------------------------
/Front-end/Javascript/Assignment-4/README.md:
--------------------------------------------------------------------------------
1 | # DOM Tree Creator
2 |
3 | ## Types of Inputs that should be supported :
4 | 1. HTML file
5 | 2. HTML String
6 | 3. URL of HTML File
7 | 4.
--------------------------------------------------------------------------------
/Front-end/Javascript/Assignment-5/Readme.md:
--------------------------------------------------------------------------------
1 | # Rock Paper Scissors
2 |
3 | ## Basic Concept :
4 | So, the basic concept behind this game is to create 3 `buttons`, and attach event listeners to them. Each event listen would have an `id` and is going to trigger a function that handles the RockPaperScissor game logic.
5 |
6 | You'll also need to maintain a scoreboard that shows your score and is updated each time you press the button.
7 |
8 | tip : You can add images of rock, paper and scissors and then attach event listers to them directly.
9 |
--------------------------------------------------------------------------------
/Front-end/Javascript/Assignment-6/readme.md:
--------------------------------------------------------------------------------
1 | # Tic Tac Toe game
2 |
3 | ## Basic Concept :
4 | This is another game you can build using `html`, `css` and `javascript`.
5 | This project would not only challenge your CSS skills but also logic building skills with JS.
6 |
7 | So, the basic concept behind this game is to create 9 `divs`, align them all within the square using `CSS Flexbox` or `CSS grids`. Once you are done with the layout you need to add event listeners to each element, which triggers the move. On each move you'll need to keep a track of current state of the board, once a player reached winning state you can display the result.
8 |
9 |
10 | tip : You can create an array of all winning states, and then compare it to the move array of each user to check wo wins.
11 |
--------------------------------------------------------------------------------
/Front-end/Pure HTML CSS/Assignment-1/README.md:
--------------------------------------------------------------------------------
1 | # MAKE YOUR RESUME INTERACTIVE
2 |
3 | This is for your own brand as well as to sharpen your skills. In the same vein of building your own personal website, building an interactive resume is one way to show you know your foundational skills while also making your resume fun
4 |
5 | ## It is not your Portfolio.
6 |
7 | *Should not have JS.*
8 | Use Only CSS and HTML
9 |
10 | ## Create Your CV Here, but still interactive
11 |
12 |
13 | #### Reference:
14 | https://dev.to/alvaromontoro/developing-an-interactive-resume-with-html-and-css-5007
15 |
16 |
17 | ### Key Take Aways :
18 | 1. Go Through the Reference throughly.
19 | 1. Use Semantic HTML5 Tags
20 | 1. time
21 | 1. address
22 | 1. article
23 | 1. Use Comments for CSS and HTML
24 | 1. Use Tables for layout ( Grids / flexbox only if you are know the concepts )
--------------------------------------------------------------------------------
/Front-end/Pure HTML CSS/Assignment-2/README.md:
--------------------------------------------------------------------------------
1 | # CREATE AN EMAIL NEWSLETTER
2 |
3 | There are job opportunities focused on email building that require HTML and CSS knowledge. You can use an email newsletter service like MailChimp and customize the designs.
4 |
5 | ## Here are some ideas on what emails to create for practice:
6 |
7 | 1. Build an email newsletter to share your journey into tech with lessons you’ve learned and projects you’ve built with friends and family
8 | 1. Launch an email newsletter of upcoming events in the area or your favorite local spots
9 | 1. Open the promotions tab on your gmail for more Ideas
10 |
11 | *Should not have JS.*
12 | Use Only CSS and HTML
13 |
14 | ### Key Take Aways :
15 | 1. Read about what tags are accepted in email templates.
16 | 1. Learn about 3rd Party Applications like MailChimp , SendGrid , etc.
17 | 1. Use Comments for CSS and HTML
18 | 1. Use Tables for layout ( Grids / flexbox only if you are know the concepts )
--------------------------------------------------------------------------------
/Front-end/Pure HTML CSS/Assignment-3/README.md:
--------------------------------------------------------------------------------
1 | # Build a Technical Documentation Page
2 |
3 | This will require some knowledge of HTML CSS , Layouts ( Grids/Flexbox/Tables )
--------------------------------------------------------------------------------
/Front-end/Pure HTML CSS/Assignment-4/README.md:
--------------------------------------------------------------------------------
1 | # google.com Search result page
2 |
3 | 1. You will create a page with the format of a google search result. Your page should have the normal 10 results and the navigation to next pages at the bottom.
4 | 1. Also,make the page should look somewhat but the functionality should not be a concern right now.
5 | 1. Pagination is not necessary , Students with understanding of jQuery can do it.
6 | 1. You will need to learn About Favicons and Positioning to completely replicate the page. It is not necessary.
--------------------------------------------------------------------------------
/Mini-projects/candy-crush/assets/css/style.css:
--------------------------------------------------------------------------------
1 | .grid {
2 | height: 560px;
3 | width: 560px;
4 |
5 | display: flex;
6 | flex-wrap: wrap;
7 |
8 | margin: 50px 80px;
9 |
10 | background-color: darkblue;
11 | }
12 |
13 | .grid div {
14 | width: 70px;
15 | height: 70px;
16 | }
17 |
--------------------------------------------------------------------------------
/Mini-projects/candy-crush/assets/images/blue-candy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Mini-projects/candy-crush/assets/images/blue-candy.png
--------------------------------------------------------------------------------
/Mini-projects/candy-crush/assets/images/green-candy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Mini-projects/candy-crush/assets/images/green-candy.png
--------------------------------------------------------------------------------
/Mini-projects/candy-crush/assets/images/orange-candy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Mini-projects/candy-crush/assets/images/orange-candy.png
--------------------------------------------------------------------------------
/Mini-projects/candy-crush/assets/images/purple-candy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Mini-projects/candy-crush/assets/images/purple-candy.png
--------------------------------------------------------------------------------
/Mini-projects/candy-crush/assets/images/red-candy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Mini-projects/candy-crush/assets/images/red-candy.png
--------------------------------------------------------------------------------
/Mini-projects/candy-crush/assets/images/yellow-candy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techinnovadors/Full-Stack-Assignments/272b8877f23d30f3f4f0b90521055b8a9eb32a17/Mini-projects/candy-crush/assets/images/yellow-candy.png
--------------------------------------------------------------------------------
/Mini-projects/candy-crush/assets/js/main.js:
--------------------------------------------------------------------------------
1 | document.addEventListener('DOMContentLoaded', () => {
2 | const grid = document.querySelector(".grid");
3 | const width = 8;
4 | let score = 0;
5 |
6 | const candies = [];
7 |
8 | const candyImages = [
9 | 'url(assets/images/red-candy.png)',
10 | 'url(assets/images/yellow-candy.png)',
11 | 'url(assets/images/orange-candy.png)',
12 | 'url(assets/images/purple-candy.png)',
13 | 'url(assets/images/green-candy.png)',
14 | 'url(assets/images/blue-candy.png)'
15 | ];
16 |
17 |
18 |
19 | function createBoard() {
20 | for (let i = 0; i < width * width; i++) {
21 | let candy = document.createElement('div');
22 | let randomImageIndex = Math.floor(Math.random() * candyImages.length);
23 |
24 | candy.setAttribute("draggable", true);
25 | candy.setAttribute("id", i);
26 | candy.style.backgroundImage = candyImages[randomImageIndex];
27 |
28 | grid.appendChild(candy);
29 |
30 | candies.push(candy)
31 | }
32 | }
33 | createBoard();
34 |
35 | let ImageBeingDragged;
36 | let candyBeingDragged;
37 | let ImageBeingReplaced;
38 | let candyBeingReplaced;
39 |
40 | candies.forEach(candy => candy.addEventListener("dragstart", dragStart));
41 | candies.forEach(candy => candy.addEventListener("dragend", dragEnd));
42 | candies.forEach(candy => candy.addEventListener("dragleave", dragLeave));
43 | candies.forEach(candy => candy.addEventListener("drop", dragDrop));
44 |
45 | candies.forEach(candy => candy.addEventListener("dragover", function (e) {
46 | e.preventDefault();
47 | }));
48 | candies.forEach(candy => candy.addEventListener("dragenter", function (e) {
49 | e.preventDefault();
50 | }));
51 |
52 |
53 | document.getElementById("save_button").addEventListener('click', saveGame);
54 |
55 |
56 | function dragStart() {
57 | ImageBeingDragged = this.style.backgroundImage;
58 | candyBeingDragged = parseInt(this.id);
59 | }
60 |
61 | function dragLeave() {
62 | console.log(this.id, "DragLeave");
63 | }
64 |
65 | function dragDrop() {
66 | ImageBeingReplaced = this.style.backgroundImage;
67 | candyBeingReplaced = parseInt(this.id);
68 |
69 | this.style.backgroundImage = ImageBeingDragged;
70 | candies[candyBeingDragged].style.backgroundImage = ImageBeingReplaced;
71 | }
72 |
73 | function dragEnd() {
74 |
75 | /**
76 | * what is a valid move?
77 | *
78 | * we can swipe two adjacent candies only.
79 | * 23 23 24
80 | * */
81 |
82 | let validMoves = [
83 | candyBeingDragged + 1,
84 | candyBeingDragged - 1,
85 | candyBeingDragged + width,
86 | candyBeingDragged - width
87 | ]
88 |
89 | console.log(candyBeingReplaced, "In drag End", candyBeingDragged)
90 | const inValidMove = (candyBeingDragged + candyBeingReplaced) % width == width - 1 &&
91 | (candyBeingDragged % width == 0 || candyBeingReplaced % width == 0);
92 | const isValidMove = validMoves.includes(candyBeingReplaced) && !inValidMove;
93 |
94 | if (candyBeingReplaced && isValidMove) {
95 |
96 | init();
97 | candyBeingReplaced = null;
98 | candyBeingDragged = null;
99 | ImageBeingReplaced = null;
100 | ImageBeingDragged = null;
101 | } else if (candyBeingReplaced && !isValidMove) {
102 | candies[candyBeingDragged].style.backgroundImage = ImageBeingDragged;
103 | candies[candyBeingReplaced].style.backgroundImage = ImageBeingReplaced;
104 | }
105 | }
106 |
107 |
108 | function generateRandomCandies() {
109 | let len = width * (width - 1); // 55
110 | for (let i = 0; i < len; i++) {
111 | if (candies[i + width].style.backgroundImage === '') {
112 | candies[i + width].style.backgroundImage = candies[i].style.backgroundImage
113 | candies[i].style.backgroundImage = ''
114 | }
115 | // Candy in first row has no backgroud
116 | if (i < width && candies[i].style.backgroundImage == '') {
117 | candies[i].style.backgroundImage = candyImages[
118 | Math.floor(Math.random() * candyImages.length)
119 | ];
120 | }
121 | }
122 | }
123 |
124 | function checkRow(no_of_candies) {
125 | let invalidIndex = [];
126 | let len = width * width - no_of_candies
127 | for (let i = width - no_of_candies + 1; i <= len; i += width) {
128 | ///pushing elements in invalidIndex
129 | invalidIndex.push(i, i + 1);
130 | if (no_of_candies >= 4) invalidIndex.push(i + 2);
131 | if (no_of_candies == 5) invalidIndex.push(i + 3);
132 | }
133 | // console.log(no_of_candies, invalidIndex)
134 | for (let i = 0; i <= len; i++) {
135 | let candiesList = []
136 | //populate candiesList
137 | candiesList.push(i, i + 1, i + 2);
138 | if (no_of_candies >= 4) candiesList.push(i + 3);
139 | if (no_of_candies == 5) candiesList.push(i + 4);
140 |
141 | let desiredImage = candies[i].style.backgroundImage;
142 |
143 | /**
144 | * If i present in the invalidIndex Array forget it;
145 | */
146 | if (invalidIndex.includes(i)) continue;
147 | /***
148 | *
149 | * If Every Element satisfies the condition after arrow
150 | * Or for every element the fuction returns true.
151 | *
152 | * then the final result is true
153 | */
154 | let match = candiesList.every(index => desiredImage != "" && candies[index].style.backgroundImage == desiredImage);
155 | if (match) {
156 | score += no_of_candies;
157 | // console.log(score)
158 | candiesList.forEach(index => candies[index].style.backgroundImage = "")
159 | }
160 |
161 |
162 | }
163 |
164 | }
165 |
166 | function checkColumnforFive() {
167 | let len = width * (width - 4);
168 |
169 | for (let i = 0; i < len; i++) {
170 | let fiveCandies = [i, i + width, i + width * 2, i + width * 3, i + width * 4];
171 | let desiredImage = candies[i].style.backgroundImage;
172 |
173 | /***
174 | *
175 | * If Every Element satisfies the condition after arrow
176 | * Or for every element the fuction returns true.
177 | * then the final result is true
178 | *
179 | */
180 | let match = fiveCandies.every(index => desiredImage != "" && candies[index].style.backgroundImage == desiredImage);
181 | if (match) {
182 | score += 5;
183 | console.log(score)
184 | fiveCandies.forEach(index => candies[index].style.backgroundImage = "")
185 | }
186 |
187 | }
188 | }
189 |
190 | function checkColumnforFour() {
191 | let len = width * (width - 3);
192 |
193 | for (let i = 0; i < len; i++) {
194 | let fourCandies = [i, i + width, i + width * 2, i + width * 3];
195 | let desiredImage = candies[i].style.backgroundImage;
196 |
197 | /***
198 | *
199 | * If Every Element satisfies the condition after arrow
200 | * Or for every element the fuction returns true.
201 | * then the final result is true
202 | *
203 | */
204 | let match = fourCandies.every(index => desiredImage != "" && candies[index].style.backgroundImage == desiredImage);
205 | if (match) {
206 | score += 4;
207 | console.log(score)
208 | fourCandies.forEach(index => candies[index].style.backgroundImage = "")
209 | }
210 |
211 | }
212 | }
213 |
214 | function checkColumnforThree() {
215 | let len = width * (width - 2);
216 |
217 | for (let i = 0; i < len; i++) {
218 | let threeCandies = [i, i + width, i + width * 2];
219 | let desiredImage = candies[i].style.backgroundImage;
220 |
221 | /***
222 | *
223 | * If Every Element satisfies the condition after arrow
224 | * Or for every element the fuction returns true.
225 | * then the final result is true
226 | *
227 | */
228 |
229 | let match = threeCandies.every(index => desiredImage != "" && candies[index].style.backgroundImage == desiredImage);
230 | if (match) {
231 | score += 3;
232 | console.log(score)
233 | threeCandies.forEach(index => candies[index].style.backgroundImage = "")
234 | }
235 |
236 | }
237 | }
238 |
239 |
240 | function saveGame() {
241 | let candiesInfo = [];
242 | candies.forEach(candy => candiesInfo[candy.id] = candy.style.backgroundImage);
243 | localStorage.setItem("board", JSON.stringify(candiesInfo));
244 | }
245 |
246 | function loadGame() {
247 | let oldBoard = JSON.parse(localStorage.getItem("board"));
248 |
249 | /***
250 | * Create the board again.
251 | * use
252 | * foreach.
253 | * getattribute
254 | */
255 | }
256 |
257 | function init() {
258 | checkRow(5);
259 | checkColumnforFive();
260 | checkRow(4);
261 | checkColumnforFour();
262 | checkRow(3);
263 | checkColumnforThree()
264 | generateRandomCandies();
265 | }
266 | init();
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 | window.setInterval(function () {
275 | init()
276 | }, 100);
277 |
278 | });
279 |
280 | /**
281 | Easy
282 | ---------------------------
283 |
284 | * Reduce columns checks to one function
285 | * Show the score on the page
286 | * Have a reset game button.
287 | * Have a shuffle game button and allow only 3 shuffles
288 |
289 | * Count number of Moves.
290 | * Have a win Condition
291 |
292 | Intermediate
293 | ---------------------------
294 | *
295 | * Make the game responsive
296 | *
297 | Difficult (Read About LocalStorage)
298 | ---------------------------
299 | * Share game with someone
300 | * A Save game button
301 | * On Refresh of page the game should not restart.
302 | *
303 | */
--------------------------------------------------------------------------------
/Mini-projects/candy-crush/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Candy Crush
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | Save the Game
21 |
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Full-Stack-Assignments
2 |
3 | Hi Students, If you are here, well step 1 is completed.
4 | There is quite alot to learn.
5 |
6 | You don't have to complete all of these.
7 | Pick what excites you, complete and extend it.
8 | The List will keep increasing.
9 |
10 | 1. Front-end
11 | 1. Pure HTML CSS (4)
12 | 1. Javascript (4)
13 |
14 | That's all I have for now!
15 |
16 |
17 | # create a new repo
18 | # added the remote url of that repo, called it session to my local repo
--------------------------------------------------------------------------------