Skip to content

strahinjapopovic/mongo-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

mongo-api

Server-side Router with Node.js, Express.js, MongoDB, Mongoose and Insomnia

node version express version npm version mongodb version mongoose version

License: MIT

Twitter: stanpopovic Youtube: strahinja-popovic-ch

Router server-side application with Node.js v22.0.0, NPM-v10.5.1, Express.js-v4.19.2, MongoDB-v6.8.0, Mongoose-v8.5.0, and Insomnia-v9.3.2

Table of Content

Description Info

Mongo API Router uses NPM packages like MongoDB package as a database document model and Mongoose as a object-oriented programming library that establishes connection between database and Node RTE. Mongoose Shemas, database Models and connection are set at first. Seeds for populating databse with testing data at second and routes and controllers at the end. Testing is performed by using Insomnia Client API platform.

Insomnia screenshot.

GitHub Repository

GitHub

Installation Process

As MongoDB will be used as a document database model it should be installed at first MongoDB Installation Package. Click on the button download and start downloading MongoDB Windows installation package (mongodb-windows-x86_64-7.0.12-signed.msi). Also, before start make a empty dir on C drive (C:>mkdir -p data/db). Start MongoDB Setup Wizard and follow instructions. Setup type should be Complete, not Custom, Configuration as Run service as Network Service user, also install MongoDB Compass, press next and install.

Configurate MongoDB on Windows

Navigate to the bin directory of already instolled MongoDb on your machine and copy path (C:\Program Files\MongoDB\Server\6.0\bin) and go to Edit The System Environment Variables (System Properties) at your PC. After went to Environment Variables section, click on the Path at User Variables window and press Edit button. Click on button New and past previously copied path to MongoDB bin directory and press Ok. Check your MongoDB is working type in Git Bash terminal as follows (C:/Users/jdoe> $ mongod):

$ mongod

If terminal shows something like image below it means MongoDB is set properly. Othrewise repeat process again.

Git Bash Terminal screenshot.

After MongoDB is setup, npm packages should be installed at root dir of the application (~/mongo-api/app>): To initialize package.json and to install node_packages run

$ npm init # initialize formating of package.json
$ npm install # installing node packages

To install mongodb npm packages run

$ npm install mongodb 

To install mongoose npm packages run

$ npm install mongoose

Populate database with testing data

Seed data are stored in seed.js file (~/utils/seed.js) and you can execute it as follows:

$ node ./utils/seed.js

Alternatively,

$ npm run seed # automate executable shortcuts scripts at package.json

Run seed output:

VS Code Image.

Usage Info

As a small application it can be helpful for testing and practising purpose but on the other side it has some atributes of serious programming application.

Contributing Guidelines

Currentlly, at this stage there is no contributors but for more information any enquiry can be reffered to Question and Contact section.

Test Instructions

Application runs by invoking command $ npm run start at ~/mongo-api/app> directory. Before running application, download compressed repo from githaub and installl packages globaly or at application root directory from the section Installation Process.

$ nodemon ./server.js # OR node ./server.js 

Alternatively,

$ npm run dev

All automate executable scripts are stored at root directory ~/mongo-api/app> in package.json file.

"scripts": {
    "test": "jest",
    "start": "node ./server.js",
    "dev": "nodemon ./server.js",
    "seed": "node ./utils/seed.js"
  },

Demonstration on YouTube

Demonstration of the application can be visited below.

MongoDB image as thumbnail for YouTube demo video.

License

Copyright © 2024, codexdev. Released under the MIT License.

Questions and Contacts

Questions about application can be reffered to the author's GitHub account or you can Contact Me directly over an email.

About

📚Testing server-side routes with MongoDB collection by using Insomnia API Development Platform.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors