https://github.com/typeonce-dev/effect-backend-example
Example of backend API written with effect that connects to a SQL database (included local Docker configuration with postgres and PgAdmin) ⚡️
https://github.com/typeonce-dev/effect-backend-example
api backend effect effect-ts pgadmin postgres-database postgresql
Last synced: 3 months ago
JSON representation
Example of backend API written with effect that connects to a SQL database (included local Docker configuration with postgres and PgAdmin) ⚡️
- Host: GitHub
- URL: https://github.com/typeonce-dev/effect-backend-example
- Owner: typeonce-dev
- Created: 2025-02-15T06:11:49.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-02-17T03:34:56.000Z (4 months ago)
- Last Synced: 2025-03-25T01:43:40.473Z (3 months ago)
- Topics: api, backend, effect, effect-ts, pgadmin, postgres-database, postgresql
- Language: TypeScript
- Homepage:
- Size: 247 KB
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# How to implement a backend with Effect
`@effect/platform` provides a type safe API for building backend apps. Any runtime, any database, and with all the features you expect from a TypeScript backend.> [**Check out the full article**](https://www.typeonce.dev/article/how-to-implement-a-backend-with-effect) to learn how to get started 🚀
## Getting started
This repository includes the following:
- Shared `effect` API definition ([`packages/api`](./packages/api/))
- Backend implementation with `effect` ([`apps/server`](/apps/server/))
- Frontend implementation with [TanStack Router](https://tanstack.com/router/latest) ([`apps/client`](/apps/client/))
- Docker compose for local Postgres + [PgAdmin](https://www.pgadmin.org/) environment ([`docker-compose.yaml`](./docker-compose.yaml))First, open [Docker Desktop](https://www.docker.com/products/docker-desktop/) and execute the below command to start the database and PgAdmin:
> Make sure to create a `.env` file inside *both* the root directory *and* `apps/server`, containing the parameters listed inside `.env.example`.
```sh
docker compose up
```This will start the database and PgAdmin. You can access `http://localhost:5050/` to login into the **local PgAdmin dashboard**.
> Use the credentials from `.env`: `PGADMIN_MAIL`+`PGADMIN_PW`.
You can then execute both server and client in the monorepo. Open a second terminal and run the below commands:
```sh
pnpm install
pnpm run dev
```This will start `client` on `http://localhost:3001/`, and `server` on `http://localhost:3000/`.
Done ✨
Server, client, and database all now all connected. Explore more of the `effect` API by playing around with the code in the repository 🕹️
> [**Check out the full article**](https://www.typeonce.dev/article/how-to-implement-a-backend-with-effect) for the details of how the code works 🚀