The goal of this assignment is to store and create an index over question objects in MongoDB, and write a NodeJS + Express based server that exposes a RESTful API to query the index and return questions that match the query.
- Node
- MongoDB
- Clone the repo
git clone https://github.com/tosinbot/realtime-notes-backend.git
- Install NPM packages
npm install
- Setup env file by renaming
.env.example
to.env
PORT=Preferred_Port_Number
MONGODB_URL="db_type://username:password@hostname:port/database_name"
- Start mongodb with
mongod
- Start the server with
npm start
Endpoints | Method | Description |
---|---|---|
/search?q=name of topic | GET | returns an array of question numbers that contain an annotation which is anywhere in the subtree of the query topic |
Frontend application built with Angular can be found here - https://github.com/tosinbot/realtime-notes-app
The app is hosted on Heroku
- Access the API via https://tosin-pencil.herokuapp.com/api/v1/search
- Database is hosted on Mongo Atlas
To query the database make a get request to the route https://tosin-pencil.herokuapp.com/api/v1/search?q=<name of topic>
https://tosin-pencil.herokuapp.com/api/v1/search?q=Reproduction
should return
{
"questions": [
29,48,58,176,181,7,53,54,73,69,158,182,37,52,109,49,122,3,25,193,125,133,12,45,138,187,56,153,190,15,130,167,197]
}
https://tosin-pencil.herokuapp.com/api/v1/search?q=Molecular Genetics
should return
{
"questions": [
31,79,107,150,162,126,144]
}
https://tosin-pencil.herokuapp.com/api/v1/search?q=Molecular Genetics
should return
{
"questions": [
31,79,107,150,162,126,144]
}