Intro to Node.js Express and insomnia: https://www.youtube.com/watch?v=-MTSQjw5DrM
- Install GCloud CLI: https://cloud.google.com/sdk/docs/install
- Set default auth
gcloud auth application-default login
- Set default auth
- Install nvm (Node Version Manager) guide for ubuntu: https://monovm.com/blog/install-nvm-on-ubuntu/
- Install Node.js on your machine version 20.18.0 (LTS) https://nodejs.org/en/download/package-manager
- Download insomnia for hitting endpoints manually
- (first time)
npm install - Start local server
- Linux:
NODE_ENV=dev nodemon . - Windows:
$env:NODE_ENV="dev"; nodemon . - if nodemon does not work use
sudo npm install -g --force nodemon
- Linux:
- Stop local server with
Ctrl+C - Force stop local server:
sudo kill -9 $(lsof -ti :8080)
NODE_ENV=test npm test -- --maxWorkers=1 --timeout=10000- can only have 1 worker as accessing db and cannot do asynchronous changes
- poor connection or machine in power saving mode can timeout tests and fail to fix:
- provide a better environment for tests to run in
- or increase test timeout parameters in command and in code
- Running in "dev"
- uses development database
- if you want your own database change
MONGO_DB=ChatEz-Developmentin .env.dev to a name of your choice
- Running in "test"
- uses test database (for destructive testing)
- disables auth and lastActive middleware, needed when doing npm test
-
getUser
-
setLanguage
-
setDisplayName
-
setProfilePhoto
-
addFriend
-
removeFriend
-
friendList
-
sendMessage
-
getMessages
-
getMessagesForSideBar
-
getUserMessages
-
setMessagesReadImplicitly
-
deleteConversation
-
deleteAllConversations
-
deleteUser
-
implicit last active based on any requests as auth user
-
implicit user creation on first auth user req
-
custom middleware for implicit requesting user from auth code
-
custom req logger middleware
-
custom auth enforcement middleware
-
implicit gcloud user from gcloud CLI
-
load secrets from google secret manager