├── .gitignore
├── README.md
├── doubtSession1
├── promise.js
└── setTimeout.js
├── doubtSession2
├── StrInter.js
├── date.js
├── index.html
├── js.html
└── style.css
├── doubtSession3
├── fire
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── robots.txt
│ ├── src
│ │ ├── App.css
│ │ ├── App.js
│ │ ├── App.test.js
│ │ ├── Home.js
│ │ ├── Login.js
│ │ ├── index.css
│ │ ├── index.js
│ │ ├── logo.svg
│ │ ├── reportWebVitals.js
│ │ ├── setupTests.js
│ │ └── utils
│ │ │ └── firebase.js
│ └── yarn.lock
└── routes
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ ├── favicon.ico
│ ├── index.html
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ └── robots.txt
│ ├── src
│ ├── App.css
│ ├── App.js
│ ├── App.test.js
│ ├── index.css
│ ├── index.js
│ ├── logo.svg
│ ├── pages
│ │ ├── About.js
│ │ ├── Home.js
│ │ ├── Topic.js
│ │ ├── Topics.js
│ │ └── Users.js
│ ├── reportWebVitals.js
│ └── setupTests.js
│ └── yarn.lock
├── hello.js
├── lecture-02
├── arithmatic.js
├── conditional.js
├── ifelse.js
├── loops.js
├── numbertype.js
└── patterns
│ ├── downtring.js
│ ├── line.js
│ ├── square.js
│ └── uptring.js
├── lecture-03
├── fn
│ ├── arrayoffn.js
│ ├── filter.js
│ ├── fnStory.js
│ ├── interwal.js
│ ├── map.js
│ └── si.js
└── patterns
│ ├── diamond.js
│ └── square.js
├── lecture-04
├── .gitignore
├── askandshow.js
├── makecall.js
├── photos
│ └── keenwarrior.jpg
└── reading.js
├── lecture-05
├── asyncBehave.js
└── promiseEg.js
├── lecture-07
└── wapp
│ ├── arraw.js
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── lecture-08
├── another.html
├── hey.html
└── index.html
├── lecture-09
├── another.html
├── external.css
├── index.html
└── interpolation.js
├── lecture-11
├── hello
│ ├── .gitignore
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── robots.txt
│ └── src
│ │ ├── App.css
│ │ ├── App.js
│ │ ├── App.test.js
│ │ ├── index.css
│ │ ├── index.js
│ │ ├── logo.svg
│ │ ├── reportWebVitals.js
│ │ └── setupTests.js
└── l11.svgz
├── lecture-12
├── calc
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── robots.txt
│ └── src
│ │ ├── App.css
│ │ ├── App.js
│ │ ├── App.test.js
│ │ ├── index.css
│ │ ├── index.js
│ │ ├── logo.svg
│ │ ├── reportWebVitals.js
│ │ └── setupTests.js
└── l12.svgz
├── lecture-13
├── calc
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── robots.txt
│ └── src
│ │ ├── App.css
│ │ ├── App.js
│ │ ├── App.test.js
│ │ ├── index.css
│ │ ├── index.js
│ │ ├── logo.svg
│ │ ├── reportWebVitals.js
│ │ └── setupTests.js
└── l12.svgz
├── lecture-14
├── Doc.svgz
└── tictactoe
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ ├── favicon.ico
│ ├── index.html
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ └── robots.txt
│ └── src
│ ├── App.js
│ ├── App.test.js
│ ├── TicTacToe.js
│ ├── index.css
│ ├── index.js
│ ├── logo.svg
│ ├── reportWebVitals.js
│ ├── setupTests.js
│ └── utils
│ └── boardUtil.js
├── lecture-15
└── firelogin
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ ├── favicon.ico
│ ├── index.html
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ └── robots.txt
│ └── src
│ ├── App.css
│ ├── App.js
│ ├── App.test.js
│ ├── Home.js
│ ├── Login.js
│ ├── index.css
│ ├── index.js
│ ├── logo.svg
│ ├── reportWebVitals.js
│ ├── setupTests.js
│ └── utils
│ └── firebase.js
├── lecture-16
└── routing
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ ├── favicon.ico
│ ├── index.html
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ └── robots.txt
│ └── src
│ ├── App.css
│ ├── App.js
│ ├── App.test.js
│ ├── components
│ └── SimpleList.js
│ ├── index.css
│ ├── index.js
│ ├── layouts
│ └── MainLayout.js
│ ├── logo.svg
│ ├── pages
│ ├── DraftsPage.js
│ ├── InboxPage.js
│ ├── SpamPage.js
│ └── TrashPage.js
│ ├── reportWebVitals.js
│ └── setupTests.js
├── lecture-18
├── May 3 18h24.svgz
├── forms
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ ├── images
│ │ │ └── bg.jpg
│ │ ├── index.html
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── robots.txt
│ └── src
│ │ ├── App.css
│ │ ├── App.js
│ │ ├── App.test.js
│ │ ├── index.css
│ │ ├── index.js
│ │ ├── logo.svg
│ │ ├── reportWebVitals.js
│ │ └── setupTests.js
└── server
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── lecture-19
└── firelogin
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ ├── favicon.ico
│ ├── index.html
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ └── robots.txt
│ └── src
│ ├── App.css
│ ├── App.js
│ ├── App.test.js
│ ├── Home.js
│ ├── Login.js
│ ├── index.css
│ ├── index.js
│ ├── logo.svg
│ ├── reportWebVitals.js
│ ├── setupTests.js
│ └── utils
│ ├── axios.js
│ └── firebase.js
├── lecture-20
├── firelogin
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── robots.txt
│ └── src
│ │ ├── App.css
│ │ ├── App.js
│ │ ├── App.test.js
│ │ ├── Home.js
│ │ ├── Login.js
│ │ ├── index.css
│ │ ├── index.js
│ │ ├── logo.svg
│ │ ├── reportWebVitals.js
│ │ ├── setupTests.js
│ │ └── utils
│ │ ├── axios.js
│ │ └── firebase.js
└── server
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ ├── another.html
│ └── index.html
│ └── service.json
├── lecture-21
├── firelogin
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── robots.txt
│ └── src
│ │ ├── App.css
│ │ ├── App.js
│ │ ├── App.test.js
│ │ ├── Home.js
│ │ ├── Login.js
│ │ ├── Routes.js
│ │ ├── index.css
│ │ ├── index.js
│ │ ├── logo.svg
│ │ ├── reportWebVitals.js
│ │ ├── setupTests.js
│ │ └── utils
│ │ ├── axios.js
│ │ └── firebase.js
└── server
│ ├── .gitignore
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ ├── another.html
│ └── index.html
│ └── service.json
├── lecture-22
├── May 13 18h06.svgz
└── ws
│ ├── client.js
│ ├── package-lock.json
│ ├── package.json
│ └── server.js
├── lecture-23
├── May 14 18h07.svgz
├── firelogin
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── robots.txt
│ └── src
│ │ ├── App.css
│ │ ├── App.js
│ │ ├── App.test.js
│ │ ├── Home.js
│ │ ├── Login.js
│ │ ├── Routes.js
│ │ ├── components
│ │ └── AuthGaurd.js
│ │ ├── index.css
│ │ ├── index.js
│ │ ├── logo.svg
│ │ ├── reportWebVitals.js
│ │ ├── setupTests.js
│ │ └── utils
│ │ ├── axios.js
│ │ └── firebase.js
└── server
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ └── service.json
├── lecture-24
├── May 20 18h09.svgz
├── expboiler
│ ├── .dockerignore
│ ├── .editorconfig
│ ├── .env.example
│ ├── .eslintignore
│ ├── .eslintrc.json
│ ├── .gitattributes
│ ├── .gitignore
│ ├── .husky
│ │ ├── .gitignore
│ │ ├── post-checkout
│ │ ├── post-commit
│ │ └── pre-commit
│ ├── .lintstagedrc.json
│ ├── .prettierignore
│ ├── .prettierrc.json
│ ├── .travis.yml
│ ├── Dockerfile
│ ├── LICENSE
│ ├── README.md
│ ├── docker-compose.dev.yml
│ ├── docker-compose.prod.yml
│ ├── docker-compose.test.yml
│ ├── docker-compose.yml
│ ├── ecosystem.config.json
│ ├── jest.config.js
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── app.js
│ │ ├── config
│ │ │ ├── config.js
│ │ │ ├── logger.js
│ │ │ ├── morgan.js
│ │ │ ├── passport.js
│ │ │ ├── roles.js
│ │ │ └── tokens.js
│ │ ├── controllers
│ │ │ ├── auth.controller.js
│ │ │ ├── index.js
│ │ │ └── user.controller.js
│ │ ├── docs
│ │ │ ├── components.yml
│ │ │ └── swaggerDef.js
│ │ ├── index.js
│ │ ├── middlewares
│ │ │ ├── auth.js
│ │ │ ├── error.js
│ │ │ ├── rateLimiter.js
│ │ │ └── validate.js
│ │ ├── models
│ │ │ ├── index.js
│ │ │ ├── plugins
│ │ │ │ ├── index.js
│ │ │ │ ├── paginate.plugin.js
│ │ │ │ └── toJSON.plugin.js
│ │ │ ├── token.model.js
│ │ │ └── user.model.js
│ │ ├── routes
│ │ │ └── v1
│ │ │ │ ├── auth.route.js
│ │ │ │ ├── docs.route.js
│ │ │ │ ├── index.js
│ │ │ │ └── user.route.js
│ │ ├── services
│ │ │ ├── auth.service.js
│ │ │ ├── email.service.js
│ │ │ ├── index.js
│ │ │ ├── token.service.js
│ │ │ └── user.service.js
│ │ ├── utils
│ │ │ ├── ApiError.js
│ │ │ ├── catchAsync.js
│ │ │ └── pick.js
│ │ └── validations
│ │ │ ├── auth.validation.js
│ │ │ ├── custom.validation.js
│ │ │ ├── index.js
│ │ │ └── user.validation.js
│ └── tests
│ │ ├── fixtures
│ │ ├── token.fixture.js
│ │ └── user.fixture.js
│ │ ├── integration
│ │ ├── auth.test.js
│ │ ├── docs.test.js
│ │ └── user.test.js
│ │ ├── unit
│ │ ├── middlewares
│ │ │ └── error.test.js
│ │ └── models
│ │ │ ├── plugins
│ │ │ ├── paginate.plugin.test.js
│ │ │ └── toJSON.plugin.test.js
│ │ │ └── user.model.test.js
│ │ └── utils
│ │ └── setupTestDB.js
├── forms
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ ├── images
│ │ │ └── bg.jpg
│ │ ├── index.html
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── robots.txt
│ └── src
│ │ ├── App.css
│ │ ├── App.js
│ │ ├── App.test.js
│ │ ├── index.css
│ │ ├── index.js
│ │ ├── logo.svg
│ │ ├── reportWebVitals.js
│ │ └── setupTests.js
└── server
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── lecture-25
├── May 21 18h20.svgz
├── firelogin
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── robots.txt
│ └── src
│ │ ├── App.css
│ │ ├── App.js
│ │ ├── App.test.js
│ │ ├── Home.js
│ │ ├── Login.js
│ │ ├── Routes.js
│ │ ├── components
│ │ └── AuthGaurd.js
│ │ ├── index.css
│ │ ├── index.js
│ │ ├── logo.svg
│ │ ├── reportWebVitals.js
│ │ ├── setupTests.js
│ │ └── utils
│ │ ├── axios.js
│ │ └── firebase.js
└── mozo
│ ├── .dockerignore
│ ├── .editorconfig
│ ├── .env.example
│ ├── .eslintignore
│ ├── .eslintrc.json
│ ├── .gitattributes
│ ├── .gitignore
│ ├── .husky
│ ├── .gitignore
│ ├── post-checkout
│ ├── post-commit
│ └── pre-commit
│ ├── .lintstagedrc.json
│ ├── .prettierignore
│ ├── .prettierrc.json
│ ├── .travis.yml
│ ├── Dockerfile
│ ├── LICENSE
│ ├── README.md
│ ├── docker-compose.dev.yml
│ ├── docker-compose.prod.yml
│ ├── docker-compose.test.yml
│ ├── docker-compose.yml
│ ├── ecosystem.config.json
│ ├── jest.config.js
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ ├── app.js
│ ├── config
│ │ ├── config.js
│ │ ├── logger.js
│ │ ├── morgan.js
│ │ ├── passport.js
│ │ ├── roles.js
│ │ └── tokens.js
│ ├── controllers
│ │ ├── auth.controller.js
│ │ ├── index.js
│ │ └── user.controller.js
│ ├── docs
│ │ ├── components.yml
│ │ └── swaggerDef.js
│ ├── index.js
│ ├── middlewares
│ │ ├── auth.js
│ │ ├── error.js
│ │ ├── rateLimiter.js
│ │ └── validate.js
│ ├── models
│ │ ├── index.js
│ │ ├── plugins
│ │ │ ├── index.js
│ │ │ ├── paginate.plugin.js
│ │ │ └── toJSON.plugin.js
│ │ ├── token.model.js
│ │ └── user.model.js
│ ├── private
│ │ └── service.json
│ ├── routes
│ │ └── v1
│ │ │ ├── auth.route.js
│ │ │ ├── docs.route.js
│ │ │ ├── index.js
│ │ │ └── user.route.js
│ ├── services
│ │ ├── auth.service.js
│ │ ├── email.service.js
│ │ ├── index.js
│ │ ├── token.service.js
│ │ └── user.service.js
│ ├── utils
│ │ ├── ApiError.js
│ │ ├── admin.js
│ │ ├── catchAsync.js
│ │ └── pick.js
│ └── validations
│ │ ├── auth.validation.js
│ │ ├── custom.validation.js
│ │ ├── index.js
│ │ └── user.validation.js
│ └── tests
│ ├── fixtures
│ ├── token.fixture.js
│ └── user.fixture.js
│ ├── integration
│ ├── auth.test.js
│ ├── docs.test.js
│ └── user.test.js
│ ├── unit
│ ├── middlewares
│ │ └── error.test.js
│ └── models
│ │ ├── plugins
│ │ ├── paginate.plugin.test.js
│ │ └── toJSON.plugin.test.js
│ │ └── user.model.test.js
│ └── utils
│ └── setupTestDB.js
├── lecture-26
├── May 27 18h04.svgz
└── reduxeg
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ ├── favicon.ico
│ ├── index.html
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ └── robots.txt
│ └── src
│ ├── App.css
│ ├── App.js
│ ├── App.test.js
│ ├── actions
│ └── countActions.js
│ ├── index.css
│ ├── index.js
│ ├── logo.svg
│ ├── reducers
│ └── countReducer.js
│ ├── reportWebVitals.js
│ ├── setupTests.js
│ └── store
│ └── index.js
├── lecture-29
├── May 31 18h08.svgz
└── learnts
│ ├── .gitignore
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ └── index.ts
│ └── tsconfig.json
├── lecture-30
├── dpatterns
│ ├── dist
│ │ ├── factory.js
│ │ └── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── factory.ts
│ │ └── index.ts
│ └── tsconfig.json
└── nesteg
│ ├── .eslintrc.js
│ ├── .gitignore
│ ├── .prettierrc
│ ├── README.md
│ ├── nest-cli.json
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ ├── app.controller.ts
│ ├── app.module.ts
│ ├── main.ts
│ └── something.ts
│ ├── test
│ ├── app.e2e-spec.ts
│ └── jest-e2e.json
│ ├── tsconfig.build.json
│ └── tsconfig.json
├── lecture-31
├── Jun 7 18h07.svgz
└── relationaleg
│ ├── .eslintrc.js
│ ├── .gitignore
│ ├── .prettierrc
│ ├── README.md
│ ├── nest-cli.json
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ ├── app.controller.spec.ts
│ ├── app.controller.ts
│ ├── app.module.ts
│ ├── app.service.ts
│ ├── main.ts
│ └── users
│ │ ├── dto
│ │ ├── create-user.dto.ts
│ │ └── update-user.dto.ts
│ │ ├── entities
│ │ └── user.entity.ts
│ │ ├── users.controller.ts
│ │ ├── users.module.ts
│ │ └── users.service.ts
│ ├── test
│ ├── app.e2e-spec.ts
│ └── jest-e2e.json
│ ├── tsconfig.build.json
│ └── tsconfig.json
├── lecture-32
├── Jun 10 18h05.svgz
└── animationsreact
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ ├── favicon.ico
│ ├── index.html
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ └── robots.txt
│ └── src
│ ├── App.css
│ ├── App.js
│ ├── App.test.js
│ ├── index.css
│ ├── index.js
│ ├── logo.svg
│ ├── reportWebVitals.js
│ └── setupTests.js
└── package-lock.json
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | extra
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MERN-Live-Special-0321
2 |
--------------------------------------------------------------------------------
/doubtSession1/promise.js:
--------------------------------------------------------------------------------
1 | // let pr = new Promise(function(accept, reject){
2 | // setTimeout(reject, 2000, "reject ho gya");
3 | // setTimeout(accept, 2000, "accpet ho gya");
4 |
5 | // })
6 |
7 | // console.log(typeof pr);
8 |
9 |
10 | // pr.then(function (res){
11 | // console.log(res);
12 | // })
13 | // .catch(function (err){
14 | // console.log(err);
15 | // })
16 |
17 |
18 | let axios = require("axios")
19 |
20 | // axios.get("https://api.github.com/users/keenwarrior").then(
21 | // function(response){
22 | // console.log(response.data);
23 | // }
24 | // )
25 |
26 | let promise = axios.get("https://api.github.com/users/keenwarrior");
27 |
28 | promise.then(function(res){
29 | console.log(res.data);
30 | }).catch((err)=>{
31 | console.log(err);
32 | });
33 |
34 | console.log(promise.data);
--------------------------------------------------------------------------------
/doubtSession1/setTimeout.js:
--------------------------------------------------------------------------------
1 | function kaam(first, second){
2 | console.log(first, second);
3 | }
4 |
5 | setTimeout(kaam, 2000, 1, 2);
6 | setTimeout(kaam, 2000, 2, 3);
--------------------------------------------------------------------------------
/doubtSession2/StrInter.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | let n1 = 10;
4 | let n2 = 20;
5 | let sum = n1+n2;
6 |
7 | function say(){
8 | return "hello";
9 | }
10 |
11 | console.log("This sum of "+n1+" and "+n2+" is "+sum);
12 |
13 | console.log(`This sum of ${n1} and ${n2} is ${say()}`);
14 |
15 |
--------------------------------------------------------------------------------
/doubtSession2/date.js:
--------------------------------------------------------------------------------
1 | function date(){
2 | let p = document.getElementsByClassName('hello');
3 | // let x = new Array();
4 | let x = [];
5 | x.push(p[0]);
6 | x.push(p[1]);
7 | x.push(p[2]);
8 |
9 | console.log(2%10);
10 | console.log(typeof p);
11 | x.map(function (value, index){
12 | value.innerHTML = "kaha";
13 | })
14 |
15 | console.log(p);
16 |
17 | }
--------------------------------------------------------------------------------
/doubtSession2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
12 |
13 |
14 | hii
15 | hello
16 | hello
17 | skjbca
18 |
19 | scbah
20 |
21 |
22 |
--------------------------------------------------------------------------------
/doubtSession2/js.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
9 |
10 |
11 | first
12 | second
13 | third
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/doubtSession2/style.css:
--------------------------------------------------------------------------------
1 | *{
2 | color: blue;
3 | }
4 | #first {
5 | color: aqua;
6 | }
7 |
8 |
--------------------------------------------------------------------------------
/doubtSession3/fire/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/doubtSession3/fire/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/doubtSession3/fire/public/favicon.ico
--------------------------------------------------------------------------------
/doubtSession3/fire/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/doubtSession3/fire/public/logo192.png
--------------------------------------------------------------------------------
/doubtSession3/fire/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/doubtSession3/fire/public/logo512.png
--------------------------------------------------------------------------------
/doubtSession3/fire/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/doubtSession3/fire/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/doubtSession3/fire/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/doubtSession3/fire/src/App.js:
--------------------------------------------------------------------------------
1 | import "./App.css";
2 | import React, { useEffect, useState } from "react";
3 | import Login from "./Login";
4 | import Home from "./Home";
5 | import {firebase} from './utils/firebase';
6 |
7 | let UserContext = React.createContext();
8 |
9 | function App() {
10 | let [user, setUser] = useState();
11 |
12 |
13 | useEffect(function () {
14 | firebase.auth().onAuthStateChanged((user) => {
15 | setUser(user);
16 | console.log(user);
17 | });
18 | }, []);
19 |
20 | return (
21 |
22 |
23 |
24 |
25 |
26 | );
27 | }
28 |
29 | export { App, UserContext };
30 |
--------------------------------------------------------------------------------
/doubtSession3/fire/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/doubtSession3/fire/src/Home.js:
--------------------------------------------------------------------------------
1 | import './App.css';
2 | import { useContext } from 'react';
3 | import { UserContext } from './App';
4 |
5 | function Home() {
6 |
7 | let {user} = useContext(UserContext);
8 |
9 | return (
10 |
11 |
12 |
{user ? user.phoneNumber : undefined}
13 |
14 |
15 | );
16 | }
17 |
18 | export default Home;
19 |
--------------------------------------------------------------------------------
/doubtSession3/fire/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/doubtSession3/fire/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import {App} from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want to start measuring performance in your app, pass a function
15 | // to log results (for example: reportWebVitals(console.log))
16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17 | reportWebVitals();
18 |
--------------------------------------------------------------------------------
/doubtSession3/fire/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/doubtSession3/fire/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/doubtSession3/fire/src/utils/firebase.js:
--------------------------------------------------------------------------------
1 | import firebase from "firebase";
2 |
3 | const config = {
4 | apiKey: "AIzaSyAK5QvhQaW0LcorV8MLpDESpNncY3QGeLE",
5 | authDomain: "specialbatch-2ca95.firebaseapp.com",
6 | projectId: "specialbatch-2ca95",
7 | storageBucket: "specialbatch-2ca95.appspot.com",
8 | messagingSenderId: "674935291974",
9 | appId: "1:674935291974:web:894d6f7ac2f4f2153cca47",
10 | };
11 |
12 | firebase.initializeApp(config);
13 |
14 | export {firebase}
--------------------------------------------------------------------------------
/doubtSession3/routes/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/doubtSession3/routes/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/doubtSession3/routes/public/favicon.ico
--------------------------------------------------------------------------------
/doubtSession3/routes/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/doubtSession3/routes/public/logo192.png
--------------------------------------------------------------------------------
/doubtSession3/routes/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/doubtSession3/routes/public/logo512.png
--------------------------------------------------------------------------------
/doubtSession3/routes/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/doubtSession3/routes/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/doubtSession3/routes/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/doubtSession3/routes/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/doubtSession3/routes/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/doubtSession3/routes/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want to start measuring performance in your app, pass a function
15 | // to log results (for example: reportWebVitals(console.log))
16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17 | reportWebVitals();
18 |
--------------------------------------------------------------------------------
/doubtSession3/routes/src/pages/About.js:
--------------------------------------------------------------------------------
1 |
2 | export default function About() {
3 | return About Page
;
4 | }
--------------------------------------------------------------------------------
/doubtSession3/routes/src/pages/Home.js:
--------------------------------------------------------------------------------
1 |
2 | export default function Home() {
3 | return Home
;
4 | }
--------------------------------------------------------------------------------
/doubtSession3/routes/src/pages/Topic.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import {
3 | useParams
4 | } from "react-router-dom";
5 | export default function Topic() {
6 | let { topicId } = useParams();
7 | return Requested topic ID: {topicId}
;
8 | }
--------------------------------------------------------------------------------
/doubtSession3/routes/src/pages/Users.js:
--------------------------------------------------------------------------------
1 |
2 | export default function Users() {
3 | return Users Page
;
4 | }
--------------------------------------------------------------------------------
/doubtSession3/routes/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/doubtSession3/routes/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/hello.js:
--------------------------------------------------------------------------------
1 | let a = 10;
2 | let b = 20;
3 |
4 | console.log(a + b);
--------------------------------------------------------------------------------
/lecture-02/arithmatic.js:
--------------------------------------------------------------------------------
1 | // arithmatic ops
2 |
3 | // +, -, *, /, %
4 |
5 |
6 | // statement
7 |
8 | // left side reciever
9 | // right side is exp
10 | let vname = 5 + 9;
11 |
12 | console.log(vname);
--------------------------------------------------------------------------------
/lecture-02/conditional.js:
--------------------------------------------------------------------------------
1 | // ops
2 |
3 | // >,<. >=, <=, !=, ==, ===
4 |
5 | console.log(1==="1.0");
6 | console.log(10 != 10);
7 |
--------------------------------------------------------------------------------
/lecture-02/ifelse.js:
--------------------------------------------------------------------------------
1 | // if salary > 2000 then bonus is 500 else bonus is 200
2 |
3 | let salary = 3000;
4 | let total = salary;
5 |
6 | if(salary > 2000){
7 | total = total + 500;
8 | } else {
9 | total = total + 200;
10 | }
11 |
12 | console.log(total);
--------------------------------------------------------------------------------
/lecture-02/loops.js:
--------------------------------------------------------------------------------
1 | let kidAge = 0;
2 |
3 | while(kidAge <= 6){
4 | console.log("Bado ki baat maan ni chahiye");
5 | kidAge = kidAge + 1;
6 | }
--------------------------------------------------------------------------------
/lecture-02/numbertype.js:
--------------------------------------------------------------------------------
1 | let variable = BigInt("1077777777777777777777777777777777777777777777777777777");
2 |
3 | console.log(typeof(variable));
4 | console.log(typeof(variable + BigInt("1")));
--------------------------------------------------------------------------------
/lecture-02/patterns/downtring.js:
--------------------------------------------------------------------------------
1 | let n = 5;
2 |
3 | let row = 0;
4 | while(row < n){
5 |
6 | let col = 0;
7 | while(col < n - row){
8 | process.stdout.write(String(col+1)+" ");
9 | col += 1;
10 | }
11 | process.stdout.write("\n");
12 |
13 | row += 1;
14 | }
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lecture-02/patterns/line.js:
--------------------------------------------------------------------------------
1 | let n = 10;
2 |
3 | while(n > 0){
4 | process.stdout.write("*");
5 | n -= 1;
6 | }
7 |
8 | process.stdout.write("\n");
--------------------------------------------------------------------------------
/lecture-02/patterns/square.js:
--------------------------------------------------------------------------------
1 | let n = 5;
2 |
3 | let row = 0;
4 | while(row < n){
5 |
6 | let col = 0;
7 | while(col < n){
8 | process.stdout.write("* ");
9 | col += 1;
10 | }
11 | process.stdout.write("\n");
12 |
13 | row += 1;
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/lecture-02/patterns/uptring.js:
--------------------------------------------------------------------------------
1 | let n = 3;
2 |
3 | let row = 0;
4 | while(row < n){
5 |
6 | let col = 0;
7 | while(col <= row){
8 | process.stdout.write("* ");
9 | col += 1;
10 | }
11 | process.stdout.write("\n");
12 |
13 | row += 1;
14 | }
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lecture-03/fn/arrayoffn.js:
--------------------------------------------------------------------------------
1 | let arr = [];
2 |
3 | function hey(name){
4 | console.log("hurray " + name);
5 | }
6 |
7 |
8 | arr.push(hey);
9 | arr.push(hey);
10 | arr.push(hey);
11 | arr.push(hey);
12 | arr.push(hey);
13 | arr.push(hey);
14 |
15 | arr.push(function(){
16 | console.log("Party all night");
17 | })
18 |
19 | // arr[0]("Harry");
20 |
21 | console.log(arr);
22 |
--------------------------------------------------------------------------------
/lecture-03/fn/filter.js:
--------------------------------------------------------------------------------
1 | let arr = [10, 21, 30, 0, "", "happy"];
2 |
3 | let out = arr.filter(function(item){
4 | return item;
5 | })
6 |
7 | console.log(2/"jj");
8 |
9 | // console.log(!!null);
10 |
--------------------------------------------------------------------------------
/lecture-03/fn/fnStory.js:
--------------------------------------------------------------------------------
1 | function sayHello(){
2 | console.log("Welcome to Code for Cause");
3 | console.log("Line 2");
4 | console.log("Line 3");
5 | }
6 |
7 | sayHello();
8 | sayHello();
9 | sayHello();
10 | sayHello();
11 | sayHello();
--------------------------------------------------------------------------------
/lecture-03/fn/interwal.js:
--------------------------------------------------------------------------------
1 | function happy(seconds){
2 | console.log("I am happy after " + seconds + " Seconds");
3 | }
4 |
5 | // let another = function(seconds){
6 | // console.log("I am happy after " + seconds + " Seconds");
7 | // }
8 |
9 | // another(6);
10 |
11 |
12 | // console.log(another);
13 |
14 |
15 |
16 | // for(let i=0; i<10; i++){
17 |
18 | // }
19 |
20 | setTimeout(function(){
21 | happy(2);
22 | }, 2000);
23 |
24 |
--------------------------------------------------------------------------------
/lecture-03/fn/map.js:
--------------------------------------------------------------------------------
1 | let arr = [10, 20, 30, 40];
2 |
3 | function square(item){
4 | return item * item;
5 | }
6 |
7 | let out = arr.map(square);
8 |
9 | console.log(out);
--------------------------------------------------------------------------------
/lecture-03/fn/si.js:
--------------------------------------------------------------------------------
1 | function si(p, r, t){
2 | let out = (p*r*t)/100;;
3 | return out;
4 | }
5 |
6 | console.log(si);
7 |
8 | si(1000, 4, 2);
--------------------------------------------------------------------------------
/lecture-03/patterns/diamond.js:
--------------------------------------------------------------------------------
1 | let n = 5;
2 |
3 | let row = 0;
4 | let row_mirr = 0;
5 | while(row_mirr < 2 * n - 1){
6 |
7 | let col = 0;
8 | while(col <= row){
9 | process.stdout.write("* ");
10 | col += 1;
11 | }
12 | process.stdout.write("\n");
13 |
14 | if(row_mirr < n-1){
15 | row += 1;
16 | } else {
17 | row -= 1;
18 | }
19 |
20 |
21 | row_mirr += 1;
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/lecture-03/patterns/square.js:
--------------------------------------------------------------------------------
1 | let n = 5;
2 |
3 | let row = 0;
4 | let row_mirr = 0;
5 | while(row_mirr < 2 * n - 1){
6 |
7 | let col = 0;
8 | let col_mirr = 0;
9 | while(col_mirr < 2 * n - 1){
10 | if(col < n - row - 1){
11 | process.stdout.write(" ");
12 | } else {
13 | process.stdout.write((col+1) + " ");
14 | }
15 |
16 | if(col_mirr < n-1){
17 | col+=1;
18 | } else {
19 | col -=1;
20 | }
21 |
22 | col_mirr += 1;
23 | }
24 | process.stdout.write("\n");
25 |
26 | if(row_mirr < n-1){
27 | row += 1;
28 | } else {
29 | row -= 1;
30 | }
31 |
32 |
33 | row_mirr += 1;
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/lecture-04/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/lecture-04/askandshow.js:
--------------------------------------------------------------------------------
1 | let readlineSync = require('readline-sync');
2 | let axios = require("axios");
3 | const download = require('image-downloader');
4 |
5 | let username = readlineSync.question('What is your github username? : ');
6 |
7 |
8 | let url = "https://api.github.com/users/" + username;
9 |
10 | axios.get(url).then(
11 | function(response){
12 | console.log(response.data.name);
13 |
14 | const options = {
15 | url: response.data.avatar_url,
16 | dest: './photos/'+username+".jpg" // will be saved to /path/to/dest/image.jpg
17 | }
18 |
19 | download.image(options);
20 |
21 | }
22 | ).catch(
23 | function(error){
24 | console.log(error);
25 | }
26 | )
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/lecture-04/makecall.js:
--------------------------------------------------------------------------------
1 | let axios = require("axios")
2 |
3 | // axios.get("https://api.github.com/users/keenwarrior").then(
4 | // function(response){
5 | // console.log(response.data);
6 | // }
7 | // )
8 |
9 | axios.get("https://api.github.com/users/yyyfffydbfbffhfhfh").then(
10 | function(response){
11 | console.log(response.data);
12 | }
13 | ).catch(
14 | function(error){
15 | console.log(error);
16 | }
17 | )
18 |
19 |
--------------------------------------------------------------------------------
/lecture-04/photos/keenwarrior.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-04/photos/keenwarrior.jpg
--------------------------------------------------------------------------------
/lecture-04/reading.js:
--------------------------------------------------------------------------------
1 | var readlineSync = require('readline-sync');
2 |
3 | var age = readlineSync.question('What is your age? ');
4 |
5 | console.log(typeof(parseInt(age)));
--------------------------------------------------------------------------------
/lecture-05/asyncBehave.js:
--------------------------------------------------------------------------------
1 | setTimeout(function(){
2 | console.log("Do this");
3 | }, 5000);
4 |
5 | console.log("Ye abhi kar lo");
--------------------------------------------------------------------------------
/lecture-05/promiseEg.js:
--------------------------------------------------------------------------------
1 |
2 | function orderSamosa() {
3 |
4 | let promise = new Promise(function(accept, reject){
5 | setTimeout(function(){
6 | accept("Ye lo samose");
7 | }, 3000);
8 |
9 | setTimeout(function(){
10 | reject("Khatam ho gye");
11 | }, 3000);
12 | });
13 |
14 | return promise;
15 | }
16 |
17 | let pr = orderSamosa();
18 |
19 | let handleA = function(first, second){
20 | console.log("Responded", first, second);
21 | }
22 |
23 | let rejectA = function(error){
24 | console.log(error);
25 | }
26 |
27 |
28 | pr.then(handleA).catch(rejectA);
29 |
30 | console.log("Ordered samosa");
31 |
32 |
--------------------------------------------------------------------------------
/lecture-07/wapp/arraw.js:
--------------------------------------------------------------------------------
1 | function fname(params){
2 | console.log("Simple fn")
3 | }
4 |
5 | let f2 = function(params){
6 | console.log("Simple fn")
7 | }
8 |
9 | let f3 = (params) => {
10 |
11 | }
12 |
13 | let f4 = param => {
14 |
15 | }
16 |
17 | let f5 = (param) => console.log("Hi");
18 |
19 |
20 | f5();
--------------------------------------------------------------------------------
/lecture-07/wapp/index.js:
--------------------------------------------------------------------------------
1 | // console.log("Hello");
2 | let axios = require('axios');
3 |
4 | async function sayHi(){
5 | console.log("Ye chalega pahle");
6 | let res = await axios.get("https://api.github.com/users/keenwarrior");
7 | console.log("ye chalega baad me");
8 | return res.data.login; // res.then(function(out){
9 | // console.log(out.data.login);
10 | // })
11 | }
12 |
13 | sayHi().then(out=>console.log(out))
14 |
15 | console.log("Yaayyyyyy")
--------------------------------------------------------------------------------
/lecture-07/wapp/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "wapp",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "axios": {
8 | "version": "0.21.1",
9 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
10 | "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
11 | "requires": {
12 | "follow-redirects": "^1.10.0"
13 | }
14 | },
15 | "follow-redirects": {
16 | "version": "1.13.3",
17 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.3.tgz",
18 | "integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA=="
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/lecture-07/wapp/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "wapp",
3 | "version": "1.0.0",
4 | "description": "A sample APp",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "node index.js",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "author": "",
11 | "license": "Apache-2.0",
12 | "dependencies": {
13 | "axios": "^0.21.1"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/lecture-08/another.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | My main title
7 | My top level heading
8 | My subheading
9 | My sub-subheading
10 |
11 |
12 | - technologists
13 | - thinkers
14 | - builders
15 |
16 |
17 | Mozilla Manifesto
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/lecture-08/hey.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/lecture-08/index.html:
--------------------------------------------------------------------------------
1 | Welcome to
Code for Cause
2 |
3 |
4 |
--------------------------------------------------------------------------------
/lecture-09/another.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 |
11 |
12 |
13 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/lecture-09/external.css:
--------------------------------------------------------------------------------
1 | #firstImage {
2 | width: 1000px;
3 | }
4 | .second {
5 | width: 100px;
6 | height: 100px;
7 | background-color: red;
8 | }
9 | p {
10 | color: black;
11 | }
--------------------------------------------------------------------------------
/lecture-09/interpolation.js:
--------------------------------------------------------------------------------
1 | let name = "Anuj Garg";
2 | let days = 10;
3 | let salutation = `Welcome ${name}. You won package of ${days} days.`;
4 |
5 | console.log(salutation);
6 |
7 |
--------------------------------------------------------------------------------
/lecture-11/hello/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/lecture-11/hello/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-11/hello/public/favicon.ico
--------------------------------------------------------------------------------
/lecture-11/hello/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-11/hello/public/logo192.png
--------------------------------------------------------------------------------
/lecture-11/hello/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-11/hello/public/logo512.png
--------------------------------------------------------------------------------
/lecture-11/hello/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/lecture-11/hello/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/lecture-11/hello/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lecture-11/hello/src/App.js:
--------------------------------------------------------------------------------
1 | import logo from './logo.svg';
2 | import './App.css';
3 |
4 | function App() {
5 | return (
6 |
22 | );
23 | }
24 |
25 | export default App;
26 |
--------------------------------------------------------------------------------
/lecture-11/hello/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/lecture-11/hello/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/lecture-11/hello/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want to start measuring performance in your app, pass a function
15 | // to log results (for example: reportWebVitals(console.log))
16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17 | reportWebVitals();
18 |
--------------------------------------------------------------------------------
/lecture-11/hello/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/lecture-11/hello/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/lecture-11/l11.svgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-11/l11.svgz
--------------------------------------------------------------------------------
/lecture-12/calc/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/lecture-12/calc/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-12/calc/public/favicon.ico
--------------------------------------------------------------------------------
/lecture-12/calc/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-12/calc/public/logo192.png
--------------------------------------------------------------------------------
/lecture-12/calc/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-12/calc/public/logo512.png
--------------------------------------------------------------------------------
/lecture-12/calc/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/lecture-12/calc/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/lecture-12/calc/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | width : 100%;
3 | height : 100vh;
4 | background: #999999;
5 | display: flex;
6 | flex-direction : column;
7 | justify-content: center;
8 | align-items: center;
9 | }
10 |
11 | .App-logo {
12 | height: 40vmin;
13 | pointer-events: none;
14 | }
15 |
16 | @media (prefers-reduced-motion: no-preference) {
17 | .App-logo {
18 | animation: App-logo-spin infinite 20s linear;
19 | }
20 | }
21 |
22 | .App-header {
23 | background-color: #282c34;
24 | min-height: 100vh;
25 | display: flex;
26 | flex-direction: column;
27 | align-items: center;
28 | justify-content: center;
29 | font-size: calc(10px + 2vmin);
30 | color: white;
31 | }
32 |
33 | .App-link {
34 | color: #61dafb;
35 | }
36 |
37 | @keyframes App-logo-spin {
38 | from {
39 | transform: rotate(0deg);
40 | }
41 | to {
42 | transform: rotate(360deg);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/lecture-12/calc/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/lecture-12/calc/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/lecture-12/calc/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 |
6 | ReactDOM.render(
7 |
8 |
9 | ,
10 | document.getElementById('root')
11 | );
12 |
13 |
--------------------------------------------------------------------------------
/lecture-12/calc/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/lecture-12/calc/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/lecture-12/l12.svgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-12/l12.svgz
--------------------------------------------------------------------------------
/lecture-13/calc/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/lecture-13/calc/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-13/calc/public/favicon.ico
--------------------------------------------------------------------------------
/lecture-13/calc/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-13/calc/public/logo192.png
--------------------------------------------------------------------------------
/lecture-13/calc/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-13/calc/public/logo512.png
--------------------------------------------------------------------------------
/lecture-13/calc/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/lecture-13/calc/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/lecture-13/calc/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | width : 100%;
3 | height : 100vh;
4 | background: #999999;
5 | display: flex;
6 | flex-direction : column;
7 | justify-content: center;
8 | align-items: center;
9 | }
10 |
11 | .App-logo {
12 | height: 40vmin;
13 | pointer-events: none;
14 | }
15 |
16 | @media (prefers-reduced-motion: no-preference) {
17 | .App-logo {
18 | animation: App-logo-spin infinite 20s linear;
19 | }
20 | }
21 |
22 | .App-header {
23 | background-color: #282c34;
24 | min-height: 100vh;
25 | display: flex;
26 | flex-direction: column;
27 | align-items: center;
28 | justify-content: center;
29 | font-size: calc(10px + 2vmin);
30 | color: white;
31 | }
32 |
33 | .App-link {
34 | color: #61dafb;
35 | }
36 |
37 | @keyframes App-logo-spin {
38 | from {
39 | transform: rotate(0deg);
40 | }
41 | to {
42 | transform: rotate(360deg);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/lecture-13/calc/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/lecture-13/calc/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/lecture-13/calc/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 |
6 | ReactDOM.render(
7 |
8 |
9 | ,
10 | document.getElementById('root')
11 | );
12 |
13 |
--------------------------------------------------------------------------------
/lecture-13/calc/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/lecture-13/calc/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/lecture-13/l12.svgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-13/l12.svgz
--------------------------------------------------------------------------------
/lecture-14/Doc.svgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-14/Doc.svgz
--------------------------------------------------------------------------------
/lecture-14/tictactoe/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/lecture-14/tictactoe/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-14/tictactoe/public/favicon.ico
--------------------------------------------------------------------------------
/lecture-14/tictactoe/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-14/tictactoe/public/logo192.png
--------------------------------------------------------------------------------
/lecture-14/tictactoe/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-14/tictactoe/public/logo512.png
--------------------------------------------------------------------------------
/lecture-14/tictactoe/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/lecture-14/tictactoe/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/lecture-14/tictactoe/src/App.js:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import TicTacToe from "./TicTacToe";
3 | import { createBoard } from "./utils/boardUtil";
4 |
5 | let BoardContext = React.createContext();
6 |
7 | function App() {
8 | let blank = createBoard();
9 | let [board, setBoard] = useState(blank);
10 |
11 | return (
12 |
13 |
14 |
15 | );
16 | }
17 |
18 | export { App, BoardContext };
19 |
--------------------------------------------------------------------------------
/lecture-14/tictactoe/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/lecture-14/tictactoe/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/lecture-14/tictactoe/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import {App} from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want to start measuring performance in your app, pass a function
15 | // to log results (for example: reportWebVitals(console.log))
16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17 | reportWebVitals();
18 |
--------------------------------------------------------------------------------
/lecture-14/tictactoe/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/lecture-14/tictactoe/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/lecture-14/tictactoe/src/utils/boardUtil.js:
--------------------------------------------------------------------------------
1 | let createBoard = function () {
2 | let board = [
3 | [-1, -1, -1],
4 | [-1, -1, -1],
5 | [-1, -1, -1],
6 | ];
7 |
8 | return board;
9 | };
10 |
11 | export { createBoard };
12 |
--------------------------------------------------------------------------------
/lecture-15/firelogin/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/lecture-15/firelogin/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-15/firelogin/public/favicon.ico
--------------------------------------------------------------------------------
/lecture-15/firelogin/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-15/firelogin/public/logo192.png
--------------------------------------------------------------------------------
/lecture-15/firelogin/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-15/firelogin/public/logo512.png
--------------------------------------------------------------------------------
/lecture-15/firelogin/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/lecture-15/firelogin/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/lecture-15/firelogin/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lecture-15/firelogin/src/App.js:
--------------------------------------------------------------------------------
1 | import "./App.css";
2 | import React, { useEffect, useState } from "react";
3 | import Login from "./Login";
4 | import Home from "./Home";
5 | import {firebase} from './utils/firebase';
6 |
7 | let UserContext = React.createContext();
8 |
9 | function App() {
10 | let [user, setUser] = useState();
11 |
12 | useEffect(function () {
13 | firebase.auth().onAuthStateChanged((user) => {
14 | setUser(user);
15 | });
16 | }, []);
17 |
18 | return (
19 |
20 |
21 |
22 |
23 |
24 |
25 | );
26 | }
27 |
28 | export { App, UserContext };
29 |
--------------------------------------------------------------------------------
/lecture-15/firelogin/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/lecture-15/firelogin/src/Home.js:
--------------------------------------------------------------------------------
1 | import './App.css';
2 | import { useContext } from 'react';
3 | import { UserContext } from './App';
4 |
5 | function Home() {
6 |
7 | let {user} = useContext(UserContext);
8 |
9 | return (
10 |
11 |
12 |
{user ? user.displayName : undefined}
13 |
14 |
15 | );
16 | }
17 |
18 | export default Home;
19 |
--------------------------------------------------------------------------------
/lecture-15/firelogin/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/lecture-15/firelogin/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import {App} from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want to start measuring performance in your app, pass a function
15 | // to log results (for example: reportWebVitals(console.log))
16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17 | reportWebVitals();
18 |
--------------------------------------------------------------------------------
/lecture-15/firelogin/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/lecture-15/firelogin/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/lecture-15/firelogin/src/utils/firebase.js:
--------------------------------------------------------------------------------
1 | import firebase from "firebase";
2 |
3 | const config = {
4 | apiKey: "AIzaSyAK5QvhQaW0LcorV8MLpDESpNncY3QGeLE",
5 | authDomain: "specialbatch-2ca95.firebaseapp.com",
6 | projectId: "specialbatch-2ca95",
7 | storageBucket: "specialbatch-2ca95.appspot.com",
8 | messagingSenderId: "674935291974",
9 | appId: "1:674935291974:web:894d6f7ac2f4f2153cca47",
10 | };
11 |
12 | firebase.initializeApp(config);
13 |
14 | export {firebase}
15 |
--------------------------------------------------------------------------------
/lecture-16/routing/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/lecture-16/routing/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-16/routing/public/favicon.ico
--------------------------------------------------------------------------------
/lecture-16/routing/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-16/routing/public/logo192.png
--------------------------------------------------------------------------------
/lecture-16/routing/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-16/routing/public/logo512.png
--------------------------------------------------------------------------------
/lecture-16/routing/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/lecture-16/routing/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/lecture-16/routing/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lecture-16/routing/src/App.js:
--------------------------------------------------------------------------------
1 | import {MainLayout} from "./layouts/MainLayout";
2 | import {
3 | BrowserRouter as Router} from "react-router-dom";
4 |
5 | function App() {
6 | return (
7 |
8 |
9 |
10 |
11 | );
12 | }
13 |
14 | export default App;
15 |
--------------------------------------------------------------------------------
/lecture-16/routing/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/lecture-16/routing/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/lecture-16/routing/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want to start measuring performance in your app, pass a function
15 | // to log results (for example: reportWebVitals(console.log))
16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17 | reportWebVitals();
18 |
--------------------------------------------------------------------------------
/lecture-16/routing/src/pages/DraftsPage.js:
--------------------------------------------------------------------------------
1 | import { Typography } from "@material-ui/core"
2 |
3 | export default function DraftPage(){
4 | return Draft Page
5 | }
--------------------------------------------------------------------------------
/lecture-16/routing/src/pages/InboxPage.js:
--------------------------------------------------------------------------------
1 | import { Typography } from "@material-ui/core"
2 |
3 | export default function InboxPage(){
4 | return Inbox Page
5 | }
--------------------------------------------------------------------------------
/lecture-16/routing/src/pages/SpamPage.js:
--------------------------------------------------------------------------------
1 | import { Typography } from "@material-ui/core"
2 |
3 | export default function SpamPage(){
4 | return Spam Page
5 | }
--------------------------------------------------------------------------------
/lecture-16/routing/src/pages/TrashPage.js:
--------------------------------------------------------------------------------
1 | import { Typography } from "@material-ui/core"
2 |
3 | export default function TrashPage(){
4 | return Trash Page
5 | }
--------------------------------------------------------------------------------
/lecture-16/routing/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/lecture-16/routing/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/lecture-18/May 3 18h24.svgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-18/May 3 18h24.svgz
--------------------------------------------------------------------------------
/lecture-18/forms/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/lecture-18/forms/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-18/forms/public/favicon.ico
--------------------------------------------------------------------------------
/lecture-18/forms/public/images/bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-18/forms/public/images/bg.jpg
--------------------------------------------------------------------------------
/lecture-18/forms/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-18/forms/public/logo192.png
--------------------------------------------------------------------------------
/lecture-18/forms/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-18/forms/public/logo512.png
--------------------------------------------------------------------------------
/lecture-18/forms/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/lecture-18/forms/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/lecture-18/forms/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lecture-18/forms/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/lecture-18/forms/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/lecture-18/forms/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want to start measuring performance in your app, pass a function
15 | // to log results (for example: reportWebVitals(console.log))
16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17 | reportWebVitals();
18 |
--------------------------------------------------------------------------------
/lecture-18/forms/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/lecture-18/forms/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/lecture-18/server/index.js:
--------------------------------------------------------------------------------
1 | let express = require("express");
2 | let cors = require('cors');
3 |
4 | let app = express();
5 |
6 | app.use(cors());
7 | app.use(express.json());
8 |
9 | let PORT = 5000;
10 |
11 | let handleGet = function (req, res) {
12 | console.log(req.query);
13 | res.send("Wohhooo. Sending from server");
14 | };
15 |
16 | let handlePing = function (req, res) {
17 | console.log(req.query);
18 | res.redirect("https://google.com/");
19 | };
20 |
21 | let handleFormSubmission = function (req, res) {
22 | let data = req.body;
23 | console.log(data);
24 | res.send("Submitted");
25 | };
26 |
27 | app.get("/", handleGet);
28 |
29 | app.get("/ping/", handlePing);
30 |
31 | app.post("/submit/", handleFormSubmission);
32 |
33 | app.listen(PORT, function () {
34 | console.log(`listening to port ${PORT}`);
35 | });
36 |
--------------------------------------------------------------------------------
/lecture-18/server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "server",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "node index.js",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {
13 | "cors": "^2.8.5",
14 | "express": "^4.17.1"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/lecture-19/firelogin/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/lecture-19/firelogin/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-19/firelogin/public/favicon.ico
--------------------------------------------------------------------------------
/lecture-19/firelogin/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-19/firelogin/public/logo192.png
--------------------------------------------------------------------------------
/lecture-19/firelogin/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-19/firelogin/public/logo512.png
--------------------------------------------------------------------------------
/lecture-19/firelogin/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/lecture-19/firelogin/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/lecture-19/firelogin/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lecture-19/firelogin/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/lecture-19/firelogin/src/Home.js:
--------------------------------------------------------------------------------
1 | import './App.css';
2 | import { useContext } from 'react';
3 | import { UserContext } from './App';
4 |
5 | function Home() {
6 |
7 | let {user} = useContext(UserContext);
8 |
9 | return (
10 |
11 |
12 |
{user ? user.displayName : undefined}
13 |
14 |
15 | );
16 | }
17 |
18 | export default Home;
19 |
--------------------------------------------------------------------------------
/lecture-19/firelogin/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/lecture-19/firelogin/src/index.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom";
3 | import "./index.css";
4 | import { App } from "./App";
5 | import reportWebVitals from "./reportWebVitals";
6 | import { BrowserRouter as Router } from "react-router-dom";
7 |
8 | ReactDOM.render(
9 |
10 |
11 |
12 |
13 | ,
14 | document.getElementById("root")
15 | );
16 |
17 | // If you want to start measuring performance in your app, pass a function
18 | // to log results (for example: reportWebVitals(console.log))
19 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
20 | reportWebVitals();
21 |
--------------------------------------------------------------------------------
/lecture-19/firelogin/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/lecture-19/firelogin/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/lecture-19/firelogin/src/utils/axios.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios';
2 |
3 | export default axios;
4 |
--------------------------------------------------------------------------------
/lecture-19/firelogin/src/utils/firebase.js:
--------------------------------------------------------------------------------
1 | import firebase from "firebase";
2 |
3 | const config = {
4 | apiKey: "AIzaSyAK5QvhQaW0LcorV8MLpDESpNncY3QGeLE",
5 | authDomain: "specialbatch-2ca95.firebaseapp.com",
6 | projectId: "specialbatch-2ca95",
7 | storageBucket: "specialbatch-2ca95.appspot.com",
8 | messagingSenderId: "674935291974",
9 | appId: "1:674935291974:web:894d6f7ac2f4f2153cca47",
10 | };
11 |
12 | firebase.initializeApp(config);
13 |
14 | export {firebase}
15 |
--------------------------------------------------------------------------------
/lecture-20/firelogin/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/lecture-20/firelogin/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-20/firelogin/public/favicon.ico
--------------------------------------------------------------------------------
/lecture-20/firelogin/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-20/firelogin/public/logo192.png
--------------------------------------------------------------------------------
/lecture-20/firelogin/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-20/firelogin/public/logo512.png
--------------------------------------------------------------------------------
/lecture-20/firelogin/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/lecture-20/firelogin/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/lecture-20/firelogin/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lecture-20/firelogin/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/lecture-20/firelogin/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/lecture-20/firelogin/src/index.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom";
3 | import "./index.css";
4 | import { App } from "./App";
5 | import reportWebVitals from "./reportWebVitals";
6 | import { BrowserRouter as Router } from "react-router-dom";
7 |
8 | ReactDOM.render(
9 |
10 |
11 |
12 |
13 | ,
14 | document.getElementById("root")
15 | );
16 |
17 | // If you want to start measuring performance in your app, pass a function
18 | // to log results (for example: reportWebVitals(console.log))
19 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
20 | reportWebVitals();
21 |
--------------------------------------------------------------------------------
/lecture-20/firelogin/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/lecture-20/firelogin/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/lecture-20/firelogin/src/utils/axios.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios';
2 |
3 | export default axios;
4 |
--------------------------------------------------------------------------------
/lecture-20/firelogin/src/utils/firebase.js:
--------------------------------------------------------------------------------
1 | import firebase from "firebase";
2 |
3 | const config = {
4 | apiKey: "AIzaSyAK5QvhQaW0LcorV8MLpDESpNncY3QGeLE",
5 | authDomain: "specialbatch-2ca95.firebaseapp.com",
6 | projectId: "specialbatch-2ca95",
7 | storageBucket: "specialbatch-2ca95.appspot.com",
8 | messagingSenderId: "674935291974",
9 | appId: "1:674935291974:web:894d6f7ac2f4f2153cca47",
10 | };
11 |
12 | firebase.initializeApp(config);
13 |
14 | export {firebase}
15 |
--------------------------------------------------------------------------------
/lecture-20/server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "server",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "node index.js",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {
13 | "cors": "^2.8.5",
14 | "express": "^4.17.1",
15 | "express-bearer-token": "^2.4.0",
16 | "firebase-admin": "^9.7.0"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/lecture-20/server/public/another.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 | It is a Another doc
11 |
12 |
13 |
--------------------------------------------------------------------------------
/lecture-20/server/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 | It is a public doc
11 |
12 |
13 |
--------------------------------------------------------------------------------
/lecture-21/firelogin/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/lecture-21/firelogin/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-21/firelogin/public/favicon.ico
--------------------------------------------------------------------------------
/lecture-21/firelogin/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-21/firelogin/public/logo192.png
--------------------------------------------------------------------------------
/lecture-21/firelogin/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-21/firelogin/public/logo512.png
--------------------------------------------------------------------------------
/lecture-21/firelogin/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/lecture-21/firelogin/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/lecture-21/firelogin/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lecture-21/firelogin/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/lecture-21/firelogin/src/Routes.js:
--------------------------------------------------------------------------------
1 |
2 | import { Switch, Route } from "react-router-dom";
3 | import Login from "./Login";
4 | import Home from "./Home";
5 |
6 | export default function Routes() {
7 | return (
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | );
17 | }
18 |
--------------------------------------------------------------------------------
/lecture-21/firelogin/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/lecture-21/firelogin/src/index.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom";
3 | import "./index.css";
4 | import { App } from "./App";
5 | import reportWebVitals from "./reportWebVitals";
6 | import { BrowserRouter as Router } from "react-router-dom";
7 |
8 | ReactDOM.render(
9 |
10 |
11 |
12 |
13 | ,
14 | document.getElementById("root")
15 | );
16 |
17 | // If you want to start measuring performance in your app, pass a function
18 | // to log results (for example: reportWebVitals(console.log))
19 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
20 | reportWebVitals();
21 |
--------------------------------------------------------------------------------
/lecture-21/firelogin/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/lecture-21/firelogin/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/lecture-21/firelogin/src/utils/axios.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios';
2 |
3 | export default axios;
4 |
--------------------------------------------------------------------------------
/lecture-21/firelogin/src/utils/firebase.js:
--------------------------------------------------------------------------------
1 | import firebase from "firebase";
2 |
3 | const config = {
4 | apiKey: "AIzaSyAK5QvhQaW0LcorV8MLpDESpNncY3QGeLE",
5 | authDomain: "specialbatch-2ca95.firebaseapp.com",
6 | projectId: "specialbatch-2ca95",
7 | storageBucket: "specialbatch-2ca95.appspot.com",
8 | messagingSenderId: "674935291974",
9 | appId: "1:674935291974:web:894d6f7ac2f4f2153cca47",
10 | };
11 |
12 | firebase.initializeApp(config);
13 |
14 | export {firebase}
15 |
--------------------------------------------------------------------------------
/lecture-21/server/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/lecture-21/server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "server",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "node index.js",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {
13 | "cors": "^2.8.5",
14 | "express": "^4.17.1",
15 | "express-bearer-token": "^2.4.0",
16 | "firebase-admin": "^9.7.0"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/lecture-21/server/public/another.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 | It is a Another doc
11 |
12 |
13 |
--------------------------------------------------------------------------------
/lecture-21/server/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 | It is a public doc
11 |
12 |
13 |
--------------------------------------------------------------------------------
/lecture-22/May 13 18h06.svgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-22/May 13 18h06.svgz
--------------------------------------------------------------------------------
/lecture-22/ws/client.js:
--------------------------------------------------------------------------------
1 | let { io } = require("socket.io-client");
2 |
3 | const URL = "http://localhost:3000";
4 |
5 | const socket = io(URL, { autoConnect: true });
6 |
7 |
8 | socket.on("connect", function(){
9 | console.log("Got connected to server");
10 | })
11 |
12 | socket.on("disconnect", function(){
13 | console.log("Got disconnected to server");
14 | })
15 |
16 | socket.on("message", function(payload){
17 | console.log(payload);
18 | })
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/lecture-22/ws/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ws",
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 | "socket.io": "^4.1.1",
13 | "socket.io-client": "^4.1.1"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/lecture-22/ws/server.js:
--------------------------------------------------------------------------------
1 | const http = require("http");
2 | const socketio = require("socket.io");
3 |
4 | const httpServer = http.createServer();
5 |
6 | // const io = socketio(httpServer, {
7 | // cors: {
8 | // origin: "http://localhost:8080",
9 | // },
10 | // });
11 |
12 | const io = socketio(httpServer);
13 |
14 | io.on("connection", function (socket) {
15 | console.log("connected to client");
16 |
17 | setInterval(function () {
18 | socket.emit("message", { prop1: "You are so awesome" });
19 | }, 3000);
20 | });
21 |
22 | setInterval(function () {
23 | io.sockets.emit("message", { ellan: "Ham hai yaha ke sahanshaa" });
24 | }, 10000);
25 |
26 | httpServer.listen(3000);
27 |
--------------------------------------------------------------------------------
/lecture-23/May 14 18h07.svgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-23/May 14 18h07.svgz
--------------------------------------------------------------------------------
/lecture-23/firelogin/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/lecture-23/firelogin/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-23/firelogin/public/favicon.ico
--------------------------------------------------------------------------------
/lecture-23/firelogin/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-23/firelogin/public/logo192.png
--------------------------------------------------------------------------------
/lecture-23/firelogin/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-23/firelogin/public/logo512.png
--------------------------------------------------------------------------------
/lecture-23/firelogin/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/lecture-23/firelogin/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/lecture-23/firelogin/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lecture-23/firelogin/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/lecture-23/firelogin/src/Routes.js:
--------------------------------------------------------------------------------
1 | import { Switch, Route } from "react-router-dom";
2 | import Login from "./Login";
3 | import Home from "./Home";
4 | import AuthGaurd from "./components/AuthGaurd";
5 |
6 | export default function Routes() {
7 | return (
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | );
19 | }
20 |
--------------------------------------------------------------------------------
/lecture-23/firelogin/src/components/AuthGaurd.js:
--------------------------------------------------------------------------------
1 | import { useContext } from "react";
2 | import { Redirect } from "react-router";
3 | import { UserContext } from "../App";
4 |
5 | export default function AuthGaurd({ children }) {
6 | let { user } = useContext(UserContext);
7 |
8 | if (user === undefined) {
9 | return Loading
;
10 | } else if (user === null) {
11 | return ;
12 | } else {
13 | return children;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/lecture-23/firelogin/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/lecture-23/firelogin/src/index.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom";
3 | import "./index.css";
4 | import { App } from "./App";
5 | import reportWebVitals from "./reportWebVitals";
6 | import { BrowserRouter as Router } from "react-router-dom";
7 |
8 | ReactDOM.render(
9 |
10 |
11 |
12 |
13 | ,
14 | document.getElementById("root")
15 | );
16 |
17 | // If you want to start measuring performance in your app, pass a function
18 | // to log results (for example: reportWebVitals(console.log))
19 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
20 | reportWebVitals();
21 |
--------------------------------------------------------------------------------
/lecture-23/firelogin/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/lecture-23/firelogin/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/lecture-23/firelogin/src/utils/axios.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios';
2 |
3 | export default axios;
4 |
--------------------------------------------------------------------------------
/lecture-23/firelogin/src/utils/firebase.js:
--------------------------------------------------------------------------------
1 | import firebase from "firebase";
2 |
3 | const config = {
4 | apiKey: "AIzaSyAeNmGrakEnf1pA9iw8-_qGYpL4CoC-tWY",
5 | authDomain: "doubt-35a6a.firebaseapp.com",
6 | projectId: "doubt-35a6a",
7 | storageBucket: "doubt-35a6a.appspot.com",
8 | messagingSenderId: "169246163329",
9 | appId: "1:169246163329:web:3cbc173aa84a7a0a212880",
10 | measurementId: "G-N721KYY7Z9",
11 | };
12 |
13 | firebase.initializeApp(config);
14 |
15 | export { firebase };
16 |
--------------------------------------------------------------------------------
/lecture-23/server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "server",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "node index.js",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {
13 | "cors": "^2.8.5",
14 | "express": "^4.17.1",
15 | "express-bearer-token": "^2.4.0",
16 | "firebase-admin": "^9.7.0",
17 | "socket.io": "^4.1.1"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/lecture-24/May 20 18h09.svgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-24/May 20 18h09.svgz
--------------------------------------------------------------------------------
/lecture-24/expboiler/.dockerignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .git
3 | .gitignore
4 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 2
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/.env.example:
--------------------------------------------------------------------------------
1 | # Port number
2 | PORT=3000
3 |
4 | # URL of the Mongo DB
5 | MONGODB_URL=mongodb://127.0.0.1:27017/node-boilerplate
6 |
7 | # JWT
8 | # JWT secret key
9 | JWT_SECRET=thisisasamplesecret
10 | # Number of minutes after which an access token expires
11 | JWT_ACCESS_EXPIRATION_MINUTES=30
12 | # Number of days after which a refresh token expires
13 | JWT_REFRESH_EXPIRATION_DAYS=30
14 | # Number of minutes after which a reset password token expires
15 | JWT_RESET_PASSWORD_EXPIRATION_MINUTES=10
16 | # Number of minutes after which a verify email token expires
17 | JWT_VERIFY_EMAIL_EXPIRATION_MINUTES=10
18 |
19 | # SMTP configuration options for the email service
20 | # For testing, you can use a fake SMTP service like Ethereal: https://ethereal.email/create
21 | SMTP_HOST=email-server
22 | SMTP_PORT=587
23 | SMTP_USERNAME=email-server-username
24 | SMTP_PASSWORD=email-server-password
25 | EMAIL_FROM=support@yourapp.com
26 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | bin
3 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "node": true,
4 | "jest": true
5 | },
6 | "extends": ["airbnb-base", "plugin:jest/recommended", "plugin:security/recommended", "plugin:prettier/recommended"],
7 | "plugins": ["jest", "security", "prettier"],
8 | "parserOptions": {
9 | "ecmaVersion": 2018
10 | },
11 | "rules": {
12 | "no-console": "error",
13 | "func-names": "off",
14 | "no-underscore-dangle": "off",
15 | "consistent-return": "off",
16 | "jest/expect-expect": "off",
17 | "security/detect-object-injection": "off"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/.gitattributes:
--------------------------------------------------------------------------------
1 | # Convert text file line endings to lf
2 | * text eol=lf
3 | *.js text
4 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/.gitignore:
--------------------------------------------------------------------------------
1 | # Dependencies
2 | node_modules
3 |
4 | # yarn error logs
5 | yarn-error.log
6 |
7 | # Environment varibales
8 | .env*
9 | !.env*.example
10 |
11 | # Code coverage
12 | coverage
13 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/.husky/.gitignore:
--------------------------------------------------------------------------------
1 | _
2 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/.husky/post-checkout:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | yarn install
5 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/.husky/post-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | git status
5 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | yarn lint-staged
5 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/.lintstagedrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "*.js": "eslint"
3 | }
4 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/.prettierignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | coverage
3 |
4 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true,
3 | "printWidth": 125
4 | }
5 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - '12'
4 | services:
5 | - mongodb
6 | cache: yarn
7 | branches:
8 | only:
9 | - master
10 | env:
11 | global:
12 | - PORT=3000
13 | - MONGODB_URL=mongodb://localhost:27017/node-boilerplate
14 | - JWT_SECRET=thisisasamplesecret
15 | - JWT_ACCESS_EXPIRATION_MINUTES=30
16 | - JWT_REFRESH_EXPIRATION_DAYS=30
17 | script:
18 | - yarn lint
19 | - yarn test
20 | after_success: yarn coverage:coveralls
21 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM node:alpine
2 |
3 | RUN mkdir -p /usr/src/node-app && chown -R node:node /usr/src/node-app
4 |
5 | WORKDIR /usr/src/node-app
6 |
7 | COPY package.json yarn.lock ./
8 |
9 | USER node
10 |
11 | RUN yarn install --pure-lockfile
12 |
13 | COPY --chown=node:node . .
14 |
15 | EXPOSE 3000
16 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/docker-compose.dev.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | node-app:
5 | container_name: node-app-dev
6 | command: yarn dev -L
7 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/docker-compose.prod.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | node-app:
5 | container_name: node-app-prod
6 | command: yarn start
7 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/docker-compose.test.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | node-app:
5 | container_name: node-app-test
6 | command: yarn test
7 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | node-app:
5 | build: .
6 | image: node-app
7 | environment:
8 | - MONGODB_URL=mongodb://mongodb:27017/node-boilerplate
9 | ports:
10 | - '3000:3000'
11 | depends_on:
12 | - mongodb
13 | volumes:
14 | - .:/usr/src/node-app
15 | networks:
16 | - node-network
17 |
18 | mongodb:
19 | image: mongo:4.2.1-bionic
20 | ports:
21 | - '27017:27017'
22 | volumes:
23 | - dbdata:/data/db
24 | networks:
25 | - node-network
26 |
27 | volumes:
28 | dbdata:
29 |
30 | networks:
31 | node-network:
32 | driver: bridge
33 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/ecosystem.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [
3 | {
4 | "name": "app",
5 | "script": "src/index.js",
6 | "instances": 1,
7 | "autorestart": true,
8 | "watch": false,
9 | "time": true,
10 | "env": {
11 | "NODE_ENV": "production"
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | testEnvironment: 'node',
3 | testEnvironmentOptions: {
4 | NODE_ENV: 'test',
5 | },
6 | restoreMocks: true,
7 | coveragePathIgnorePatterns: ['node_modules', 'src/config', 'src/app.js', 'tests'],
8 | coverageReporters: ['text', 'lcov', 'clover', 'html'],
9 | };
10 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/config/logger.js:
--------------------------------------------------------------------------------
1 | const winston = require('winston');
2 | const config = require('./config');
3 |
4 | const enumerateErrorFormat = winston.format((info) => {
5 | if (info instanceof Error) {
6 | Object.assign(info, { message: info.stack });
7 | }
8 | return info;
9 | });
10 |
11 | const logger = winston.createLogger({
12 | level: config.env === 'development' ? 'debug' : 'info',
13 | format: winston.format.combine(
14 | enumerateErrorFormat(),
15 | config.env === 'development' ? winston.format.colorize() : winston.format.uncolorize(),
16 | winston.format.splat(),
17 | winston.format.printf(({ level, message }) => `${level}: ${message}`)
18 | ),
19 | transports: [
20 | new winston.transports.Console({
21 | stderrLevels: ['error'],
22 | }),
23 | ],
24 | });
25 |
26 | module.exports = logger;
27 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/config/morgan.js:
--------------------------------------------------------------------------------
1 | const morgan = require('morgan');
2 | const config = require('./config');
3 | const logger = require('./logger');
4 |
5 | morgan.token('message', (req, res) => res.locals.errorMessage || '');
6 |
7 | const getIpFormat = () => (config.env === 'production' ? ':remote-addr - ' : '');
8 | const successResponseFormat = `${getIpFormat()}:method :url :status - :response-time ms`;
9 | const errorResponseFormat = `${getIpFormat()}:method :url :status - :response-time ms - message: :message`;
10 |
11 | const successHandler = morgan(successResponseFormat, {
12 | skip: (req, res) => res.statusCode >= 400,
13 | stream: { write: (message) => logger.info(message.trim()) },
14 | });
15 |
16 | const errorHandler = morgan(errorResponseFormat, {
17 | skip: (req, res) => res.statusCode < 400,
18 | stream: { write: (message) => logger.error(message.trim()) },
19 | });
20 |
21 | module.exports = {
22 | successHandler,
23 | errorHandler,
24 | };
25 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/config/passport.js:
--------------------------------------------------------------------------------
1 | const { Strategy: JwtStrategy, ExtractJwt } = require('passport-jwt');
2 | const config = require('./config');
3 | const { tokenTypes } = require('./tokens');
4 | const { User } = require('../models');
5 |
6 | const jwtOptions = {
7 | secretOrKey: config.jwt.secret,
8 | jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
9 | };
10 |
11 | const jwtVerify = async (payload, done) => {
12 | try {
13 | if (payload.type !== tokenTypes.ACCESS) {
14 | throw new Error('Invalid token type');
15 | }
16 | const user = await User.findById(payload.sub);
17 | if (!user) {
18 | return done(null, false);
19 | }
20 | done(null, user);
21 | } catch (error) {
22 | done(error, false);
23 | }
24 | };
25 |
26 | const jwtStrategy = new JwtStrategy(jwtOptions, jwtVerify);
27 |
28 | module.exports = {
29 | jwtStrategy,
30 | };
31 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/config/roles.js:
--------------------------------------------------------------------------------
1 | const roles = ['user', 'admin'];
2 |
3 | const roleRights = new Map();
4 | roleRights.set(roles[0], []);
5 | roleRights.set(roles[1], ['getUsers', 'manageUsers']);
6 |
7 | module.exports = {
8 | roles,
9 | roleRights,
10 | };
11 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/config/tokens.js:
--------------------------------------------------------------------------------
1 | const tokenTypes = {
2 | ACCESS: 'access',
3 | REFRESH: 'refresh',
4 | RESET_PASSWORD: 'resetPassword',
5 | VERIFY_EMAIL: 'verifyEmail',
6 | };
7 |
8 | module.exports = {
9 | tokenTypes,
10 | };
11 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/controllers/index.js:
--------------------------------------------------------------------------------
1 | module.exports.authController = require('./auth.controller');
2 | module.exports.userController = require('./user.controller');
3 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/docs/swaggerDef.js:
--------------------------------------------------------------------------------
1 | const { version } = require('../../package.json');
2 | const config = require('../config/config');
3 |
4 | const swaggerDef = {
5 | openapi: '3.0.0',
6 | info: {
7 | title: 'node-express-boilerplate API documentation',
8 | version,
9 | license: {
10 | name: 'MIT',
11 | url: 'https://github.com/hagopj13/node-express-boilerplate/blob/master/LICENSE',
12 | },
13 | },
14 | servers: [
15 | {
16 | url: `http://localhost:${config.port}/v1`,
17 | },
18 | ],
19 | };
20 |
21 | module.exports = swaggerDef;
22 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/middlewares/rateLimiter.js:
--------------------------------------------------------------------------------
1 | const rateLimit = require('express-rate-limit');
2 |
3 | const authLimiter = rateLimit({
4 | windowMs: 15 * 60 * 1000,
5 | max: 20,
6 | skipSuccessfulRequests: true,
7 | });
8 |
9 | module.exports = {
10 | authLimiter,
11 | };
12 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/middlewares/validate.js:
--------------------------------------------------------------------------------
1 | const Joi = require('joi');
2 | const httpStatus = require('http-status');
3 | const pick = require('../utils/pick');
4 | const ApiError = require('../utils/ApiError');
5 |
6 | const validate = (schema) => (req, res, next) => {
7 | const validSchema = pick(schema, ['params', 'query', 'body']);
8 | const object = pick(req, Object.keys(validSchema));
9 | const { value, error } = Joi.compile(validSchema)
10 | .prefs({ errors: { label: 'key' } })
11 | .validate(object);
12 |
13 | if (error) {
14 | const errorMessage = error.details.map((details) => details.message).join(', ');
15 | return next(new ApiError(httpStatus.BAD_REQUEST, errorMessage));
16 | }
17 | Object.assign(req, value);
18 | return next();
19 | };
20 |
21 | module.exports = validate;
22 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/models/index.js:
--------------------------------------------------------------------------------
1 | module.exports.Token = require('./token.model');
2 | module.exports.User = require('./user.model');
3 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/models/plugins/index.js:
--------------------------------------------------------------------------------
1 | module.exports.toJSON = require('./toJSON.plugin');
2 | module.exports.paginate = require('./paginate.plugin');
3 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/routes/v1/docs.route.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const swaggerJsdoc = require('swagger-jsdoc');
3 | const swaggerUi = require('swagger-ui-express');
4 | const swaggerDefinition = require('../../docs/swaggerDef');
5 |
6 | const router = express.Router();
7 |
8 | const specs = swaggerJsdoc({
9 | swaggerDefinition,
10 | apis: ['src/docs/*.yml', 'src/routes/v1/*.js'],
11 | });
12 |
13 | router.use('/', swaggerUi.serve);
14 | router.get(
15 | '/',
16 | swaggerUi.setup(specs, {
17 | explorer: true,
18 | })
19 | );
20 |
21 | module.exports = router;
22 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/routes/v1/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const authRoute = require('./auth.route');
3 | const userRoute = require('./user.route');
4 | const docsRoute = require('./docs.route');
5 | const config = require('../../config/config');
6 |
7 | const router = express.Router();
8 |
9 | const defaultRoutes = [
10 | {
11 | path: '/auth',
12 | route: authRoute,
13 | },
14 | {
15 | path: '/users',
16 | route: userRoute,
17 | },
18 | ];
19 |
20 | const devRoutes = [
21 | // routes available only in development mode
22 | {
23 | path: '/docs',
24 | route: docsRoute,
25 | },
26 | ];
27 |
28 | defaultRoutes.forEach((route) => {
29 | router.use(route.path, route.route);
30 | });
31 |
32 | /* istanbul ignore next */
33 | if (config.env === 'development') {
34 | devRoutes.forEach((route) => {
35 | router.use(route.path, route.route);
36 | });
37 | }
38 |
39 | module.exports = router;
40 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/services/index.js:
--------------------------------------------------------------------------------
1 | module.exports.authService = require('./auth.service');
2 | module.exports.emailService = require('./email.service');
3 | module.exports.tokenService = require('./token.service');
4 | module.exports.userService = require('./user.service');
5 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/utils/ApiError.js:
--------------------------------------------------------------------------------
1 | class ApiError extends Error {
2 | constructor(statusCode, message, isOperational = true, stack = '') {
3 | super(message);
4 | this.statusCode = statusCode;
5 | this.isOperational = isOperational;
6 | if (stack) {
7 | this.stack = stack;
8 | } else {
9 | Error.captureStackTrace(this, this.constructor);
10 | }
11 | }
12 | }
13 |
14 | module.exports = ApiError;
15 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/utils/catchAsync.js:
--------------------------------------------------------------------------------
1 | const catchAsync = (fn) => (req, res, next) => {
2 | Promise.resolve(fn(req, res, next)).catch((err) => next(err));
3 | };
4 |
5 | module.exports = catchAsync;
6 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/utils/pick.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Create an object composed of the picked object properties
3 | * @param {Object} object
4 | * @param {string[]} keys
5 | * @returns {Object}
6 | */
7 | const pick = (object, keys) => {
8 | return keys.reduce((obj, key) => {
9 | if (object && Object.prototype.hasOwnProperty.call(object, key)) {
10 | // eslint-disable-next-line no-param-reassign
11 | obj[key] = object[key];
12 | }
13 | return obj;
14 | }, {});
15 | };
16 |
17 | module.exports = pick;
18 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/validations/custom.validation.js:
--------------------------------------------------------------------------------
1 | const objectId = (value, helpers) => {
2 | if (!value.match(/^[0-9a-fA-F]{24}$/)) {
3 | return helpers.message('"{{#label}}" must be a valid mongo id');
4 | }
5 | return value;
6 | };
7 |
8 | const password = (value, helpers) => {
9 | if (value.length < 8) {
10 | return helpers.message('password must be at least 8 characters');
11 | }
12 | if (!value.match(/\d/) || !value.match(/[a-zA-Z]/)) {
13 | return helpers.message('password must contain at least 1 letter and 1 number');
14 | }
15 | return value;
16 | };
17 |
18 | module.exports = {
19 | objectId,
20 | password,
21 | };
22 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/src/validations/index.js:
--------------------------------------------------------------------------------
1 | module.exports.authValidation = require('./auth.validation');
2 | module.exports.userValidation = require('./user.validation');
3 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/tests/fixtures/token.fixture.js:
--------------------------------------------------------------------------------
1 | const moment = require('moment');
2 | const config = require('../../src/config/config');
3 | const { tokenTypes } = require('../../src/config/tokens');
4 | const tokenService = require('../../src/services/token.service');
5 | const { userOne, admin } = require('./user.fixture');
6 |
7 | const accessTokenExpires = moment().add(config.jwt.accessExpirationMinutes, 'minutes');
8 | const userOneAccessToken = tokenService.generateToken(userOne._id, accessTokenExpires, tokenTypes.ACCESS);
9 | const adminAccessToken = tokenService.generateToken(admin._id, accessTokenExpires, tokenTypes.ACCESS);
10 |
11 | module.exports = {
12 | userOneAccessToken,
13 | adminAccessToken,
14 | };
15 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/tests/integration/docs.test.js:
--------------------------------------------------------------------------------
1 | const request = require('supertest');
2 | const httpStatus = require('http-status');
3 | const app = require('../../src/app');
4 | const config = require('../../src/config/config');
5 |
6 | describe('Auth routes', () => {
7 | describe('GET /v1/docs', () => {
8 | test('should return 404 when running in production', async () => {
9 | config.env = 'production';
10 | await request(app).get('/v1/docs').expect(httpStatus.NOT_FOUND);
11 | config.env = process.env.NODE_ENV;
12 | });
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/lecture-24/expboiler/tests/utils/setupTestDB.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose');
2 | const config = require('../../src/config/config');
3 |
4 | const setupTestDB = () => {
5 | beforeAll(async () => {
6 | await mongoose.connect(config.mongoose.url, config.mongoose.options);
7 | });
8 |
9 | beforeEach(async () => {
10 | await Promise.all(Object.values(mongoose.connection.collections).map(async (collection) => collection.deleteMany()));
11 | });
12 |
13 | afterAll(async () => {
14 | await mongoose.disconnect();
15 | });
16 | };
17 |
18 | module.exports = setupTestDB;
19 |
--------------------------------------------------------------------------------
/lecture-24/forms/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/lecture-24/forms/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-24/forms/public/favicon.ico
--------------------------------------------------------------------------------
/lecture-24/forms/public/images/bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-24/forms/public/images/bg.jpg
--------------------------------------------------------------------------------
/lecture-24/forms/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-24/forms/public/logo192.png
--------------------------------------------------------------------------------
/lecture-24/forms/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-24/forms/public/logo512.png
--------------------------------------------------------------------------------
/lecture-24/forms/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/lecture-24/forms/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/lecture-24/forms/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lecture-24/forms/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/lecture-24/forms/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/lecture-24/forms/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want to start measuring performance in your app, pass a function
15 | // to log results (for example: reportWebVitals(console.log))
16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17 | reportWebVitals();
18 |
--------------------------------------------------------------------------------
/lecture-24/forms/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/lecture-24/forms/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/lecture-24/server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "server",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "node index.js",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {
13 | "cors": "^2.8.5",
14 | "express": "^4.17.1",
15 | "mongoose": "^5.12.10"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/lecture-25/May 21 18h20.svgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-25/May 21 18h20.svgz
--------------------------------------------------------------------------------
/lecture-25/firelogin/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/lecture-25/firelogin/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-25/firelogin/public/favicon.ico
--------------------------------------------------------------------------------
/lecture-25/firelogin/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-25/firelogin/public/logo192.png
--------------------------------------------------------------------------------
/lecture-25/firelogin/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-25/firelogin/public/logo512.png
--------------------------------------------------------------------------------
/lecture-25/firelogin/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/lecture-25/firelogin/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/lecture-25/firelogin/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lecture-25/firelogin/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/lecture-25/firelogin/src/Home.js:
--------------------------------------------------------------------------------
1 | import "./App.css";
2 | import { useContext, useEffect, useState } from "react";
3 | import { UserContext } from "./App";
4 | import axios from "./utils/axios";
5 |
6 | function Home() {
7 | let { user } = useContext(UserContext);
8 |
9 | return (
10 |
19 | );
20 | }
21 |
22 | export default Home;
23 |
--------------------------------------------------------------------------------
/lecture-25/firelogin/src/Routes.js:
--------------------------------------------------------------------------------
1 | import { Switch, Route } from "react-router-dom";
2 | import Login from "./Login";
3 | import Home from "./Home";
4 | import AuthGaurd from "./components/AuthGaurd";
5 |
6 | export default function Routes() {
7 | return (
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | );
19 | }
20 |
--------------------------------------------------------------------------------
/lecture-25/firelogin/src/components/AuthGaurd.js:
--------------------------------------------------------------------------------
1 | import { useContext } from "react";
2 | import { Redirect } from "react-router";
3 | import { UserContext } from "../App";
4 |
5 | export default function AuthGaurd({ children }) {
6 | let { user } = useContext(UserContext);
7 |
8 | if (user === undefined) {
9 | return Loading
;
10 | } else if (user === null) {
11 | return ;
12 | } else {
13 | return children;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/lecture-25/firelogin/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/lecture-25/firelogin/src/index.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom";
3 | import "./index.css";
4 | import { App } from "./App";
5 | import reportWebVitals from "./reportWebVitals";
6 | import { BrowserRouter as Router } from "react-router-dom";
7 |
8 | ReactDOM.render(
9 |
10 |
11 |
12 |
13 | ,
14 | document.getElementById("root")
15 | );
16 |
17 | // If you want to start measuring performance in your app, pass a function
18 | // to log results (for example: reportWebVitals(console.log))
19 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
20 | reportWebVitals();
21 |
--------------------------------------------------------------------------------
/lecture-25/firelogin/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/lecture-25/firelogin/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/lecture-25/firelogin/src/utils/axios.js:
--------------------------------------------------------------------------------
1 | import axios from "axios";
2 |
3 | let instance = axios.create();
4 |
5 | export default instance;
6 |
--------------------------------------------------------------------------------
/lecture-25/firelogin/src/utils/firebase.js:
--------------------------------------------------------------------------------
1 | import firebase from "firebase";
2 |
3 | const config = {
4 | apiKey: "AIzaSyAK5QvhQaW0LcorV8MLpDESpNncY3QGeLE",
5 | authDomain: "specialbatch-2ca95.firebaseapp.com",
6 | projectId: "specialbatch-2ca95",
7 | storageBucket: "specialbatch-2ca95.appspot.com",
8 | messagingSenderId: "674935291974",
9 | appId: "1:674935291974:web:894d6f7ac2f4f2153cca47",
10 | };
11 |
12 | firebase.initializeApp(config);
13 |
14 | export { firebase };
15 |
--------------------------------------------------------------------------------
/lecture-25/mozo/.dockerignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .git
3 | .gitignore
4 |
--------------------------------------------------------------------------------
/lecture-25/mozo/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 2
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
--------------------------------------------------------------------------------
/lecture-25/mozo/.env.example:
--------------------------------------------------------------------------------
1 | # Port number
2 | PORT=3000
3 |
4 | # URL of the Mongo DB
5 | MONGODB_URL=mongodb://127.0.0.1:27017/node-boilerplate
6 |
7 | # JWT
8 | # JWT secret key
9 | JWT_SECRET=thisisasamplesecret
10 | # Number of minutes after which an access token expires
11 | JWT_ACCESS_EXPIRATION_MINUTES=30
12 | # Number of days after which a refresh token expires
13 | JWT_REFRESH_EXPIRATION_DAYS=30
14 | # Number of minutes after which a reset password token expires
15 | JWT_RESET_PASSWORD_EXPIRATION_MINUTES=10
16 | # Number of minutes after which a verify email token expires
17 | JWT_VERIFY_EMAIL_EXPIRATION_MINUTES=10
18 |
19 | # SMTP configuration options for the email service
20 | # For testing, you can use a fake SMTP service like Ethereal: https://ethereal.email/create
21 | SMTP_HOST=email-server
22 | SMTP_PORT=587
23 | SMTP_USERNAME=email-server-username
24 | SMTP_PASSWORD=email-server-password
25 | EMAIL_FROM=support@yourapp.com
26 |
--------------------------------------------------------------------------------
/lecture-25/mozo/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | bin
3 |
--------------------------------------------------------------------------------
/lecture-25/mozo/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "node": true,
4 | "jest": true
5 | },
6 | "extends": ["airbnb-base", "plugin:jest/recommended", "plugin:security/recommended", "plugin:prettier/recommended"],
7 | "plugins": ["jest", "security", "prettier"],
8 | "parserOptions": {
9 | "ecmaVersion": 2018
10 | },
11 | "rules": {
12 | "no-console": "error",
13 | "func-names": "off",
14 | "no-underscore-dangle": "off",
15 | "consistent-return": "off",
16 | "jest/expect-expect": "off",
17 | "security/detect-object-injection": "off"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/lecture-25/mozo/.gitattributes:
--------------------------------------------------------------------------------
1 | # Convert text file line endings to lf
2 | * text eol=lf
3 | *.js text
4 |
--------------------------------------------------------------------------------
/lecture-25/mozo/.gitignore:
--------------------------------------------------------------------------------
1 | # Dependencies
2 | node_modules
3 |
4 | # yarn error logs
5 | yarn-error.log
6 |
7 | # Environment varibales
8 | .env*
9 | !.env*.example
10 |
11 | # Code coverage
12 | coverage
13 |
--------------------------------------------------------------------------------
/lecture-25/mozo/.husky/.gitignore:
--------------------------------------------------------------------------------
1 | _
2 |
--------------------------------------------------------------------------------
/lecture-25/mozo/.husky/post-checkout:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | yarn install
5 |
--------------------------------------------------------------------------------
/lecture-25/mozo/.husky/post-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | git status
5 |
--------------------------------------------------------------------------------
/lecture-25/mozo/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | yarn lint-staged
5 |
--------------------------------------------------------------------------------
/lecture-25/mozo/.lintstagedrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "*.js": "eslint"
3 | }
4 |
--------------------------------------------------------------------------------
/lecture-25/mozo/.prettierignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | coverage
3 |
4 |
--------------------------------------------------------------------------------
/lecture-25/mozo/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true,
3 | "printWidth": 125
4 | }
5 |
--------------------------------------------------------------------------------
/lecture-25/mozo/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - '12'
4 | services:
5 | - mongodb
6 | cache: yarn
7 | branches:
8 | only:
9 | - master
10 | env:
11 | global:
12 | - PORT=3000
13 | - MONGODB_URL=mongodb://localhost:27017/node-boilerplate
14 | - JWT_SECRET=thisisasamplesecret
15 | - JWT_ACCESS_EXPIRATION_MINUTES=30
16 | - JWT_REFRESH_EXPIRATION_DAYS=30
17 | script:
18 | - yarn lint
19 | - yarn test
20 | after_success: yarn coverage:coveralls
21 |
--------------------------------------------------------------------------------
/lecture-25/mozo/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM node:alpine
2 |
3 | RUN mkdir -p /usr/src/node-app && chown -R node:node /usr/src/node-app
4 |
5 | WORKDIR /usr/src/node-app
6 |
7 | COPY package.json yarn.lock ./
8 |
9 | USER node
10 |
11 | RUN yarn install --pure-lockfile
12 |
13 | COPY --chown=node:node . .
14 |
15 | EXPOSE 3000
16 |
--------------------------------------------------------------------------------
/lecture-25/mozo/docker-compose.dev.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | node-app:
5 | container_name: node-app-dev
6 | command: yarn dev -L
7 |
--------------------------------------------------------------------------------
/lecture-25/mozo/docker-compose.prod.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | node-app:
5 | container_name: node-app-prod
6 | command: yarn start
7 |
--------------------------------------------------------------------------------
/lecture-25/mozo/docker-compose.test.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | node-app:
5 | container_name: node-app-test
6 | command: yarn test
7 |
--------------------------------------------------------------------------------
/lecture-25/mozo/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | node-app:
5 | build: .
6 | image: node-app
7 | environment:
8 | - MONGODB_URL=mongodb://mongodb:27017/node-boilerplate
9 | ports:
10 | - '3000:3000'
11 | depends_on:
12 | - mongodb
13 | volumes:
14 | - .:/usr/src/node-app
15 | networks:
16 | - node-network
17 |
18 | mongodb:
19 | image: mongo:4.2.1-bionic
20 | ports:
21 | - '27017:27017'
22 | volumes:
23 | - dbdata:/data/db
24 | networks:
25 | - node-network
26 |
27 | volumes:
28 | dbdata:
29 |
30 | networks:
31 | node-network:
32 | driver: bridge
33 |
--------------------------------------------------------------------------------
/lecture-25/mozo/ecosystem.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [
3 | {
4 | "name": "app",
5 | "script": "src/index.js",
6 | "instances": 1,
7 | "autorestart": true,
8 | "watch": false,
9 | "time": true,
10 | "env": {
11 | "NODE_ENV": "production"
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/lecture-25/mozo/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | testEnvironment: 'node',
3 | testEnvironmentOptions: {
4 | NODE_ENV: 'test',
5 | },
6 | restoreMocks: true,
7 | coveragePathIgnorePatterns: ['node_modules', 'src/config', 'src/app.js', 'tests'],
8 | coverageReporters: ['text', 'lcov', 'clover', 'html'],
9 | };
10 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/config/logger.js:
--------------------------------------------------------------------------------
1 | const winston = require('winston');
2 | const config = require('./config');
3 |
4 | const enumerateErrorFormat = winston.format((info) => {
5 | if (info instanceof Error) {
6 | Object.assign(info, { message: info.stack });
7 | }
8 | return info;
9 | });
10 |
11 | const logger = winston.createLogger({
12 | level: config.env === 'development' ? 'debug' : 'info',
13 | format: winston.format.combine(
14 | enumerateErrorFormat(),
15 | config.env === 'development' ? winston.format.colorize() : winston.format.uncolorize(),
16 | winston.format.splat(),
17 | winston.format.printf(({ level, message }) => `${level}: ${message}`)
18 | ),
19 | transports: [
20 | new winston.transports.Console({
21 | stderrLevels: ['error'],
22 | }),
23 | ],
24 | });
25 |
26 | module.exports = logger;
27 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/config/morgan.js:
--------------------------------------------------------------------------------
1 | const morgan = require('morgan');
2 | const config = require('./config');
3 | const logger = require('./logger');
4 |
5 | morgan.token('message', (req, res) => res.locals.errorMessage || '');
6 |
7 | const getIpFormat = () => (config.env === 'production' ? ':remote-addr - ' : '');
8 | const successResponseFormat = `${getIpFormat()}:method :url :status - :response-time ms`;
9 | const errorResponseFormat = `${getIpFormat()}:method :url :status - :response-time ms - message: :message`;
10 |
11 | const successHandler = morgan(successResponseFormat, {
12 | skip: (req, res) => res.statusCode >= 400,
13 | stream: { write: (message) => logger.info(message.trim()) },
14 | });
15 |
16 | const errorHandler = morgan(errorResponseFormat, {
17 | skip: (req, res) => res.statusCode < 400,
18 | stream: { write: (message) => logger.error(message.trim()) },
19 | });
20 |
21 | module.exports = {
22 | successHandler,
23 | errorHandler,
24 | };
25 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/config/passport.js:
--------------------------------------------------------------------------------
1 | const { Strategy: JwtStrategy, ExtractJwt } = require('passport-jwt');
2 | const config = require('./config');
3 | const { tokenTypes } = require('./tokens');
4 | const { User } = require('../models');
5 |
6 | const jwtOptions = {
7 | secretOrKey: config.jwt.secret,
8 | jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
9 | };
10 |
11 | const jwtVerify = async (payload, done) => {
12 | try {
13 | if (payload.type !== tokenTypes.ACCESS) {
14 | throw new Error('Invalid token type');
15 | }
16 | const user = await User.findById(payload.sub);
17 | if (!user) {
18 | return done(null, false);
19 | }
20 | done(null, user);
21 | } catch (error) {
22 | done(error, false);
23 | }
24 | };
25 |
26 | const jwtStrategy = new JwtStrategy(jwtOptions, jwtVerify);
27 |
28 | module.exports = {
29 | jwtStrategy,
30 | };
31 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/config/roles.js:
--------------------------------------------------------------------------------
1 | const roles = ['user', 'admin'];
2 |
3 | const roleRights = new Map();
4 | roleRights.set(roles[0], []);
5 | roleRights.set(roles[1], ['getUsers', 'manageUsers']);
6 |
7 | module.exports = {
8 | roles,
9 | roleRights,
10 | };
11 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/config/tokens.js:
--------------------------------------------------------------------------------
1 | const tokenTypes = {
2 | ACCESS: 'access',
3 | REFRESH: 'refresh',
4 | RESET_PASSWORD: 'resetPassword',
5 | VERIFY_EMAIL: 'verifyEmail',
6 | };
7 |
8 | module.exports = {
9 | tokenTypes,
10 | };
11 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/controllers/index.js:
--------------------------------------------------------------------------------
1 | module.exports.authController = require('./auth.controller');
2 | module.exports.userController = require('./user.controller');
3 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/docs/swaggerDef.js:
--------------------------------------------------------------------------------
1 | const { version } = require('../../package.json');
2 | const config = require('../config/config');
3 |
4 | const swaggerDef = {
5 | openapi: '3.0.0',
6 | info: {
7 | title: 'node-express-boilerplate API documentation',
8 | version,
9 | license: {
10 | name: 'MIT',
11 | url: 'https://github.com/hagopj13/node-express-boilerplate/blob/master/LICENSE',
12 | },
13 | },
14 | servers: [
15 | {
16 | url: `http://localhost:${config.port}/v1`,
17 | },
18 | ],
19 | };
20 |
21 | module.exports = swaggerDef;
22 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/middlewares/auth.js:
--------------------------------------------------------------------------------
1 | const admin = require('../utils/admin');
2 |
3 | const auth =
4 | (...requiredRights) =>
5 | async (req, res, next) => {
6 | if (req.token) {
7 | let user = await admin.auth().verifyIdToken(req.token);
8 | if (user && user.uid) {
9 | req.user = user;
10 | next();
11 | } else {
12 | res.sendStatus(401);
13 | }
14 | } else {
15 | res.sendStatus(401);
16 | }
17 | };
18 |
19 | module.exports = auth;
20 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/middlewares/rateLimiter.js:
--------------------------------------------------------------------------------
1 | const rateLimit = require('express-rate-limit');
2 |
3 | const authLimiter = rateLimit({
4 | windowMs: 15 * 60 * 1000,
5 | max: 20,
6 | skipSuccessfulRequests: true,
7 | });
8 |
9 | module.exports = {
10 | authLimiter,
11 | };
12 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/middlewares/validate.js:
--------------------------------------------------------------------------------
1 | const Joi = require('joi');
2 | const httpStatus = require('http-status');
3 | const pick = require('../utils/pick');
4 | const ApiError = require('../utils/ApiError');
5 |
6 | const validate = (schema) => (req, res, next) => {
7 | const validSchema = pick(schema, ['params', 'query', 'body']);
8 | const object = pick(req, Object.keys(validSchema));
9 | const { value, error } = Joi.compile(validSchema)
10 | .prefs({ errors: { label: 'key' } })
11 | .validate(object);
12 |
13 | if (error) {
14 | const errorMessage = error.details.map((details) => details.message).join(', ');
15 | return next(new ApiError(httpStatus.BAD_REQUEST, errorMessage));
16 | }
17 | Object.assign(req, value);
18 | return next();
19 | };
20 |
21 | module.exports = validate;
22 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/models/index.js:
--------------------------------------------------------------------------------
1 | module.exports.Token = require('./token.model');
2 | module.exports.User = require('./user.model');
3 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/models/plugins/index.js:
--------------------------------------------------------------------------------
1 | module.exports.toJSON = require('./toJSON.plugin');
2 | module.exports.paginate = require('./paginate.plugin');
3 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/routes/v1/docs.route.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const swaggerJsdoc = require('swagger-jsdoc');
3 | const swaggerUi = require('swagger-ui-express');
4 | const swaggerDefinition = require('../../docs/swaggerDef');
5 |
6 | const router = express.Router();
7 |
8 | const specs = swaggerJsdoc({
9 | swaggerDefinition,
10 | apis: ['src/docs/*.yml', 'src/routes/v1/*.js'],
11 | });
12 |
13 | router.use('/', swaggerUi.serve);
14 | router.get(
15 | '/',
16 | swaggerUi.setup(specs, {
17 | explorer: true,
18 | })
19 | );
20 |
21 | module.exports = router;
22 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/routes/v1/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const authRoute = require('./auth.route');
3 | const userRoute = require('./user.route');
4 | const docsRoute = require('./docs.route');
5 | const config = require('../../config/config');
6 |
7 | const router = express.Router();
8 |
9 | const defaultRoutes = [
10 | {
11 | path: '/auth',
12 | route: authRoute,
13 | },
14 | {
15 | path: '/users',
16 | route: userRoute,
17 | },
18 | ];
19 |
20 | const devRoutes = [
21 | // routes available only in development mode
22 | {
23 | path: '/docs',
24 | route: docsRoute,
25 | },
26 | ];
27 |
28 | defaultRoutes.forEach((route) => {
29 | router.use(route.path, route.route);
30 | });
31 |
32 | /* istanbul ignore next */
33 | if (config.env === 'development') {
34 | devRoutes.forEach((route) => {
35 | router.use(route.path, route.route);
36 | });
37 | }
38 |
39 | module.exports = router;
40 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/services/index.js:
--------------------------------------------------------------------------------
1 | module.exports.authService = require('./auth.service');
2 | module.exports.emailService = require('./email.service');
3 | module.exports.tokenService = require('./token.service');
4 | module.exports.userService = require('./user.service');
5 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/utils/ApiError.js:
--------------------------------------------------------------------------------
1 | class ApiError extends Error {
2 | constructor(statusCode, message, isOperational = true, stack = '') {
3 | super(message);
4 | this.statusCode = statusCode;
5 | this.isOperational = isOperational;
6 | if (stack) {
7 | this.stack = stack;
8 | } else {
9 | Error.captureStackTrace(this, this.constructor);
10 | }
11 | }
12 | }
13 |
14 | module.exports = ApiError;
15 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/utils/admin.js:
--------------------------------------------------------------------------------
1 | let admin = require('firebase-admin');
2 | var serviceAccount = require('../private/service.json');
3 |
4 | admin.initializeApp({
5 | credential: admin.credential.cert(serviceAccount),
6 | });
7 |
8 | module.exports = admin;
9 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/utils/catchAsync.js:
--------------------------------------------------------------------------------
1 | const catchAsync = (fn) => (req, res, next) => {
2 | Promise.resolve(fn(req, res, next)).catch((err) => next(err));
3 | };
4 |
5 | module.exports = catchAsync;
6 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/utils/pick.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Create an object composed of the picked object properties
3 | * @param {Object} object
4 | * @param {string[]} keys
5 | * @returns {Object}
6 | */
7 | const pick = (object, keys) => {
8 | return keys.reduce((obj, key) => {
9 | if (object && Object.prototype.hasOwnProperty.call(object, key)) {
10 | // eslint-disable-next-line no-param-reassign
11 | obj[key] = object[key];
12 | }
13 | return obj;
14 | }, {});
15 | };
16 |
17 | module.exports = pick;
18 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/validations/custom.validation.js:
--------------------------------------------------------------------------------
1 | const objectId = (value, helpers) => {
2 | if (!value.match(/^[0-9a-fA-F]{24}$/)) {
3 | return helpers.message('"{{#label}}" must be a valid mongo id');
4 | }
5 | return value;
6 | };
7 |
8 | const password = (value, helpers) => {
9 | if (value.length < 8) {
10 | return helpers.message('password must be at least 8 characters');
11 | }
12 | if (!value.match(/\d/) || !value.match(/[a-zA-Z]/)) {
13 | return helpers.message('password must contain at least 1 letter and 1 number');
14 | }
15 | return value;
16 | };
17 |
18 | module.exports = {
19 | objectId,
20 | password,
21 | };
22 |
--------------------------------------------------------------------------------
/lecture-25/mozo/src/validations/index.js:
--------------------------------------------------------------------------------
1 | module.exports.authValidation = require('./auth.validation');
2 | module.exports.userValidation = require('./user.validation');
3 |
--------------------------------------------------------------------------------
/lecture-25/mozo/tests/fixtures/token.fixture.js:
--------------------------------------------------------------------------------
1 | const moment = require('moment');
2 | const config = require('../../src/config/config');
3 | const { tokenTypes } = require('../../src/config/tokens');
4 | const tokenService = require('../../src/services/token.service');
5 | const { userOne, admin } = require('./user.fixture');
6 |
7 | const accessTokenExpires = moment().add(config.jwt.accessExpirationMinutes, 'minutes');
8 | const userOneAccessToken = tokenService.generateToken(userOne._id, accessTokenExpires, tokenTypes.ACCESS);
9 | const adminAccessToken = tokenService.generateToken(admin._id, accessTokenExpires, tokenTypes.ACCESS);
10 |
11 | module.exports = {
12 | userOneAccessToken,
13 | adminAccessToken,
14 | };
15 |
--------------------------------------------------------------------------------
/lecture-25/mozo/tests/integration/docs.test.js:
--------------------------------------------------------------------------------
1 | const request = require('supertest');
2 | const httpStatus = require('http-status');
3 | const app = require('../../src/app');
4 | const config = require('../../src/config/config');
5 |
6 | describe('Auth routes', () => {
7 | describe('GET /v1/docs', () => {
8 | test('should return 404 when running in production', async () => {
9 | config.env = 'production';
10 | await request(app).get('/v1/docs').expect(httpStatus.NOT_FOUND);
11 | config.env = process.env.NODE_ENV;
12 | });
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/lecture-25/mozo/tests/utils/setupTestDB.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose');
2 | const config = require('../../src/config/config');
3 |
4 | const setupTestDB = () => {
5 | beforeAll(async () => {
6 | await mongoose.connect(config.mongoose.url, config.mongoose.options);
7 | });
8 |
9 | beforeEach(async () => {
10 | await Promise.all(Object.values(mongoose.connection.collections).map(async (collection) => collection.deleteMany()));
11 | });
12 |
13 | afterAll(async () => {
14 | await mongoose.disconnect();
15 | });
16 | };
17 |
18 | module.exports = setupTestDB;
19 |
--------------------------------------------------------------------------------
/lecture-26/May 27 18h04.svgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-26/May 27 18h04.svgz
--------------------------------------------------------------------------------
/lecture-26/reduxeg/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/lecture-26/reduxeg/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-26/reduxeg/public/favicon.ico
--------------------------------------------------------------------------------
/lecture-26/reduxeg/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-26/reduxeg/public/logo192.png
--------------------------------------------------------------------------------
/lecture-26/reduxeg/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-26/reduxeg/public/logo512.png
--------------------------------------------------------------------------------
/lecture-26/reduxeg/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/lecture-26/reduxeg/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/lecture-26/reduxeg/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lecture-26/reduxeg/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/lecture-26/reduxeg/src/actions/countActions.js:
--------------------------------------------------------------------------------
1 | export const INCREASE_ACTION = "@counter/increase";
2 | export const DECREASE_ACTION = "@counter/decrease";
3 | export const SET_ACTION = "@counter/set";
4 |
5 | export function increase() {
6 | return {
7 | type: INCREASE_ACTION,
8 | };
9 | }
10 |
11 | export function decrease() {
12 | return {
13 | type: DECREASE_ACTION,
14 | };
15 | }
16 |
17 | export function set(value) {
18 | return {
19 | type: SET_ACTION,
20 | payload: value,
21 | };
22 | }
23 |
--------------------------------------------------------------------------------
/lecture-26/reduxeg/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/lecture-26/reduxeg/src/index.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom";
3 | import "./index.css";
4 | import App from "./App";
5 | import reportWebVitals from "./reportWebVitals";
6 | import { Provider } from "react-redux";
7 | import { store } from "./store";
8 |
9 | ReactDOM.render(
10 |
11 |
12 |
13 |
14 | ,
15 | document.getElementById("root")
16 | );
17 |
18 | // If you want to start measuring performance in your app, pass a function
19 | // to log results (for example: reportWebVitals(console.log))
20 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
21 | reportWebVitals();
22 |
--------------------------------------------------------------------------------
/lecture-26/reduxeg/src/reducers/countReducer.js:
--------------------------------------------------------------------------------
1 | import {
2 | INCREASE_ACTION,
3 | DECREASE_ACTION,
4 | SET_ACTION,
5 | } from "../actions/countActions";
6 |
7 | const initialState = {
8 | count: 0,
9 | };
10 |
11 | export const countReducer = (state = initialState, action) => {
12 | switch (action.type) {
13 | case INCREASE_ACTION: {
14 | let copy = { ...state };
15 | copy.count += 1;
16 | return copy;
17 | }
18 |
19 | case DECREASE_ACTION: {
20 | let copy = { ...state };
21 | copy.count -= 1;
22 | return copy;
23 | }
24 |
25 | case SET_ACTION: {
26 | const payload = action.payload;
27 | let copy = { ...state };
28 | copy.count = payload;
29 | return copy;
30 | }
31 |
32 | default: {
33 | return state;
34 | }
35 | }
36 | };
37 |
--------------------------------------------------------------------------------
/lecture-26/reduxeg/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/lecture-26/reduxeg/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/lecture-26/reduxeg/src/store/index.js:
--------------------------------------------------------------------------------
1 | import { createStore } from "redux";
2 | import { countReducer } from "../reducers/countReducer";
3 |
4 | export const store = createStore(countReducer);
5 |
--------------------------------------------------------------------------------
/lecture-29/May 31 18h08.svgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-29/May 31 18h08.svgz
--------------------------------------------------------------------------------
/lecture-29/learnts/.gitignore:
--------------------------------------------------------------------------------
1 | dist
--------------------------------------------------------------------------------
/lecture-29/learnts/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "learnts",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "typescript": {
8 | "version": "4.3.2",
9 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.2.tgz",
10 | "integrity": "sha512-zZ4hShnmnoVnAHpVHWpTcxdv7dWP60S2FsydQLV8V5PbS3FifjWFFRiHSWpDJahly88PRyV5teTSLoq4eG7mKw==",
11 | "dev": true
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/lecture-29/learnts/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "learnts",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "tsc && node dist/index.js",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {},
13 | "devDependencies": {
14 | "typescript": "^4.3.2"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/lecture-29/learnts/src/index.ts:
--------------------------------------------------------------------------------
1 | // function printName(id: number | string) {
2 | // console.log(id);
3 | // }
4 |
5 | // printName("Anuj");
6 |
7 | type Point = {
8 | x: number;
9 | y?: number;
10 | };
11 |
12 | let some: Point = {
13 | x : 88,
14 | }
15 |
--------------------------------------------------------------------------------
/lecture-30/dpatterns/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "dpatterns",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "typescript": {
8 | "version": "4.3.2",
9 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.2.tgz",
10 | "integrity": "sha512-zZ4hShnmnoVnAHpVHWpTcxdv7dWP60S2FsydQLV8V5PbS3FifjWFFRiHSWpDJahly88PRyV5teTSLoq4eG7mKw==",
11 | "dev": true
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/lecture-30/dpatterns/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "dpatterns",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "tsc && node dist/factory.js",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "author": "",
11 | "license": "ISC",
12 | "devDependencies": {
13 | "typescript": "^4.3.2"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/lecture-30/dpatterns/src/factory.ts:
--------------------------------------------------------------------------------
1 | class Shape {
2 | getInfo = () => {
3 | console.log("I am of generic shape");
4 | };
5 | }
6 |
7 | class Circle extends Shape {
8 | getInfo = () => {
9 | console.log("I am of circular shape");
10 | };
11 | }
12 |
13 | class Square extends Shape {
14 | getInfo = () => {
15 | console.log("I am of square shape");
16 | };
17 | }
18 |
19 | class ShapeFactory {
20 | static create = (shape?: string): Shape => {
21 | if (shape === "square") {
22 | return new Square();
23 | } else if (shape === "circle") {
24 | return new Circle();
25 | }
26 |
27 | return new Shape();
28 | };
29 | }
30 |
31 | let s1 = ShapeFactory.create();
32 | let s2 = ShapeFactory.create("square");
33 | let s3 = ShapeFactory.create("circle");
34 |
35 | s1.getInfo();
36 | s2.getInfo();
37 | s3.getInfo();
38 |
--------------------------------------------------------------------------------
/lecture-30/dpatterns/src/index.ts:
--------------------------------------------------------------------------------
1 | class Earth {
2 | private people: Array = [];
3 | private static instance: null | Earth = null;
4 |
5 | static getInstance = function () {
6 | if (Earth.instance) {
7 | return Earth.instance;
8 | }
9 |
10 | Earth.instance = new Earth();
11 | return Earth.instance;
12 | };
13 |
14 | addHuman = (human: Human) => {
15 | this.people.push(human);
16 | };
17 |
18 | getPeople = () => {
19 | return this.people;
20 | };
21 | }
22 |
23 | class Human {
24 | name: string;
25 | constructor(name: string) {
26 | this.name = name;
27 | Earth.getInstance().addHuman(this);
28 | }
29 | }
30 |
31 | let anuj = new Human("Anuj Garg");
32 | let vasu = new Human("Vasudev");
33 |
34 | console.log(Earth.getInstance().getPeople());
35 |
--------------------------------------------------------------------------------
/lecture-30/nesteg/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | parser: '@typescript-eslint/parser',
3 | parserOptions: {
4 | project: 'tsconfig.json',
5 | sourceType: 'module',
6 | },
7 | plugins: ['@typescript-eslint/eslint-plugin'],
8 | extends: [
9 | 'plugin:@typescript-eslint/recommended',
10 | 'plugin:prettier/recommended',
11 | ],
12 | root: true,
13 | env: {
14 | node: true,
15 | jest: true,
16 | },
17 | ignorePatterns: ['.eslintrc.js'],
18 | rules: {
19 | '@typescript-eslint/interface-name-prefix': 'off',
20 | '@typescript-eslint/explicit-function-return-type': 'off',
21 | '@typescript-eslint/explicit-module-boundary-types': 'off',
22 | '@typescript-eslint/no-explicit-any': 'off',
23 | },
24 | };
25 |
--------------------------------------------------------------------------------
/lecture-30/nesteg/.gitignore:
--------------------------------------------------------------------------------
1 | # compiled output
2 | /dist
3 | /node_modules
4 |
5 | # Logs
6 | logs
7 | *.log
8 | npm-debug.log*
9 | yarn-debug.log*
10 | yarn-error.log*
11 | lerna-debug.log*
12 |
13 | # OS
14 | .DS_Store
15 |
16 | # Tests
17 | /coverage
18 | /.nyc_output
19 |
20 | # IDEs and editors
21 | /.idea
22 | .project
23 | .classpath
24 | .c9/
25 | *.launch
26 | .settings/
27 | *.sublime-workspace
28 |
29 | # IDE - VSCode
30 | .vscode/*
31 | !.vscode/settings.json
32 | !.vscode/tasks.json
33 | !.vscode/launch.json
34 | !.vscode/extensions.json
--------------------------------------------------------------------------------
/lecture-30/nesteg/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true,
3 | "trailingComma": "all"
4 | }
--------------------------------------------------------------------------------
/lecture-30/nesteg/nest-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "collection": "@nestjs/schematics",
3 | "sourceRoot": "src"
4 | }
5 |
--------------------------------------------------------------------------------
/lecture-30/nesteg/src/app.controller.ts:
--------------------------------------------------------------------------------
1 | import { Controller, Delete, Get, Post, Put } from '@nestjs/common';
2 | import { DoSomething } from './something';
3 |
4 | @Controller()
5 | export class AppController {
6 | constructor(private readonly appService: DoSomething) {}
7 |
8 | @Get('/')
9 | getHello(): string {
10 | return this.appService.hello();
11 | }
12 |
13 | @Delete('/moto')
14 | getmoto(): string {
15 | return 'Hello Moto';
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/lecture-30/nesteg/src/app.module.ts:
--------------------------------------------------------------------------------
1 | import { Module } from '@nestjs/common';
2 | import { AppController } from './app.controller';
3 | import { DoSomething } from './something';
4 |
5 | @Module({
6 | imports: [],
7 | controllers: [AppController],
8 | providers: [DoSomething],
9 | })
10 | export class AppModule {}
11 |
--------------------------------------------------------------------------------
/lecture-30/nesteg/src/main.ts:
--------------------------------------------------------------------------------
1 | import { NestFactory } from '@nestjs/core';
2 | import { AppModule } from './app.module';
3 |
4 | async function bootstrap() {
5 | const app = await NestFactory.create(AppModule);
6 | await app.listen(3000);
7 | }
8 |
9 | bootstrap();
10 |
--------------------------------------------------------------------------------
/lecture-30/nesteg/src/something.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@nestjs/common';
2 |
3 | @Injectable()
4 | export class DoSomething {
5 | hello = () => {
6 | return 'Hu la la';
7 | };
8 | }
9 |
--------------------------------------------------------------------------------
/lecture-30/nesteg/test/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { Test, TestingModule } from '@nestjs/testing';
2 | import { INestApplication } from '@nestjs/common';
3 | import * as request from 'supertest';
4 | import { AppModule } from './../src/app.module';
5 |
6 | describe('AppController (e2e)', () => {
7 | let app: INestApplication;
8 |
9 | beforeEach(async () => {
10 | const moduleFixture: TestingModule = await Test.createTestingModule({
11 | imports: [AppModule],
12 | }).compile();
13 |
14 | app = moduleFixture.createNestApplication();
15 | await app.init();
16 | });
17 |
18 | it('/ (GET)', () => {
19 | return request(app.getHttpServer())
20 | .get('/')
21 | .expect(200)
22 | .expect('Hello World!');
23 | });
24 | });
25 |
--------------------------------------------------------------------------------
/lecture-30/nesteg/test/jest-e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "moduleFileExtensions": ["js", "json", "ts"],
3 | "rootDir": ".",
4 | "testEnvironment": "node",
5 | "testRegex": ".e2e-spec.ts$",
6 | "transform": {
7 | "^.+\\.(t|j)s$": "ts-jest"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lecture-30/nesteg/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
4 | }
5 |
--------------------------------------------------------------------------------
/lecture-30/nesteg/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "declaration": true,
5 | "removeComments": true,
6 | "emitDecoratorMetadata": true,
7 | "experimentalDecorators": true,
8 | "allowSyntheticDefaultImports": true,
9 | "target": "es2017",
10 | "sourceMap": true,
11 | "outDir": "./dist",
12 | "baseUrl": "./",
13 | "incremental": true
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/lecture-31/Jun 7 18h07.svgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-31/Jun 7 18h07.svgz
--------------------------------------------------------------------------------
/lecture-31/relationaleg/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | parser: '@typescript-eslint/parser',
3 | parserOptions: {
4 | project: 'tsconfig.json',
5 | sourceType: 'module',
6 | },
7 | plugins: ['@typescript-eslint/eslint-plugin'],
8 | extends: [
9 | 'plugin:@typescript-eslint/recommended',
10 | 'plugin:prettier/recommended',
11 | ],
12 | root: true,
13 | env: {
14 | node: true,
15 | jest: true,
16 | },
17 | ignorePatterns: ['.eslintrc.js'],
18 | rules: {
19 | '@typescript-eslint/interface-name-prefix': 'off',
20 | '@typescript-eslint/explicit-function-return-type': 'off',
21 | '@typescript-eslint/explicit-module-boundary-types': 'off',
22 | '@typescript-eslint/no-explicit-any': 'off',
23 | },
24 | };
25 |
--------------------------------------------------------------------------------
/lecture-31/relationaleg/.gitignore:
--------------------------------------------------------------------------------
1 | # compiled output
2 | /dist
3 | /node_modules
4 |
5 | # Logs
6 | logs
7 | *.log
8 | npm-debug.log*
9 | yarn-debug.log*
10 | yarn-error.log*
11 | lerna-debug.log*
12 |
13 | # OS
14 | .DS_Store
15 |
16 | # Tests
17 | /coverage
18 | /.nyc_output
19 |
20 | # IDEs and editors
21 | /.idea
22 | .project
23 | .classpath
24 | .c9/
25 | *.launch
26 | .settings/
27 | *.sublime-workspace
28 |
29 | # IDE - VSCode
30 | .vscode/*
31 | !.vscode/settings.json
32 | !.vscode/tasks.json
33 | !.vscode/launch.json
34 | !.vscode/extensions.json
--------------------------------------------------------------------------------
/lecture-31/relationaleg/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true,
3 | "trailingComma": "all"
4 | }
--------------------------------------------------------------------------------
/lecture-31/relationaleg/nest-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "collection": "@nestjs/schematics",
3 | "sourceRoot": "src"
4 | }
5 |
--------------------------------------------------------------------------------
/lecture-31/relationaleg/src/app.controller.spec.ts:
--------------------------------------------------------------------------------
1 | import { Test, TestingModule } from '@nestjs/testing';
2 | import { AppController } from './app.controller';
3 | import { AppService } from './app.service';
4 |
5 | describe('AppController', () => {
6 | let appController: AppController;
7 |
8 | beforeEach(async () => {
9 | const app: TestingModule = await Test.createTestingModule({
10 | controllers: [AppController],
11 | providers: [AppService],
12 | }).compile();
13 |
14 | appController = app.get(AppController);
15 | });
16 |
17 | describe('root', () => {
18 | it('should return "Hello World!"', () => {
19 | expect(appController.getHello()).toBe('Hello World!');
20 | });
21 | });
22 | });
23 |
--------------------------------------------------------------------------------
/lecture-31/relationaleg/src/app.controller.ts:
--------------------------------------------------------------------------------
1 | import { Controller, Get } from '@nestjs/common';
2 | import { AppService } from './app.service';
3 |
4 | @Controller()
5 | export class AppController {
6 | constructor(private readonly appService: AppService) {}
7 |
8 | @Get()
9 | getHello(): string {
10 | return this.appService.getHello();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/lecture-31/relationaleg/src/app.module.ts:
--------------------------------------------------------------------------------
1 | import { Module } from '@nestjs/common';
2 | import { TypeOrmModule } from '@nestjs/typeorm';
3 | import { AppController } from './app.controller';
4 | import { AppService } from './app.service';
5 | import { User } from './users/entities/user.entity';
6 | import { UsersModule } from './users/users.module';
7 |
8 | @Module({
9 | imports: [
10 | TypeOrmModule.forRoot({
11 | type: 'mysql',
12 | host: 'localhost',
13 | port: 3306,
14 | username: 'mernmarch',
15 | password: 'MERN_march21',
16 | database: 'nestsample',
17 | entities: [User],
18 | synchronize: true,
19 | }),
20 | UsersModule,
21 | ],
22 | controllers: [AppController],
23 | providers: [AppService],
24 | })
25 | export class AppModule {}
26 |
--------------------------------------------------------------------------------
/lecture-31/relationaleg/src/app.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@nestjs/common';
2 |
3 | @Injectable()
4 | export class AppService {
5 | getHello(): string {
6 | return 'Hello World!';
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/lecture-31/relationaleg/src/main.ts:
--------------------------------------------------------------------------------
1 | import { NestFactory } from '@nestjs/core';
2 | import { AppModule } from './app.module';
3 |
4 | async function bootstrap() {
5 | const app = await NestFactory.create(AppModule);
6 | await app.listen(3000);
7 | }
8 | bootstrap();
9 |
--------------------------------------------------------------------------------
/lecture-31/relationaleg/src/users/dto/create-user.dto.ts:
--------------------------------------------------------------------------------
1 | export class CreateUserDto {}
2 |
--------------------------------------------------------------------------------
/lecture-31/relationaleg/src/users/dto/update-user.dto.ts:
--------------------------------------------------------------------------------
1 | import { PartialType } from '@nestjs/mapped-types';
2 | import { CreateUserDto } from './create-user.dto';
3 |
4 | export class UpdateUserDto extends PartialType(CreateUserDto) {}
5 |
--------------------------------------------------------------------------------
/lecture-31/relationaleg/src/users/entities/user.entity.ts:
--------------------------------------------------------------------------------
1 | import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';
2 |
3 | @Entity()
4 | export class User {
5 | @PrimaryGeneratedColumn()
6 | id: number;
7 |
8 | @Column()
9 | firstName: string;
10 |
11 | @Column()
12 | lastName: string;
13 |
14 | @Column({ default: true })
15 | isActive: boolean;
16 | }
17 |
--------------------------------------------------------------------------------
/lecture-31/relationaleg/src/users/users.module.ts:
--------------------------------------------------------------------------------
1 | import { Module } from '@nestjs/common';
2 | import { UsersService } from './users.service';
3 | import { UsersController } from './users.controller';
4 | import { TypeOrmModule } from '@nestjs/typeorm';
5 | import { User } from './entities/user.entity';
6 |
7 | @Module({
8 | imports: [TypeOrmModule.forFeature([User])],
9 | controllers: [UsersController],
10 | providers: [UsersService],
11 | })
12 | export class UsersModule {}
13 |
--------------------------------------------------------------------------------
/lecture-31/relationaleg/src/users/users.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@nestjs/common';
2 | import { CreateUserDto } from './dto/create-user.dto';
3 | import { UpdateUserDto } from './dto/update-user.dto';
4 | import { InjectRepository } from '@nestjs/typeorm';
5 | import { User } from './entities/user.entity';
6 | import { Repository } from 'typeorm';
7 |
8 | @Injectable()
9 | export class UsersService {
10 | constructor(
11 | @InjectRepository(User)
12 | private usersRepository: Repository,
13 | ) {}
14 |
15 | create(user: User) {
16 | return this.usersRepository.save(user);
17 | }
18 |
19 | findAll() {
20 | return this.usersRepository.find();
21 | }
22 |
23 | findOne(id: number) {
24 | return this.usersRepository.findOne(id);
25 | }
26 |
27 | update(id: number, user: User) {
28 | return this.usersRepository.update(id, user);
29 | }
30 |
31 | remove(id: number) {
32 | return this.usersRepository.delete(id);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/lecture-31/relationaleg/test/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { Test, TestingModule } from '@nestjs/testing';
2 | import { INestApplication } from '@nestjs/common';
3 | import * as request from 'supertest';
4 | import { AppModule } from './../src/app.module';
5 |
6 | describe('AppController (e2e)', () => {
7 | let app: INestApplication;
8 |
9 | beforeEach(async () => {
10 | const moduleFixture: TestingModule = await Test.createTestingModule({
11 | imports: [AppModule],
12 | }).compile();
13 |
14 | app = moduleFixture.createNestApplication();
15 | await app.init();
16 | });
17 |
18 | it('/ (GET)', () => {
19 | return request(app.getHttpServer())
20 | .get('/')
21 | .expect(200)
22 | .expect('Hello World!');
23 | });
24 | });
25 |
--------------------------------------------------------------------------------
/lecture-31/relationaleg/test/jest-e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "moduleFileExtensions": ["js", "json", "ts"],
3 | "rootDir": ".",
4 | "testEnvironment": "node",
5 | "testRegex": ".e2e-spec.ts$",
6 | "transform": {
7 | "^.+\\.(t|j)s$": "ts-jest"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lecture-31/relationaleg/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
4 | }
5 |
--------------------------------------------------------------------------------
/lecture-31/relationaleg/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "declaration": true,
5 | "removeComments": true,
6 | "emitDecoratorMetadata": true,
7 | "experimentalDecorators": true,
8 | "allowSyntheticDefaultImports": true,
9 | "target": "es2017",
10 | "sourceMap": true,
11 | "outDir": "./dist",
12 | "baseUrl": "./",
13 | "incremental": true
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/lecture-32/Jun 10 18h05.svgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-32/Jun 10 18h05.svgz
--------------------------------------------------------------------------------
/lecture-32/animationsreact/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/lecture-32/animationsreact/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-32/animationsreact/public/favicon.ico
--------------------------------------------------------------------------------
/lecture-32/animationsreact/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-32/animationsreact/public/logo192.png
--------------------------------------------------------------------------------
/lecture-32/animationsreact/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeforcauseorg-archive/MERN-Live-Special-0321/7b8166e0a029276777e0b55f3631e521bafd41ad/lecture-32/animationsreact/public/logo512.png
--------------------------------------------------------------------------------
/lecture-32/animationsreact/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/lecture-32/animationsreact/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/lecture-32/animationsreact/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | .App-header {
11 | background-color: #282c34;
12 | min-height: 100vh;
13 | display: flex;
14 | flex-direction: column;
15 | align-items: center;
16 | justify-content: center;
17 | font-size: calc(10px + 2vmin);
18 | color: white;
19 | }
20 |
21 | .App-link {
22 | color: #61dafb;
23 | }
24 |
--------------------------------------------------------------------------------
/lecture-32/animationsreact/src/App.js:
--------------------------------------------------------------------------------
1 | import logo from "./logo.svg";
2 | import "./App.css";
3 | import { useTrail, animated } from "react-spring";
4 |
5 | function App() {
6 | const [springs, api] = useTrail(4, () => ({
7 | from: { opacity: 0 },
8 | to: { opacity: 1 },
9 | loop: { reverse: true },
10 | }));
11 |
12 | return (
13 |
14 | {springs.map(function (spring) {
15 | return (
16 |
23 | );
24 | })}
25 |
26 | );
27 | }
28 |
29 | export default App;
30 |
--------------------------------------------------------------------------------
/lecture-32/animationsreact/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/lecture-32/animationsreact/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/lecture-32/animationsreact/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want to start measuring performance in your app, pass a function
15 | // to log results (for example: reportWebVitals(console.log))
16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17 | reportWebVitals();
18 |
--------------------------------------------------------------------------------
/lecture-32/animationsreact/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/lecture-32/animationsreact/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "requires": true,
3 | "lockfileVersion": 1,
4 | "dependencies": {
5 | "axios": {
6 | "version": "0.21.1",
7 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
8 | "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
9 | "requires": {
10 | "follow-redirects": "^1.10.0"
11 | }
12 | },
13 | "follow-redirects": {
14 | "version": "1.13.3",
15 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.3.tgz",
16 | "integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA=="
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------