This is a Node.js Hono API sample project for lttle.cloud.
It demonstrates how to deploy a simple CRUD API using the Hono framework on lttle.cloud's platform. The API allows you to create, read, update, and delete items stored in a PostgreSQL database using Drizzle ORM.
To run the project locally you will also need to have a PostgreSQL database running and accessible. We have provided a docker-compose.yml file to help you set up a local PostgreSQL instance.
-
Start the PostgreSQL database using Docker Compose:
docker-compose up -d
-
Create the
.envfile in the root of the project with the following content:DATABASE_URL=postgres://postgres:password@localhost:5432/postgres
-
Migrate the database schema using Drizzle Kit:
npm run migrate
-
Start the development server:
npm run dev
To deploy the project to lttle.cloud, run:
lttle deploy hono-api.lttle.yamlThis will build three Docker images
- One for the Hono API
- One in order to run
drizzle-kit migrateto create & migrate the database schema - One in order to run
npm run seedto seed the database with initial data.
Both latter images will run only once during the deployment process and the machines they run on will be removed afterwards.
To understand how we manage to build you can checkout our documentation: lttle.cloud Docs | Building.
After that you can access your static site at https://hono-api--samples--public--your-tenant.eu.lttle.host/ where your-tenant is your lttle.cloud tenant name.
You can check our deployment of this sample https://hono-api--samples--public--aifrim.eu.lttle.host/.