Skip to content

LexusCreations/LexusChat-2 | ChatApp - [node, socket.io, mongodb, express]

Notifications You must be signed in to change notification settings

lexuscreations/lexuschat-2-backend

Repository files navigation

1). this readme is a bit old 2). for any .env related issue - just ping me directly

Install Node Version Manager (NVM) | .nvmrc

First uninstall your current node.exe and then 👇

https://github.com/coreybutler/nvm-windows/releases -> download:nvm-setup.zip

nvm --version

nvm install latest | for latest version nvm install | for specfic version | example: nvm install 14.9.0 nvm use 14.9.0 | after installing run this command for use that version

node --version npm --version

nvm list | for check avaliable installed version

|---|------|------|------|------|------|------|------|------|------|------|------|------|---|

use yarn instead of npm | yarn.lock

For exicute a perticular script

npm run start | yarn start

for_npm -D or --save-dev : Package will appear in your devDependencies. i or install : For download package. -g or --global : For installing globally.

for_yarn --dev or -D : For install as devDependencie. add : For download. global : For installing globally.

npm i -g yarn | npm install yarn --global

|---|------|------|------|------|------|------|------|------|------|------|------|------|---|

nodemon - for development only | nodemon.json

npm i -g nodemon | npm install nodemon --save-dev yarn global add nodemon | yarn add --dev nodemon | yarn add --D nodemon

|---|------|------|------|------|------|------|------|------|------|------|------|------|---|

download-install_setup-configure_eslint for linting | .eslintrc.json + .eslintignore

1). install eslint

npm install eslint --save-dev

2). make settings.json file inside .vscode folder in root directory (create/make folder/file.json if not exsist) and paste this (if not already)

{

"editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
},
"eslint.validate": ["javascript"],
"editor.formatOnSave": true,
"editor.tabSize": 4,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"prettier.tabWidth": 4,
"prettier.useTabs": true

}

3). Disable your all pre-installed formatters vscode extensions

4). and then add these vscode extensions

eslint : https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint prettier : https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode

-> optional

cobalt2 : https://marketplace.visualstudio.com/items?itemName=wesbos.theme-cobalt2 tabnine : https://marketplace.visualstudio.com/items?itemName=TabNine.tabnine-vscode vscode-icons : https://marketplace.visualstudio.com/items?itemName=vscode-icons-team.vscode-icons

5). initialize eslint in projectDirectoy (if not already)

./node_modules/.bin/eslint --init | npx eslint --init

-> select appropriate options which will ask after execute this 👆 command or if u want - you can replace .eslint.json file contect with this json 👇

{"env":{"node":true,"commonjs":true,"es2021":true},"extends":["airbnb-base"],"parserOptions":{"ecmaVersion":"latest","sourceType":"script"},"rules":{"one-var":["warn","never"],"strict":["warn","never"],"import/no-dynamic-require":"warn","object-curly-newline":["warn","always"],"max-len":["warn",{"code":120}],"global-require":"warn","function-paren-newline":"warn","import/extensions":"off","arrow-parens":["warn","always"],"operator-linebreak":"warn","consistent-return":"warn","no-nested-ternary":"warn","no-console":"off","space-before-function-paren":"warn","indent":["off",2,{"SwitchCase":1}],"quotes":["warn","double"],"no-unused-vars":["warn",{"vars":"all","args":"after-used","ignoreRestSiblings":false}],"eol-last":["warn","always"],"linebreak-style":["off","windows"],"comma-dangle":["warn","never"]}}

-> and create one more file named .eslintignore and paste 👇 (if not already)

/.vscode node_modules/ dist coverage .env .eslintrc.json .gitignore .nvmrc nodemon.json package.json package-lock.json README.md yarn.lock

|---|------|------|------|------|------|------|------|------|------|------|------|------|---|

download-install_setup-configure_prettier for code formatter | .prettierrc

npm i --save-dev prettier | yarn add -D prettier

-> and create .prettierrc file (if not already) and paste this 👇 content

{

"tabWidth": 2,
"printWidth": 120,
"singleQuote": false,
"trailingComma": "none",
"arrowParens": "always",
"semi": true

}

|---|------|------|------|------|------|------|------|------|------|------|------|------|---|

download-install_setup-configure_pm2 for server alive | pm2-ecosystem.json

npm i -g pm2 .then-> yarn add pm2 | npm i pm2

-> create pm2-ecosystem.json file then open and paste this 👇 configuration json inside the file

{"apps":[{"name":"arthmate","script":"src/index.js","args":"","instances":1,"exec_mode":"cluster","watch":false,"increment_var":"PORT","error_file":"logs/msr_err.log","out_file":"logs/msr.log","pid_file":"pids/msr.pid","no-autorestart":true,"log_date_format":"YYYY-MM-DD HH:mm Z","max_memory_restart":"8G","env":{"PORT":3000,"NODE_ENV":"development"},"env_production":{"NODE_ENV":"production","PORT":3000},"env_test":{"NODE_ENV":"test","PORT":3000}}]}

-> some_commands-instructions

pm2 start pm2-ecosystem.json --env development pm2 kill : kill all running process pm2 ls | pm2 list : list of all running process pm2 delete | example : pm2 delete admission_apis_uac pm2 start pm2 stop

|---|------|------|------|------|------|------|------|------|------|------|------|------|---|

.vscode

vscode extensions required - Better Comments + eslint

|---|------|------|------|------|------|------|------|------|------|------|------|------|---|

.env | .env.example

-> .env : contains variables/values that we want/need in our whole project environment -> .env.example is replica of .env but without values

|---|------|------|------|------|------|------|------|------|------|------|------|------|---| code --list-extensions > .vscode/extensions.list

Releases

No releases published

Packages

No packages published