Skip to content

Commit 488645f

Browse files
README getting started
1 parent cf458f2 commit 488645f

File tree

3 files changed

+41
-31
lines changed

3 files changed

+41
-31
lines changed

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,39 @@
11
# How to implement a backend with Effect
22
`@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.
33

4-
> [**Check out the full article**](https://www.typeonce.dev/article/how-to-implement-a-backend-with-effect) to learn how to get started 🚀
4+
> [**Check out the full article**](https://www.typeonce.dev/article/how-to-implement-a-backend-with-effect) to learn how to get started 🚀
5+
6+
7+
## Getting started
8+
This repository includes the following:
9+
- Shared `effect` API definition ([`packages/api`](./packages/api/))
10+
- Backend implementation with `effect` ([`apps/server`](/apps/server/))
11+
- Frontend implementation with [TanStack Router](https://tanstack.com/router/latest) ([`apps/client`](/apps/client/))
12+
- Docker compose for local Postgres + [PgAdmin](https://www.pgadmin.org/) environment ([`docker-compose.yaml`](./docker-compose.yaml))
13+
14+
First, open [Docker Desktop](https://www.docker.com/products/docker-desktop/) and execute the below command to start the database and PgAdmin:
15+
16+
> Make sure to create a `.env` file inside *both* the root directory *and* `apps/server`, containing the parameters listed inside `.env.example`.
17+
18+
```sh
19+
docker compose up
20+
```
21+
22+
This will start the database and PgAdmin. You can access `http://localhost:5050/` to login into the **local PgAdmin dashboard**.
23+
24+
> Use the credentials from `.env`: `PGADMIN_MAIL`+`PGADMIN_PW`.
25+
26+
You can then execute both server and client in the monorepo. Open a second terminal and run the below commands:
27+
28+
```sh
29+
pnpm install
30+
pnpm run dev
31+
```
32+
33+
This will start `client` on `http://localhost:3001/`, and `server` on `http://localhost:3000/`.
34+
35+
Done ✨
36+
37+
Server, client, and database all now all connected. Explore more of the `effect` API by playing around with the code in the repository 🕹️
38+
39+
> [**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 🚀

apps/client/src/routeTree.gen.ts

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,10 @@
1111
// Import Routes
1212

1313
import { Route as rootRoute } from './routes/__root'
14-
import { Route as AboutImport } from './routes/about'
1514
import { Route as IndexImport } from './routes/index'
1615

1716
// Create/Update Routes
1817

19-
const AboutRoute = AboutImport.update({
20-
id: '/about',
21-
path: '/about',
22-
getParentRoute: () => rootRoute,
23-
} as any)
24-
2518
const IndexRoute = IndexImport.update({
2619
id: '/',
2720
path: '/',
@@ -39,51 +32,39 @@ declare module '@tanstack/react-router' {
3932
preLoaderRoute: typeof IndexImport
4033
parentRoute: typeof rootRoute
4134
}
42-
'/about': {
43-
id: '/about'
44-
path: '/about'
45-
fullPath: '/about'
46-
preLoaderRoute: typeof AboutImport
47-
parentRoute: typeof rootRoute
48-
}
4935
}
5036
}
5137

5238
// Create and export the route tree
5339

5440
export interface FileRoutesByFullPath {
5541
'/': typeof IndexRoute
56-
'/about': typeof AboutRoute
5742
}
5843

5944
export interface FileRoutesByTo {
6045
'/': typeof IndexRoute
61-
'/about': typeof AboutRoute
6246
}
6347

6448
export interface FileRoutesById {
6549
__root__: typeof rootRoute
6650
'/': typeof IndexRoute
67-
'/about': typeof AboutRoute
6851
}
6952

7053
export interface FileRouteTypes {
7154
fileRoutesByFullPath: FileRoutesByFullPath
72-
fullPaths: '/' | '/about'
55+
fullPaths: '/'
7356
fileRoutesByTo: FileRoutesByTo
74-
to: '/' | '/about'
75-
id: '__root__' | '/' | '/about'
57+
to: '/'
58+
id: '__root__' | '/'
7659
fileRoutesById: FileRoutesById
7760
}
7861

7962
export interface RootRouteChildren {
8063
IndexRoute: typeof IndexRoute
81-
AboutRoute: typeof AboutRoute
8264
}
8365

8466
const rootRouteChildren: RootRouteChildren = {
8567
IndexRoute: IndexRoute,
86-
AboutRoute: AboutRoute,
8768
}
8869

8970
export const routeTree = rootRoute
@@ -96,15 +77,11 @@ export const routeTree = rootRoute
9677
"__root__": {
9778
"filePath": "__root.tsx",
9879
"children": [
99-
"/",
100-
"/about"
80+
"/"
10181
]
10282
},
10383
"/": {
10484
"filePath": "index.tsx"
105-
},
106-
"/about": {
107-
"filePath": "about.tsx"
10885
}
10986
}
11087
}

apps/server/.env.example

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
POSTGRES_USER=postgres
2-
POSTGRES_PW=postgres
3-
POSTGRES_DB=postgres
1+
POSTGRES_PW=postgres

0 commit comments

Comments
 (0)