Skip to content
/ api Public

The Kibisis API is a set of functions that are deployed to DigitalOcean.

License

Notifications You must be signed in to change notification settings

kibis-is/api

Repository files navigation

3D pixelated Kibisis icon

Kibisis API

The Kibisis API is a set of DigitalOcean functions that act as a RESTful API for the Kibisis ecosystem.

GitHub release GitHub release date - published at

GitHub Pre-release GitHub Pre-release Date - Published At

GitHub license

Table Of Contents

🗂️ 1. Overview

1.1. Project Structure

The project structure is based on the DigitalOcean functions project structure. However, the core directories lib and packages have specific functionality:

  • packages - This is where each function resides. Each package/function relates to a versioned API path. For example, v1/quests will correspond to an API path https://<endpoint>/v1/quests
  • lib - This contains independent modules that are referenced from the packages.

⚠️ NOTE: Each path must parse the request header and handle the method, i.e. GET, POST, DELETE e.t.c.

Back to top ^

🛠️ 2. Development

2.1. Requirements

Back to top ^

2.2. Create Personal Doppler Config

To start using your own Doppler config, go to the project on Doppler and press the "+" to create a new personal branch config in the "Development" config

Screen grab of the Doppler dashboard when creating a branch config

⚠️ NOTE: Use your name in lowercase with underscores instead of spaces (snake_case).

Back to top ^

2.3. Setup doppler

Once the branch project config has been setup, follow the instructions here to:

  • login to Doppler, and;
  • setup Doppler to use the api project with your personal config.

⚠️ NOTE: When naming your token, it is recommended you use: "-<device_name>".

Back to top ^

2.4. Setup doctl

The DigitalOcean CLI client, doctl, is used to deploy the function to a remote environment tha can be used to develop.

Follow the instructions outlined in the documentation.

⚠️ NOTE: Once you have setup doctl make sure you also install the serverless subcommand using doctl serverless install

Back to top ^

2.5. Create A Personal Namespace (optional)

⚠️ NOTE: If you have a personal namespace already setup, you can skip this step.

  1. Setup a personal namespace using your name suffixed by the word "namespace" ensuring to use kebab-case:
doctl serverless namespaces create --label="kieran-namespace" --region="ams3"

⚠️ NOTE: The above example shows setting up a namespace in the Amsterdam region, but it is better if you use a region that is closest to you. Run the command: doctl serverless namespaces list-regions to get a list of regions and replace the --region value with the desired region form the list.

Back to top ^

2.6. Deploy The Functions To The Namespace

  1. Deploy the function to the namespace that was created in the previous step:
make deploy
  1. Get the URL of the deployed function:
doctl serverless functions get <package>/<function> --url

This will return a URL in the form of:

https://faas-ams3-2a2df116.doserverless.co/api/v1/web/<namespace>/<package>/<function>

Use this URL to interact with the API.

Back to top ^

📑 3. Appendix

3.1. Useful Commands

Command Description
make Deploys the functions to the remote namespace. Intended for development purposes only.
make clean Removes build files and configurations.
make deploy Fetches secrets from Doppler and deploys the functions to the configured namespace. Intended for development purposes only.
make list Lists the deployed functions in the configured namespace.
make logs Outputs the activation logs for the deployed functions.
make test Runs the tests for each function.
make setup Installs dependencies.
make swagger Parses the functions and creates the swagger.json to packages/vX/swagger directories.
make watch Fetches secrets from Doppler and watches for code changes and redeploys functions to namespace. Intended for development purposes only.

Back to top ^

👏 4. How To Contribute

Please read the Contributing Guide to learn about the development process.

Back to top ^

📄 5. License

Please refer to the COPYING file.

Back to top ^