Skip to content

Commit

Permalink
Merge branch 'main' into role-based-authorization-spa
Browse files Browse the repository at this point in the history
  • Loading branch information
LimZiJia committed Oct 24, 2024
2 parents d5c4faa + 374d8da commit 75d2106
Show file tree
Hide file tree
Showing 71 changed files with 7,023 additions and 54 deletions.
6 changes: 6 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ USER_DB_LOCAL_URI=mongodb://user-db:27017/user
USER_DB_USERNAME=user
USER_DB_PASSWORD=password

# Match Service
MATCH_DB_CLOUD_URI=<FILL-THIS-IN>
MATCH_DB_LOCAL_URI=mongodb://match-db:27017/match
MATCH_DB_USERNAME=user
MATCH_DB_PASSWORD=password

# Secret for creating JWT signature
JWT_SECRET=you-can-replace-this-with-your-own-secret

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
service: [frontend, services/question, services/user]
service: [frontend, services/question, services/user, services/match]
steps:
- uses: actions/checkout@v4
- name: Use Node.js
Expand Down
18 changes: 17 additions & 1 deletion compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,20 @@ services:

user-db:
ports:
- 27018:27017
- 27018:27017

match:
command: npm run dev
ports:
- 8083:8083
volumes:
- /app/node_modules
- ./services/match:/app

match-db:
ports:
- 27019:27017

match-broker:
ports:
- 5672:5672
52 changes: 52 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ services:
- 8080:8080
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- question
- user
- match
networks:
- gateway-network

Expand Down Expand Up @@ -78,10 +82,56 @@ services:
- user-db-network
command: --quiet
restart: always

match:
container_name: match
image: match
build:
context: services/match
dockerfile: Dockerfile
environment:
DB_CLOUD_URI: ${MATCH_DB_CLOUD_URI}
DB_LOCAL_URI: ${MATCH_DB_LOCAL_URI}
DB_USERNAME: ${MATCH_DB_USERNAME}
DB_PASSWORD: ${MATCH_DB_PASSWORD}
depends_on:
match-broker:
condition: service_healthy
networks:
- gateway-network
- match-db-network
restart: always

match-db:
container_name: match-db
image: mongo:7.0.14
environment:
MONGO_INITDB_ROOT_USERNAME: ${MATCH_DB_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: ${MATCH_DB_PASSWORD}
volumes:
- match-db:/data/db
networks:
- match-db-network
restart: always

match-broker:
container_name: match-broker
hostname: match-broker
image: rabbitmq:4.0.2
user: rabbitmq
networks:
- match-db-network
healthcheck:
test: rabbitmq-diagnostics check_port_connectivity
interval: 30s
timeout: 30s
retries: 10
start_period: 30s

volumes:
question-db:
user-db:
match-db:

networks:
gateway-network:
Expand All @@ -90,3 +140,5 @@ networks:
driver: bridge
user-db-network:
driver: bridge
match-db-network:
driver: bridge
3 changes: 2 additions & 1 deletion frontend/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
}
],
"styles": [
"src/styles.css"
"src/styles.css",
"node_modules/typeface-poppins/index.css"
],
"scripts": []
},
Expand Down
142 changes: 130 additions & 12 deletions frontend/package-lock.json

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

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"primeng": "^17.18.11",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"typeface-poppins": "^1.1.13",
"zone.js": "~0.14.10"
},
"devDependencies": {
Expand Down
Binary file added frontend/public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions frontend/src/_services/authentication.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@ export class AuthenticationService extends ApiService {
) {
super();
const userData = localStorage.getItem('user');
this.userSubject = new BehaviorSubject(userData ? JSON.parse(userData) : null);
const user: User | null = userData ? JSON.parse(userData) : null;
this.userSubject = new BehaviorSubject(user);
this.user$ = this.userSubject.asObservable();
}

public get userValue() {
return this.userSubject.value;
}

public get isLoggedIn(): boolean {
return !!this.userSubject.value;
}

login(username: string, password: string) {
console.log('login', `${this.apiUrl}/auth/login`);
return this.http
.post<UServRes>(
`${this.apiUrl}/auth/login`,
Expand Down
Loading

0 comments on commit 75d2106

Please sign in to comment.