- NodeJS using Express framework with MongoDB as database.
- Innovaccer HackerCamp Homepage
- The Problem Statement for HackerCamp '19.
- API Docs for all the APIs.
- Project Homepage
Project is based on SandBox API of ApiMedic API.
- Clone the repository using
git clone
and then change the directory to root of the project
git clone https://github.com/ays14/innovaccer-hackercamp-19.git
cd innovaccer-hackercamp-19
- Create
.env
file as per the sampleEXAMPLE.env
file in the root of your project. The username and password are the credentials for Sandbox Api for ApiMedic API. These credentials are API keys and can be found here. Please make an account here, if you don't have one to get your API keys.
Lines beginning with '#' are comments and are not required in .env
By default, the working environment, 'env' is set equal to 'development'
- If you are working behind a Proxy Server then uncomment all the proxy blocks in the code and configure proxy configuration in
.env
.
Which blocks in code are to be uncommented? This is answered in Proxy Setup
- Use
npm
oryarn
to install dependencies for the project
yarn
OR
npm install
-
Make sure, MongoDB is running at your configured
db_url
in.env
file. If not installed, then install from here -
Run the program either by
npm
oryarn
using
yarn start
OR
npm start
yarn startDev
ornpm startDev
script is for starting withnodemon
.
The console logs the following if the app is running properly
[Database] Connected to database at: mongodb://localhost:27017
Note: The folder tree does not include sub-directories for common/generated folders. For example -
node_modules
.
- Sub-directories of the folders marked with ' * ' are not shown for clarity.
- Folders are typed in bold
─── innovaccer-hackercamp-19
├── app.js
├── bin
│ └── www
├── config.js
├── docs
│ ├── api_data.js
│ ├── api_data.json
│ ├── api_project.js
│ ├── api_project.json
│ ├── css*
│ ├── fonts*
│ ├── img*
│ ├── index.html
│ ├── locales*
│ ├── main.js
│ ├── utils*
│ └── vendor*
├── EXAMPLE.env
├── .env
├── .git*
├── .gitignore
├── models
│ └── Conditions.js
├── node_modules*
├── package.json
├── public*
├── README.md
├── routes
│ └── apiRoutes.js
├── services
│ ├── index.js
│ └── scrapper
│ └── index.js
└── views*
├── yarn-error.log
└── yarn.lock
The project has 4 endpoints mounted at {server_ip}/
namely -
- Symptoms
- Diagnosis
- ConditionInfo
- MedicationInfo
Note: The project is completed while working behind a proxy server. There may be some proxy configuration in API Docs, which can be simply ignored for non-proxy server environment. It is mandatory for MedicationInfo, to be called after ConditionInfo has been called with same query.
Because sometimes NightmareJS
instance doesn't destroy completely on slow web-servers, which it is trying to scrap. A request timeout may happen without launching Nighmare instance. This issue is being addressed by NighmareJS developers.
By default, NightmareJS instance's show property
is set to true
. This asks NightmareJS to load a GUI instance of the browser. It can be set to false
in services/scrapper/index.js -> Line: 22
In the case, when either of the 'ConditionInfo' or 'MedicationInfo' show request timeout,
and execute the same query then it will work fine.
The documentation regarding all of the four above listed APIs can be found at API Docs or in the docs/index.html
where docs is a folder in the project.
The code blocks to uncomment are commented with the line
--> Uncomment for Proxy Setup <--
The line numbers for files are listed below
-
config.js -> Line: 10-15, 22-31
-
services/index.js -> Line: 9-17, 42-44
-
services/scrapper/index.js -> Line: 7-9, 12-19, 34-36, 69-71. Also in the same file comment the section -> Line: 20-24
-
routes/apiRoutes.js -> Line: 14-22, 72-74, 172-174