Skip to content

cymulatereouven/mdb-playground

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MongoDB Web Project Playground

Installation

Note: this project was tested on Node.js versio 22.4.x.

npm i

Configuration

cat <<EOF > .env
PORT=3000
MONGODB_URI="<YOUR_MONGODB_CONNECTION_STRING>"
PRODUCTION=0
LOG_LEVEL=info
ATLAS_API_BASE_URI=https://cloud.mongodb.com/api/atlas/v2/groups/<PROJECT_ID>/clusters/<CLUSTER_NAME>/
ATLAS_PUBLIC_KEY=<ATLAS_PROJECT_API_PUB_KEY>
ATLAS_PRIVATE_KEY=<ATLAS_PROJECT_API_PVT_KEY>
EOF

Run the web service

Run a development server with a change listener (nodemon):

npm run dev 

Build and run the project

npm run build
npm run start

Build and run in cluster mode:

npm run build
npm run prod

Migrations

Create a migration in the following way:

npm run build-and-generate-migration --name=<short name>

This will create a new migration file under ./src/migrations/. If you named your migration "JIRA-214", you should see a log entry along the following one:

{
  "level":"info",
  "message":"Migration successfully written to /workspace/mdb-playground/src/migrations/m-20240726T083627-66a3600b6b350f3ede3d0010-JIRA-214.ts. Edit this TS file to implement the migration",
  "pid":"53697",
  "timestamp":"2024-07-26T08:36:27.776Z"
}

Once you finished editing your migration file (or files), you can apply it in the following way:

npm run build-and-migration

This project contains a couple of sample migrations - you can try them out.

About

Sample web project with MongoDB Atlas

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 93.5%
  • EJS 6.5%