Skip to content

tumraja/nodejs-api-mongodb

Repository files navigation

TypeScript NodeJs API + MongoDB (WIP)

This small API built on Node, TypeScript and using MongoDB (NoSQL)

Prerequisites

Before you start, make sure you have created a database on MongoDB Atlas. If you don't have an account, please follow the link to create one MongoDB Atlas

Getting Started

  1. The easiest way to get started is to clone the repository:

    # [email protected]:tumraja/nodejs-api-mongodb.git

    then

    # cd nodejs-api-mongodb
  2. Install dependence

    # yarn install OR # npm install
  3. Run the migration to create collections

    Replace {name} with available collections (user, user_proxy, session, operator, tour)

    # ./node_modules/.bin/ts-node commands/migrations/create-collection-{name}.ts 

    You will see collections created in the dashboard under collections tab

  4. Run development server

    # yarn server:watch
  5. Run test

    # yarn test

Adding credentials

Once you have created a database and a user, update environment file configuration - mongoAtlas

config/enviroment.yaml, add your <username>:<password>

How to test API

For the testing purposes, made a list of endpoints you can use in you preferred client. There are two types of storage used MongoDB and InMemory store. To test using InMemory store is very straight forward. You just need to change one line of code and then you are good to go.

NOTE: MongoDB is used as a default storage, to switch to InMemory store, make changes on storage.service.ts on line 22 to InMemoryStorage() and everything should work out of the box.

List of endpoints: Endpoints

Where you can find me

You can find me on twitter Thanks!

License

Copyright (c) Tumsime Kondo. All rights reserved. Licensed under MIT file.

About

NodeJs API written on TypeScript and using MongoDB and In memory storage as alternative

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •