Harnessing the power of AI to imagine the world in a goosier way.
This CRUD API provides a collection of inspirational quotes from the wise and charismatic Goose.
It is powered by the HONC stack, consisting of Hono for the API, Neon for the database, and Drizzle for the ORM. It runs on CloudFlare Workers.
The repo is also a good example of how to use FPX to build, test and debug a Hono API.
Besides the requirements specified in the package.json
you will need a Postgres database.
To run this project you need to provide a DATABASE_URL
and an OPENAI_API_KEY
. The easiest way is to provide both in a dev.vars
file at the root of the project. A dev.vars.example
file is included in the project to serve as a template
Set the DATABASE_URL
in the dev.vars
. The drizzle.config.ts
file will use this URL to migrate the tables to your database. The Cloudflare worker will also need access to this variable to interact with the database.
We recommend using Neon for a Postgres database, but any other Postgres database should do the trick, as well as running one locally.
For the generation of quotes and biographies for the geese, you will need an OpenAI API key. You can create one here.
You can set the OpenAI API key in the .dev.vars
file or in the .env
file or within your wrangler.toml
file.
- Clone the repository:
git clone https://github.com/fiberplane/goose-quotes-api.git
- Navigate to the project directory:
cd goose-quotes-api
- Install dependencies:
yarn install
- Setting up the database:
yarn run db:setup
which is the same as running:
yarn run db:generate
yarn run db:migrate
yarn run db:seed
- Start the development server:
yarn dev
The API will be running at http://localhost:8787
and spin up a local CloudFlare Worker.
In order to debug your API, you can use FPX Studio and the Hono Otel Client Library.
The client library is already installed and configured in the project. All you need to do is run the following command to start FPX Studio:
yarn run fiberplane
Then restart your API, and inspect your routes and generate requests at http://localhost:8788
.
yarn run deploy
You will need a CloudFlare account to deploy the API. You can create one here.
Description: Home page. If the shouldHonk query parameter is present, it responds with “Honk honk!”.
Description: Retrieves all geese. If the name query parameter is defined, it returns geese whose names match the search term.
Description: Creates a new goose. Requires name, and optionally isFlockLeader, programmingLanguage, motivations, and location in the request body.
Description: Generates goose quotes influenced by the specified goose.
Description: Retrieves all geese that are flock leaders.
Description: Retrieves a goose by its ID.
Description: Generates a bio for the specified goose and updates it.
Description: Sends a honk message to the specified goose by its ID.
Description: Updates the name of the specified goose by its ID.
Description: Retrieves geese by programming language.
Description: Updates the motivations of the specified goose by its ID.
Description: WebSocket endpoint for handling various real-time events related to geese, such as retrieving geese and creating a new goose.
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.