Skip to content

kir-dev/StartSCH

Repository files navigation

StartSCH

Running locally

Dependencies

  • .NET 9 SDK
    • make sure you can run dotnet --info and it shows 9.x.x under .NET SDKs installed
  • bun
    • make sure you can run bun

AuthSCH credentials

Go to https://auth.sch.bme.hu/console/create, set Átirányítási cím to http://localhost:5264/signin-oidc, then use the created credentials in the following commands:

Running from terminal

git clone https://github.com/kir-dev/StartSCH
cd StartSCH/StartSch
dotnet user-secrets set AuthSch:ClientId $YOUR_AUTHSCH_CLIENTID
dotnet user-secrets set AuthSch:ClientSecret $YOUR_AUTHSCH_CLIENTSECRET
dotnet run

Development

Configuration

Push notifications (optional)

When sending push notifications, most push services, for example Apple, require a VAPID key pair. You can use Push Companion to generate these.

dotnet user-secrets set Push:PublicKey "..."
dotnet user-secrets set Push:PrivateKey "..."
dotnet user-secrets set Push:Subject "mailto:..."

Database

Migrations

After modifying the Db, you have to create new migrations:

# Go to the server project directory (e.g. ~/src/StartSCH/StartSch)
cd StartSch

# Make sure you can run `dotnet ef`.
# One of these commands, ideally the first one, should install it.
dotnet tool restore
dotnet tool install dotnet-ef
dotnet tool install dotnet-ef --global

# Describe the migration
export MIGRATION_MESSAGE=AddSomethingToSomeOtherThing

# Add migration
dotnet ef migrations add --context SqliteDb $MIGRATION_MESSAGE
dotnet ef migrations add --context PostgresDb $MIGRATION_MESSAGE

# Remove latest migration
dotnet ef migrations remove --context SqliteDb
dotnet ef migrations remove --context PostgresDb

# Reset migrations
rm -r Data/Migrations
dotnet ef migrations add --context SqliteDb --output-dir Data/Migrations/Sqlite $MIGRATION_MESSAGE
dotnet ef migrations add --context PostgresDb --output-dir Data/Migrations/Postgres $MIGRATION_MESSAGE

Migrations are applied automatically on server startup.

Injecting a Db instance

Depending on where you want to access the database, you have to decide between injecting Db or IDbContextFactory<Db>.

For example, static forms or API controllers that run in a scope should use Db, while methods in an interactive Blazor component should request a new Db instance every time they run.

Releases

No releases published

Packages

No packages published