Skip to content

Commit

Permalink
new graphs, disable timer functions, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Tschonti committed Nov 26, 2023
1 parent dbaee4c commit 953b134
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 145 deletions.
78 changes: 71 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,79 @@
# Pontoz-O

This the repository of Pontoz-O, an application to rate hungarian orienteering events. The repository was created with Nx and it's made of three packages:
This the repository of Pontoz-O, an application to rate hungarian orienteering events that was developed in collaboration with the Hungarian Orienteering Federation (MTFSZ). The repository was created with Nx and it's made of three packages:

## Functions
- Functions: The backend of the application, which is an Azure Funtion App written in TypeScript with the Node programming model v4.
- Client: The React frontend of the application.
- Common: Common types and util functions of the two main packages.

The backend of the application, which is an Azure Funtion App written in TypeScript with the Node programming model v4.
## Local development

## Client
The setup for local development is time consuming and requires access to some resources of the MTFSZ that are not public.

The React frontend of the application.
You'll need the following applications:

## Common
- VS Code with the Azure Functions extension v1.10.4 or above and the Nx extension
- Node.js 18.x or above
- Azure Functions Core Tools v4.0.5382 or above
- Azure Storage Emulator

Common types and util functions of the two main packages.
You'll need to be able to connect to the following services:

- Azure SQL or Microsoft SQL Server database
- Redis
- Azure API Management
- MTFSZ SSO (not publically available)

Next, create a `local.settings.json` file in `/packages/functions`.
Fill with the following values:

```json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;",
"FUNCTIONS_WORKER_RUNTIME": "node",
"APIM_HOST": <URL of your API Management instance>,
"APIM_KEY": <subscription key for your APIM instance>,
"CLIENT_ID": <client id of your registered app at MTFSZ SSO>,
"CLIENT_SECRET": <client secret of your registered app at MTFSZ SSO>,
"JWT_SECRET": "a very secret value dont share it with anyone",
"ADMINS": <array of MTFSZ users that the seed function will set as admin>,
"WEBSITE_RUN_FROM_PACKAGE": "1",
"REDIS_HOST": <host url of your redis instance>,
"REDIS_PORT": <port of your redis instance>,
"REDIS_PWD": <password of your redis instance>,
"DB_SERVER": <host of your database server>,
"DB_NAME": <database name of your database>,
"DB_USER": <user (with datareader and datawriter roles) of your database>,
"DB_PWD": <password of your user>,
"DB_ADMIN_USER": <user (with database admin role) of your database>,
"DB_ADMIN_PWD": <password of your admin user>
},
"Host": {
"LocalHttpPort": 3000,
"CORS": "*"
}
}
```

Next, create a `.env` file in `/packages/client` with the follwoing content:

```
VITE_CLIENT_ID=<client id of your registered app at MTFSZ SSO>
VITE_APIM_KEY=<subscription key for your APIM instance>
PORT=3001
```

Install the dependencies:

```
npm i
```

Then start the frontend and backend with Nx:

```
nx run functions:start
nx run client:serve
```
2 changes: 1 addition & 1 deletion docs/architecture.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 17 additions & 17 deletions docs/authCode.puml
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,30 @@ participant db[
""Azure SQL""
]

user -> webapp ++: Click on Login button
webapp -> mauth ++: Redirect to /auth
user -> webapp ++: 1: Click on Login button
webapp -> mauth ++: 2: Redirect to /auth
|||
mauth -> user ++: Ask login credentials
mauth -> user ++: 3: Ask login credentials
|||
return login credentials
return 4: login credentials
|||
mauth -> user++: Share user data with Pontoz-O?
mauth -> user++: 5: Share user data with Pontoz-O?
|||
return Yes
mauth -> funcapp --++: Redirect to redirectURI with authorizationCode
return 6: Yes
mauth -> funcapp --++: 7: Redirect to redirectURI with authorizationCode
|||
funcapp -> mauth++: Call /token to exchange code for token
funcapp -> mauth++: 8: Call /token with authCode and secret
|||
return tokens
funcapp -> mapi ++: Get user data with token
return 9: token
funcapp -> mapi ++: 10: Get user data with token
|||
return user data
funcapp -> db ++: Get user roles
return 11: user data
funcapp -> db ++: 12: Get user roles
|||
return user roles
return 13: user roles
|||
funcapp -> funcapp: Create JWT with user data and roles
funcapp --> webapp--: JWT
webapp -> webapp: store JWT in cookie
return User logged in!
funcapp -> funcapp: 14: Create JWT with user data and roles
funcapp --> webapp--: 15: JWT
webapp -> webapp: 16: store JWT in cookie
return 17: User logged in!
@enduml
4 changes: 4 additions & 0 deletions docs/navigation.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/navigation_admin.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
116 changes: 0 additions & 116 deletions packages/functions/package-lock.json

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

5 changes: 3 additions & 2 deletions packages/functions/src/functions/events/closeRating.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, InvocationContext, Timer } from '@azure/functions'
import { InvocationContext, Timer } from '@azure/functions'
import { getRedisClient } from '../../redis/redisClient'
import Event from '../../typeorm/entities/Event'
import { getAppDataSource } from '../../typeorm/getConfig'
Expand Down Expand Up @@ -41,8 +41,9 @@ export const closeRating = async (myTimer: Timer, context: InvocationContext): P
}
}

/* Disabling this function until the end of the winter period, so the testing events will stay rateable
app.timer('events-close-rating', {
schedule: '0 0 3 * * *', // 3 AM every day
handler: closeRating,
runOnStartup: false,
})
})*/
5 changes: 3 additions & 2 deletions packages/functions/src/functions/events/import.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, InvocationContext, Timer } from '@azure/functions'
import { InvocationContext, Timer } from '@azure/functions'
import { getHighestRank, getRateableEvents, stageFilter } from '@pontozo/common'
import { getRedisClient } from '../../redis/redisClient'
import Club from '../../typeorm/entities/Club'
Expand Down Expand Up @@ -83,8 +83,9 @@ export const importEvents = async (myTimer: Timer, context: InvocationContext):
}
}

/* Disabling this function until the end of the winter period, so only the testing events will be rateable
app.timer('events-import', {
schedule: '0 0 12 * * *', // 12 PM every day (noon)
handler: importEvents,
runOnStartup: false,
})
})*/

0 comments on commit 953b134

Please sign in to comment.