Skip to content

A MERN simple REST API template using MongoDb on Atlas free server and MongoDb extension on Visual Studio Code

License

Notifications You must be signed in to change notification settings

matheusrosendo/MERNstackRestApiTemplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A MERN simple REST API template using MongoDb on Atlas free server and MongoDb extension on Visual Studio Code

Based on Mongodb tutorial How to Use MERN Stack: A Complete Guide.

Licence main workflow

Requirements

  • npm version ^16
  • Visual Studio Code

Arquitecture

alt text

How To Run

  1. Clone this repo

  2. You can follow the Getting Started with Atlas guide, to learn how to create a free Atlas account, create your first cluster and get your Connection String to the database. Then, set the Atlas URI connection parameter in server/.env to your Connection String:

ATLAS_URI=mongodb+srv://<username>:<password>@sandbox.jadwj.mongodb.net/myFirstDatabase?retryWrites=true&w=majority
  1. Start the Express server:
cd server
npm install
npm install -g nodemon
nodemon server

you should see a "Successfully connected to MongoDB" message on terminal, let it running

  1. Start the React app: open another Terminal tab
cd client
npm install
npm start
  1. Test App on localhost:3000 Create a Record Edit that record

  2. Install Visual Studio Code and MongoDB extension https://code.visualstudio.com/docs/azure/mongodb

    • Use the same connecting string contained in .env file to connect to Atlas MongoDb using the VS code MongoDb extension
    • Open MERNtutorial_employee_populate.mongodb and press 'Play' button
  3. Check out new records inserted on both Atlas UI and localhost

    • Go to https://cloud.mongodb.com/ navigate to collections > MERNstackDB > employee and check new records just inserted
    • Refresh your localhost:3000 on browser and check if the new records are there
  4. You can also execute the other mongoDb files to get used to mongodb shell sintax for insert, erase, update and delete data on mongodb:

    • open server/db/MERNtutorial_* files and execute them

Disclaimer

Use at your own risk; not a supported MongoDB product

About

A MERN simple REST API template using MongoDb on Atlas free server and MongoDb extension on Visual Studio Code

Resources

License

Stars

Watchers

Forks

Packages

No packages published