/amazono

Practice of Udemy - Complete Modern Amazon clone: Angular 5 and Node.js

Primary LanguageTypeScript

Amazono

Practice of Udemy - Complete Modern Amazon clone: Angular 5 and Node.js

TODO:

  1. Use Assert, Expect, Should to write test codes https://cythilya.github.io/2017/09/17/unit-test-with-mocha-chai-and-sinon/

BUG:

  1. 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.

  2. echo './server/node_modules' > .gitignore seems 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 test

Questions:

  1. Can I do npm and yarn in the same project?

DONE:

  1. Add RestApi

ARCHIVE:

  1. Install all Angular in uni

  2. Edit app.component, home.component

  3. VSCode: install Formatting toggle for prettier

  4. Add Travis CI => Failed

  5. npm install -g prettier
    # install globally
    # then it can use prettier commands
    prettier --single-quote --write "server/*.js"
    yarn add lint-staged husky --dev
  6. Add husky in config for prettier before precommit

      "scripts": {
        "precommit": "lint-staged",
      },
      "lint-staged": {
        "*.js": [
          "prettier --write",
          "git add"
        ]
      },

    Ref: https://kaddopur.github.io/blog/2017/05/10/prettier/

  7. Mocha and Chai for unit test

    npm install mocha -g      	# mocha execution should install globally
    npm install mocha --save-dev
    npm install should --save-dev

    Ref: https://buddy.works/guides/how-automate-nodejs-unit-tests-with-mocha-chai

  8. Don't push node_modules into git

    cd ..
    echo './server/node_modules' > .gitignore
  9. GET a json response

  10. 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

  11. Install cors: communicate between front-end and back-end because they are in different domains and ports.

  12. Build a Node.js server

  13. Install Prettier & ESLint

    1. Prettier do: Formatting rules: eg: max-len, no-mixed-spaces-and-tabs, keyword-spacing, comma-style...
    2. Linter do: Code-quality rules: eg no-unused-vars, no-extra-bind, no-implicit-globals, prefer-promise-reject-errors...
  14. 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-dev

Answered:

  1. 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