This branch is live at http://miltonbecker.com:8001
npm install
npm run dev
- Access http://localhost:8000
npm install
npm run build
- Make sure you have a Postgres instance up and running
- Edit the file
postgres.js
with your db info (or set the env variables accordingly) npm start
- Access http://localhost:8000
npm install
- Make sure you have Docker installed
npm run docker
- You should now have 2 docker images: milton/comment-app and milton/comment-db
- To run the db:
- Without keeping the db changes:
docker run -d -p 5444:5432 milton/comment-db
- Keeping the db changes:
docker run -d -p 5444:5432 -v YourLocalPathToAnEmptyDirHere:/var/lib/postgresql/data milton/comment-db
- To run the app:
docker run -d -p 8000:8000 --env-file docker.env milton/comment-app
- Access http://localhost:8000
-
You can create and delete comments
-
Adding a comment follows an optimistic approach, that is:
- The comment gets added instantaneously
- Its id is temporary while the API is processing
- Once the API is done and responds, the comment gets its real id (the id generated by the database)
- The user will only be able to delete it once it gets its real id
- If there is an error on the server side, the user is notified and that comment gets removed
-
Deleting a comment also follows an optimistic approach:
- The comment gets deleted instantaneously
- If there is an error on the server side, the user is notified and the comments are re-fetched from the server
-
npm scripts:
npm start
starts the server in production mode without the webpack hooksnpm run dev
starts the server with the webpack hooksnpm run build
generates the production bundlenpm run docker
generates the production bundle and creates the docker images