finished documentation for installation, database usage and authentication
This commit is contained in:
37
docs/installation/Blazor.md
Normal file
37
docs/installation/Blazor.md
Normal file
@@ -0,0 +1,37 @@
|
||||
## How to use the Blazor API
|
||||
This Installation adds all HopFrame [pages](../pages) and [services](../services) to the application.
|
||||
|
||||
1. Add the HopFrame.Web library to your project
|
||||
|
||||
```
|
||||
dotnet add package HopFrame.Web
|
||||
```
|
||||
|
||||
2. Create a [DbContext](./Database.md) that inherits the ``HopDbContext`` and add a data source
|
||||
<p> </p>
|
||||
|
||||
3. Add the HopFrame services to your application, provide the previously created `DatabaseContext` that inherits from `HopDbContextBase`
|
||||
|
||||
```csharp
|
||||
builder.Services.AddHopFrame<DatabaseContext>();
|
||||
```
|
||||
|
||||
4. **Optional:** You can also add your [AdminContext](../admin)
|
||||
|
||||
```csharp
|
||||
builder.Services.AddAdminContext<AdminContext>();
|
||||
```
|
||||
|
||||
5. Add the authentication middleware to your app
|
||||
|
||||
```csharp
|
||||
app.UseMiddleware<AuthMiddleware>();
|
||||
```
|
||||
|
||||
6. Add the HopFrame pages to your Razor components
|
||||
|
||||
```csharp
|
||||
app.MapRazorComponents<App>()
|
||||
.AddHopFrameAdminPages()
|
||||
.AddInteractiveServerRenderMode();
|
||||
```
|
||||
37
docs/installation/Database.md
Normal file
37
docs/installation/Database.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Database initialization
|
||||
You also need to initialize the data source with the tables from HopFrame
|
||||
|
||||
## Create a DbContext
|
||||
|
||||
1. Create a c# class that inherits from the `HopDbContextBase` and add a data source (In the example Sqlite is used)
|
||||
|
||||
```csharp
|
||||
public class DatabaseContext : HopDbContextBase {
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
|
||||
optionsBuilder.UseSqlite("...");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**IMPORTANT:** You need to leave the `base.OnConfiguring(optionsBuilder)` in place so the HopFrame model relations are set correctly.
|
||||
<p> </p>
|
||||
|
||||
2. Register the `DatabaseContext` as a service
|
||||
|
||||
```csharp
|
||||
builder.Services.AddDbContext<DatabaseContext>();
|
||||
```
|
||||
|
||||
3. Create a database migration
|
||||
|
||||
```bash
|
||||
dotnet ef migrations add Initial
|
||||
```
|
||||
|
||||
4. Apply the migration to the data source
|
||||
|
||||
```bash
|
||||
dotnet ef database update
|
||||
```
|
||||
2
docs/installation/README.md
Normal file
2
docs/installation/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# HopFrame Usage
|
||||
There are two different versions of HopFrame, either the [Web API](./WebAPI.md) version or the full [Blazor web version](./Blazor.md).
|
||||
17
docs/installation/WebAPI.md
Normal file
17
docs/installation/WebAPI.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Ho to use the Web API version
|
||||
This Installation adds all HopFrame [endpoints](../endpoints) and [services](../services) to the application.
|
||||
|
||||
1. Add the HopFrame.Api library to your project:
|
||||
|
||||
```
|
||||
dotnet add package HopFrame.Api
|
||||
```
|
||||
|
||||
2. Create a [DbContext](./Database.md) that inherits the ``HopDbContext`` and add a data source
|
||||
<p> </p>
|
||||
|
||||
3. Add the HopFrame services to your application, provide the previously created `DatabaseContext` that inherits from `HopDbContextBase`
|
||||
|
||||
```csharp
|
||||
builder.Services.AddHopFrame<DatabaseContext>();
|
||||
```
|
||||
Reference in New Issue
Block a user