node-mongo-demo

node.js and mongodb demo

git clone https://9o.is/git/node-mongo-demo.git

commit 8109abd1e649a589b208c6e45cab5a97d2c97876
parent 6023d594a8f5b5afa2469b844237b42c37a23b83
Author: Jul <jul@9o.is>
Date:   Tue, 28 Jan 2025 06:00:55 -0500

add instructions in readme file

Diffstat:
Mbackend/package.json | 5+++--
Mreadme.md | 27++++++++++++++++++++-------
2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/backend/package.json b/backend/package.json @@ -6,8 +6,9 @@ "type": "module", "scripts": { "start": "node index.js", - "repl": "node", - "test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest" + "db": "node scripts/mongodb-development.js", + "test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest", + "repl": "node" }, "author": "Pidwin LLC", "license": "ISC", diff --git a/readme.md b/readme.md @@ -2,6 +2,11 @@ The Pidwin Fullstack Assessment. +## Backend Architecture + +See the architecture document for details on design decisions for +the backend lucky7 code. + ## Project setup Enter each folder: @@ -16,17 +21,25 @@ npm install ``` --- - ## Backend -Create a **.env file** and populate the fields. +To run the backend, you first need a MongoDB replica set. +A replica set is required because the backend uses MongoDB change streams. +To run a replica set locally, run the following command in the backend folder. + +```bash +npm run db +``` + +The above command should print the connection string to connect to the +replica set locally. Create a **.env file** and populate the `MONGODB_URL`. + +Now in the backend folder. Run the start command in a separate terminal. -Now in the backend folder. Run the start - command - ```bash - npm run start - ``` +```bash +npm run start +``` The backend is now up and running.