Skip to content

bcgov/sample-api

Repository files navigation

Sample API

This is a sample api.

Technology Used

Setup

Environment variables

The following environment variables are expected:

  • ORIGINS: comma separated list of allowed origins.
  • POSTGRES_SERVER: URL of db server
  • POSTGRES_USER
  • POSTGRES_PASSWORD
  • POSTGRES_DB: postgres DB name

DB adaptor

The psycopg2 adaptor is used. Note the installation requirements for the psycopg2 package. The sample-api dependencies use the psycopg2 package and not the psycopg2-binary package.

Local Development

Running locally

  • Run docker compose up command from root directory to start the entire stack. The following will be started:
    • Postgres server
    • Flyway - it setups the postgres tables and inserts some dev data.
    • sample-api server
  • Environment variables are defined in the docker-compose.yml
  • The sample-api folder is volume mounted, so any changes to the code will be reflected in the container
  • The API's documentation is available at http://localhost:3003/docs.

Unit tests

  • Run docker compose --profile test up command to run the unit tests from the root directory. This will run the above services as well as the unit tests.
  • The folder is volume mounted, so any changes to the code will be reflected in the container and run the unit tests again.

The API

This is a simple API. It is not production ready.

The API is based on the table schema defined in V1.0.0__init.sql file. Note the foreign key constraint if you want to try the endpoints out.

The http://localhost:3003/docs page lists the available endpoints.

About

An example API to experiment with

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published