Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/refactor nest #61

Merged
merged 11 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
!websocket/
!packages/
!src/
!nest-cli.json
!nest-cli.json
!api/
!proxy/
3 changes: 1 addition & 2 deletions .github/workflows/push-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ jobs:
- name: Build and Push Images
run: |
docker buildx create --use
docker buildx build --platform=linux/amd64,linux/arm64 -t ikehunter5/jukebox-server:latest -f ./server/Dockerfile . --push
docker buildx build --platform=linux/amd64,linux/arm64 -t ikehunter5/jukebox-websocket:latest -f ./websocket/Dockerfile . --push
docker buildx build --platform=linux/amd64,linux/arm64 -t ikehunter5/jukebox-server:latest -f ./Dockerfile . --push
docker buildx build --platform=linux/amd64,linux/arm64 -t ikehunter5/jukebox-proxy:latest ./proxy --push
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ coverage/
_depricated/
_deprecated/
_deprecated_*/
generated/

### Terraform ###
# Local .terraform directories
Expand Down
51 changes: 39 additions & 12 deletions docker-compose.network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,74 @@ services:
- BASE_URL=http://localhost:8080
- SPOTIFY_CLIENT_ID=${SPOTIFY_CLIENT_ID}
- SPOTIFY_CLIENT_SECRET=${SPOTIFY_CLIENT_SECRET}
- PROXY_URL=http://proxy:8080
- DB_HOST=jbx-network-db
- DB_PORT=5432
- DB_USER=devuser
- DB_PASS=devpass
- DB_NAME=devdatabase
ports:
- 9000:9000
depends_on:
- mongodb
- postgres
- pgadmin
- kafka
volumes:
- ./src:/app/src
- ./package.json:/app/package.json
- ./generated:/app/generated
# - api-spec:/app/generated
command: npm run start:network

proxy:
build:
context: ./proxy/
ports:
- 8080:8080
- 8081:8081
networks:
- cluster
depends_on:
- server

volumes:
- client-dist:/vol/client
- club-static:/vol/static
- ./proxy/api:/vol/apispec
environment:
- SERVER_URI=server-jbx:9000
- WEBSOCKET_URI=server-jbx:9000
- CLUB_MANAGER_URI=club-app-network:9000

# attach: false

mongodb:
image: mongo:6.0.9
postgres:
image: postgres:13-alpine
container_name: jbx-network-db
volumes:
- jukebox-network-pg-data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=devdatabase
- POSTGRES_USER=devuser
- POSTGRES_PASSWORD=devpass
networks:
- cluster

pgadmin:
image: dpage/pgadmin4
container_name: jbx-netork-pgadmin
restart: always
container_name: mongo-network-jbx
ports:
- 27017:27017
volumes:
- mongo-data:/data/db
- "8888:80"
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=changeme
command: mongod --quiet --logpath /dev/null --bind_ip_all
- [email protected]
- PGADMIN_DEFAULT_PASSWORD=changeme
# - PGADMIN_SERVER_MODE=True
- PGADMIN_CONFIG_DATABASE_URI="postgresql://devuser:devpass@jbx-network-db:5432/devdatabase"
# - PGADMIN_SQLITE_PATH='/var/lib/sqlite'

volumes:
- pgadmin-network-data:/var/lib/pgadmin
networks:
- cluster

Expand Down Expand Up @@ -113,10 +140,10 @@ services:
volumes:
client-dist:
name: client-dist
mongo-data:
jukebox-network-pg-data:
club-static:
name: club-static
# external: true
pgadmin-network-data:

networks:
cluster:
Expand Down
26 changes: 14 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,29 @@ services:
- SPOTIFY_CLIENT_ID=${SPOTIFY_CLIENT_ID}
- SPOTIFY_CLIENT_SECRET=${SPOTIFY_CLIENT_SECRET}
- LOG_LEVEL=debug
- DB_HOST=jbx-dev-db
- DB_PORT=5432
- DB_USER=devuser
- DB_PASS=devpass
- DB_NAME=devdatabase
ports:
- 8000:8000
depends_on:
- mongodb
- postgres
volumes:
- ./src:/app/src
- ./package.json:/app/package.json
command: npm run start:dev

mongodb:
image: mongo:6.0.9
restart: always
container_name: mongo-jbx
ports:
- 27017:27017
postgres:
image: postgres:13-alpine
container_name: jbx-dev-db
volumes:
- data:/data/db
- jukebox-pg-data:/var/lib/postgresql/data
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=changeme
command: mongod --quiet --logpath /dev/null --bind_ip_all
- POSTGRES_DB=devdatabase
- POSTGRES_USER=devuser
- POSTGRES_PASSWORD=devpass

volumes:
data:
jukebox-pg-data:
11 changes: 4 additions & 7 deletions docs/conventions.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Project Conventions

## Objects, Models, Schemas
## Objects, Entities, DTOs

When handling objects in typescript, often it is useful to know if the object represents minimum fields required for creation, or the full list of fields given from the model serialization process. When differentiating between the two, stick with this convention:

For some model named `Model`,

- Use `IModel` to describe all possible fields, including the ID field
- Use `IModelFields` to describe fields needed when creating the model.
1. Data Transfer Objects (DTOs) dictate shape of data on server ingres/egress (api requests, responses, kafka events, websockets, etc). DTOs determine **inter-service** data contracts.
2. Entities dictate shape of data within the server, between controllers, services, etc. Entities determine **intra-service** data contracts.
3. Use `snake_case` for fields of data objects that are stored inside a database, or passed into/out of the API. This keeps consistency with patterns used across other technologies like Django, Postgres, etc.
Loading