Practice of Udemy - Complete Modern Amazon clone: Angular 5 and Node.js
TODO:
- Use Assert, Expect, Should to write test codes https://cythilya.github.io/2017/09/17/unit-test-with-mocha-chai-and-sinon/
BUG:
-
problem
npm ERR! network request to https://registry.npmjs.org/watchpack/-/watchpack-1.5.0.tgz failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443 npm ERR! network This is a problem related to network connectivity. npm ERR! network In most cases you are behind a proxy or have bad network settings.
-
echo './server/node_modules' > .gitignoreseems doesn't work -
# include node_modules/@jaredhanson/make-node/main.mk
#
# My Fancy Node.js project
#
# PROJECT = "Amazono"
# test: ;@echo "Testing ${PROJECT}....."; \
# export NODE_PATH=.; \
# ./server/node_modules/.bin/mocha;
# app_bundle := server/server.js
# test: ;@cd ./server && npm testQuestions:
-
Can I do npm and yarn in the same project?
DONE:
- Add RestApi
ARCHIVE:
-
Install all Angular in uni
-
Edit app.component, home.component
-
VSCode: install Formatting toggle for prettier
-
Add Travis CI => Failed
-
npm install -g prettier # install globally # then it can use prettier commands prettier --single-quote --write "server/*.js" yarn add lint-staged husky --dev
-
Add husky in config for prettier before precommit
"scripts": { "precommit": "lint-staged", }, "lint-staged": { "*.js": [ "prettier --write", "git add" ] },
-
Mocha and Chai for unit test
npm install mocha -g # mocha execution should install globally npm install mocha --save-dev npm install should --save-devRef: https://buddy.works/guides/how-automate-nodejs-unit-tests-with-mocha-chai
-
Don't push node_modules into git
cd .. echo './server/node_modules' > .gitignore
-
GET a json response
-
Setting up mlab https://mlab.com/ da…2 -> AWS -> sandbox -> US East (Virginia, us-east-1) DBName: amazono-app Collection: davis Database Users: davislf2, pw: db123
-
Install cors: communicate between front-end and back-end because they are in different domains and ports.
-
Build a Node.js server
-
Install Prettier & ESLint
- Prettier do: Formatting rules: eg: max-len, no-mixed-spaces-and-tabs, keyword-spacing, comma-style...
- Linter do: Code-quality rules: eg no-unused-vars, no-extra-bind, no-implicit-globals, prefer-promise-reject-errors...
-
Install Mocha, Chai, Sinon for unit test
npm install --save-dev --save-exact prettier
# Also install on VSCode
npm install eslint-config-airbnb-base eslint-plugin-import eslint --save-dev
npm install mocha chai sinon --save-devAnswered:
- How to debug if it doesnt' connect to MongoDB? => use command directly connect
VSCode Prettier
Using Command Palette (CMD/CTRL + Shift + P)
1. CMD + Shift + P -> Format Document
OR
1. Select the text you want to Prettify
2. CMD + Shift + P -> Format Selection