This API stores and serves information about Methods bids for client tenders.
- Python 3.x
- Flask
- Homebrew
- Makefile
-
Run the following command to start the API:
make run
- The API will be available at http://localhost:8080/api/bids
-
To see all available Make targets, run the following command in a new terminal:
make help
-
Follow this link to go to the authorization documentation: Authorization Documentation
-
In a new terminal enter the following command to run authorization server if not already running. This will be needed to generate a token:
make auth
- The API will be available at http://localhost:5000/authorise
In order to validate your credentials, configure the database connection and utilise pagination you will have to set up the environmental variables locally.
To do this, create a .env
file in your root folder, with the following key/value pairs:
API_KEY=THIS_IS_THE_API_KEY
SECRET_KEY=THIS_IS_A_SECRET
DB_HOST=localhost
DB_NAME=bidsAPI
TEST_DB_NAME=testAPI
DEFAULT_OFFSET=0
DEFAULT_LIMIT=20
MAX_OFFSET=2000
MAX_LIMIT=1000
DEFAULT_SORT_BIDS=bid_date
DEFAULT_SORT_QUESTIONS=description
APP_NAME=BidsAPI
APP_VERSION=0.8.0
APP_LANG=Python
To install on Windows please see here
-
Install MongoDB by running the following commands:
brew tap mongodb/brew brew install mongodb-community
-
To run MongoDB (i.e. the mongod process) as a macOS service, run:
make mongostart
-
To verify that MongoDB is running, run:
brew services list
You should see the service
mongodb-community
listed asstarted
. -
Run the following command to stop the MongoDB instance, as needed:
make mongostop
-
To begin using MongoDB, connect the MongoDB shell (mongosh) to the running instance. From a new terminal, issue the following:
mongosh
-
To create a new database called
bidsAPI
, run:use bidsAPI
-
To create a new test database called
testAPI
, run:use testAPI
-
To exit the MongoDB shell, run the following command:
exit
OPTIONAL - Download MongoDB Compass to view the database in a GUI. You can download it from here
To set up the application database, run the following command:
```bash
make setup
```
This will perform the following steps:
- Clean up the existing database
- Populate the bids collection with dummy data
- Populate the questions collection with dummy data, using existing bid IDs
-
Run the following command to start the API (if you haven't already):
make run
-
In a new terminal run the following command to view the Swagger UI in your default web browser:
make swag
-
Follow the steps above to start the API, authorization server and database connection (if you haven't already).
-
Run the following command to setup the test database:
make test-setup
-
Enter the following command to run the test suites and generate a test coverage report:
make test
-
Enter the following command to run the integration tests:
make test-integration
-
Follow the steps above to start the API, authorization server and database connection (if you haven't already).
-
In a new terminal enter the following command to open the auth playground in your default web browser:
make authplay
-
Follow the steps in the auth playground to generate a token and much more.
See CONTRIBUTING for details
See LICENSE for details