Skip to content

Commit

Permalink
Merge pull request #4 from marmelab/features/games-list-view
Browse files Browse the repository at this point in the history
First ressources lists: user and game.
  • Loading branch information
slax57 authored Jan 30, 2025
2 parents ddc3a28 + 7b97cc4 commit b944fd0
Show file tree
Hide file tree
Showing 13 changed files with 214 additions and 25 deletions.
9 changes: 5 additions & 4 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Configure your dev environment
DATABASE_PORT=<the postgrest port>
DATABASE_USER=<your username>
DATABASE_PASSWORD=<your password>
DATABASE_PORT=<wanted postgres database port>
DATABASE_USER=<wanted postgres database username>
DATABASE_PASSWORD=<wanted postgres database password>

DATABASE_NAME=connect_four_reboot_admin
PGRST_DB_ANON_ROLE=web_anon
PGRST_DB_SCHEMA=api
PGRST_DB_SCHEMA=public
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"

- name: Install dependencies
run: npm install

- name: Check TypeScript types
run: npm run type-check

# - name: Run tests
# run: npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ build
coverage/
.vscode
.env
.vite/

# React Router
/.react-router/
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ database with:
make create-db
```

tips:

```sh
make run
```

this goal do all for you.

## Installation connect-four-reboot-admin frontend

Install the react-admin application dependencies by running:
Expand Down
13 changes: 11 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,30 @@ services:
depends_on:
- database-postgres
environment:
- PGRST_DB_URI=postgres://${DATABASE_USER}:${DATABASE_PASSWORD}@postgres:${DATABASE_PORT}/${DATABASE_NAME}
- PGRST_DB_URI=postgres://${DATABASE_USER}:${DATABASE_PASSWORD}@database-postgres:${DATABASE_PORT}/${DATABASE_NAME}
- PGRST_DB_SCHEMA=${PGRST_DB_SCHEMA}
- PGRST_DB_ANON_ROLE=${PGRST_DB_ANON_ROLE}
networks:
- your_network

database-postgres:
image: postgres:14
ports:
- "${DATABASE_PORT}:${DATABASE_PORT}"
- "${DATABASE_PORT}:5432"
environment:
- POSTGRES_USER=${DATABASE_USER}
- POSTGRES_PASSWORD=${DATABASE_PASSWORD}
- POSTGRES_DB=${DATABASE_NAME}
volumes:
- pgdata:/var/lib/postgresql/data
- ./scripts:/scripts:ro
networks:
- your_network
healthcheck:
test: ["CMD", "pg_isready", "-U", "${DATABASE_USER}"]
interval: 10s
timeout: 5s
retries: 5

networks:
your_network:
Expand Down
17 changes: 16 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ build : ## build the react-admin server.
run-ra-dev: ## run the react-admin server.
npm run dev

## Run
########

run: ## fresh run of all you need to use the app
make run-postgrest-docker && make create-model && make populate-db && make run-ra-dev

stop: ## stop the docker
make stop-postgrest-docker

## Docker - postrgrest / postgres
#################################

Expand All @@ -39,14 +48,19 @@ create-db: ## initialize an empty ready to use db inside the docker - use it onl
docker exec -i connect-four-reboot-admin-database-postgres-1 sh -c 'psql -U $(DATABASE_USER) -c "CREATE DATABASE $(DATABASE_NAME);"'

drop-db: ## drop the postgres db inside the docker.
docker exec -i connect-four-reboot-admin-database-postgres-1 sh -c 'psql -U $(DATABASE_USER) -c "DROP DATABASE IF EXISTS $(DATABASE_NAME);"'
docker exec -i connect-four-reboot-admin-database-postgres-1 sh -c \
'psql -U postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '\''connect_four_reboot_admin'\'';"' && docker exec -i connect-four-reboot-admin-database-postgres-1 sh -c 'psql -U $(DATABASE_USER) -c "DROP DATABASE IF EXISTS $(DATABASE_NAME);"'

create-model: ## create the connect-four-reboot-admin tables.
docker exec connect-four-reboot-admin-database-postgres-1 sh -c 'psql -U $(DATABASE_USER) -d $(DATABASE_NAME) -f /scripts/create_model.sql'

populate-db: ## populate database with fake values
npx tsx tools/populateDbWithFakeData.ts

reset-db:
make drop-db && make create-db && make create-model && make populate-db


## Dev quality
##############

Expand All @@ -58,3 +72,4 @@ lint: ## run linter

format: ## run prettier
npm run format

58 changes: 52 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"@emotion/styled": "^11.14.0",
"@mui/icons-material": "^6.4.0",
"@mui/material": "^6.4.0",
"@raphiniert/ra-data-postgrest": "^2.4.1",
"@types/pg": "^8.11.11",
"dotenv": "^16.4.7",
"faker": "^6.6.6",
"react": "^19.0.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/create_model.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CREATE ROLE web_anon NOLOGIN;
GRANT USAGE ON SCHEMA public TO web_anon;

ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT SELECT, INSERT, UPDATE, DELETE ON tables TO web_anon;
GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO web_anon;

CREATE TABLE IF NOT EXISTS leagues (
id SERIAL PRIMARY KEY,
Expand Down
Loading

0 comments on commit b944fd0

Please sign in to comment.