/mongodb-api

Primary LanguageTypeScript

Introduction

API to mongodb database. Challenge.

API URLs

  • admin_url: https://mongodb-api-w05f.onrender.com/admin/api/v1
  • url: https://mongodb-api-w05f.onrender.com/api/v1

TESTS ACCOUNTS

admin:

{
    "email": "fac.ariasl@gmail.com",
    "password": "12345678",
},
{
    "email": "john.doe@email.com",
    "password": "12345678",
}

Project Support Features

  • Users can signup and login to their accounts
  • Public (non-authenticated) users can access all causes on the platform
  • Authenticated users can access all causes as well as create a new cause, edit their created cause and also delete what they've created.

Installation Guide

  • Clone this repository here.
  • The develop branch is the most stable branch at any given time, ensure you're working from it.
  • Run npm install to install all dependencies
  • You can either work with the default mLab database or use your locally installed MongoDB. Do configure to your choice in the application entry file.
  • Create an .env file in your project root folder and add your variables. See .env.sample for assistance.

Usage

  • Run npm run dev to start the application.
  • Connect to the API using Postman on port 3001.

Authentication

This API requires authentication using a Bearer token for each request (token value from login response). You should include the token in the Authorization header as follows: Authorization: Bearer <your_token_here>

API Endpoints (admin)

HTTP Verbs Endpoints Action Query
POST admin_url/api/v1/auth/login To login an existing user account
GET admin_url/api/v1/users To get all users page=1&limit=10&order=asc&orderBy=name&search=surname
POST admin_url/api/v1/users To create a new user
PUT admin_url/api/v1/users/:userId To update/edit a user
DELETE admin_url/api/v1/users/:userId To delete a user
GET admin_url/api/v1/pets To get all pets page=1&limit=10&order=asc&orderBy=breed&search=name
POST admin_url/api/v1/pets To create a new pet, associated to your account (user)
PUT admin_url/api/v1/pets/:petId To update/edit a pet
DELETE admin_url/api/v1/pets/:petId To delete a pet

API Endpoints (subscriber)

HTTP Verbs Endpoints Action Query
POST url/api/v1/users To create a new user
POST url/api/v1/auth/login To login an existing user account
GET url/api/v1/users/myprofile To get user profile
PUT url/api/v1/users/:userId To update/edit your profile user
POST url/api/v1/pets To create a new pet, associated to your account (user)
GET url/api/v1/pets To get all user pets
PUT url/api/v1/pets/:petId To update/edit a single pet

Technologies Used

  • NodeJS This is a cross-platform runtime environment built on Chrome's V8 JavaScript engine used in running JavaScript codes on the server. It allows for installation and managing of dependencies and communication with databases.
  • ExpressJS This is a NodeJS web application framework.
  • MongoDB This is a free open source NOSQL document database with scalability and flexibility. Data are stored in flexible JSON-like documents.
  • mongodb MongoDB validation to mongo documents

Authors

License

This project is available for use under the MIT License.