This small API built on Node, TypeScript and using MongoDB (NoSQL)
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
- MongoDB
- Node.js 13+
- Command Line Tools
- OS (Mac OS X / Windows / Linux)
-
The easiest way to get started is to clone the repository:
# [email protected]:tumraja/nodejs-api-mongodb.git
then
# cd nodejs-api-mongodb
-
Install dependence
# yarn install OR # npm install
-
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
-
Run development server
# yarn server:watch
-
Run test
# yarn test
Once you have created a database and a user, update environment file configuration - mongoAtlas
config/enviroment.yaml
, add your<username>:<password>
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
You can find me on twitter Thanks!
Copyright (c) Tumsime Kondo. All rights reserved. Licensed under MIT file.