Skip to content

Commit

Permalink
upgrade to v8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Feb 8, 2024
1 parent 02d62c1 commit bd733e2
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 71 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# .NET 6.0 Next.js + Tailwindcss Template
# .NET 8.0 Next.js + Tailwindcss Template

[![](https://raw.githubusercontent.com/ServiceStack/Assets/master/csharp-templates/nextjs.png)](https://nextjs.jamstacks.net)
[![](https://raw.githubusercontent.com/ServiceStack/Assets/master/csharp-templates/start/nextjs.png)](https://nextjs.jamstacks.net)
![](https://raw.githubusercontent.com/ServiceStack/Assets/master/csharp-templates/nextjs.png)
![](https://raw.githubusercontent.com/ServiceStack/Assets/master/csharp-templates/start/nextjs.png)

> Browse [source code](https://github.com/NetCoreTemplates/nextjs), view live demo [nextjs-api.jamstacks.net](https://nextjs.jamstacks.net) and install with [x new](https://docs.servicestack.net/dotnet-new):
> Browse [source code](https://github.com/NetCoreTemplates/nextjs) and install with [x new](https://docs.servicestack.net/dotnet-new):
This template should help get you started developing with Vue 3 and Typescript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.

Expand All @@ -29,10 +29,7 @@ $ cd api\ProjectName
$ dotnet watch
```

For more, see development workflow docs for
[JetBrains Rider](https://nextjs.jamstacks.net/posts/rider)
and
[VS Code / VS .NET](https://nextjs.jamstacks.net/posts/vs)
For more, see development workflow docs for **JetBrains Rider** and **VS Code / VS .NET**

#### Use npm dev server for UI Development

Expand Down
72 changes: 57 additions & 15 deletions api/MyApp/Configure.Auth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using ServiceStack;
using ServiceStack.Auth;
using ServiceStack.FluentValidation;
using ServiceStack.Html;

[assembly: HostingStartup(typeof(MyApp.ConfigureAuth))]

Expand All @@ -28,27 +29,68 @@ public CustomRegistrationValidator()
public class ConfigureAuth : IHostingStartup
{
public void Configure(IWebHostBuilder builder) => builder
//.ConfigureServices(services => services.AddSingleton<ICacheClient>(new MemoryCacheClient()))
.ConfigureServices(services =>
{
//override the default registration validation with your own custom implementation
services.AddSingleton<IValidator<Register>, CustomRegistrationValidator>();
services.AddPlugin(new RegistrationFeature()); //Enable /register Service
})
.ConfigureAppHost(appHost =>
{
var appSettings = appHost.AppSettings;
appHost.Plugins.Add(new AuthFeature(() => new CustomUserSession(),
new IAuthProvider[] {
new JwtAuthProvider(appSettings) {
AuthKeyBase64 = appSettings.GetString("AuthKeyBase64") ?? "cARl12kvS/Ra4moVBIaVsrWwTpXYuZ0mZf/gNLUhDW5=",
},
new CredentialsAuthProvider(appSettings), /* Sign In with Username / Password credentials */
new FacebookAuthProvider(appSettings), /* Create App https://developers.facebook.com/apps */
new GoogleAuthProvider(appSettings), /* Create App https://console.developers.google.com/apis/credentials */
new MicrosoftGraphAuthProvider(appSettings), /* Create App https://apps.dev.microsoft.com */
})
[
new JwtAuthProvider(appSettings) {
AuthKeyBase64 = appSettings.GetString("AuthKeyBase64") ?? "cARl12kvS/Ra4moVBIaVsrWwTpXYuZ0mZf/gNLUhDW5=",
},
new CredentialsAuthProvider(appSettings), /* Sign In with Username / Password credentials */
new FacebookAuthProvider(appSettings), /* Create App https://developers.facebook.com/apps */
new GoogleAuthProvider(appSettings), /* Create App https://console.developers.google.com/apis/credentials */
new MicrosoftGraphAuthProvider(appSettings) /* Create App https://apps.dev.microsoft.com */
])
{
IncludeDefaultLogin = false
});
appHost.Plugins.Add(new RegistrationFeature()); //Enable /register Service
//override the default registration validation with your own custom implementation
appHost.RegisterAs<CustomRegistrationValidator, IValidator<Register>>();
// Removing unused UserName in Admin Users UI
appHost.Plugins.Add(new AdminUsersFeature {
// Show custom fields in Search Results
QueryUserAuthProperties =
[
nameof(AppUser.Id),
nameof(AppUser.Email),
nameof(AppUser.DisplayName),
nameof(AppUser.Department),
nameof(AppUser.CreatedDate),
nameof(AppUser.LastLoginDate)
],
QueryMediaRules =
[
MediaRules.ExtraSmall.Show<AppUser>(x => new { x.Id, x.Email, x.DisplayName }),
MediaRules.Small.Show<AppUser>(x => x.Department)
],
// Add Custom Fields to Create/Edit User Forms
FormLayout =
[
Input.For<AppUser>(x => x.Email),
Input.For<AppUser>(x => x.DisplayName),
Input.For<AppUser>(x => x.Company),
Input.For<AppUser>(x => x.Department, c => c.FieldsPerRow(2)),
Input.For<AppUser>(x => x.PhoneNumber, c =>
{
c.Type = Input.Types.Tel;
c.FieldsPerRow(2);
}),
Input.For<AppUser>(x => x.Nickname, c =>
{
c.Help = "Public alias (3-12 lower alpha numeric chars)";
c.Pattern = "^[a-z][a-z0-9_.-]{3,12}$";
//c.Required = true;
}),
Input.For<AppUser>(x => x.ProfileUrl, c => c.Type = Input.Types.Url),
Input.For<AppUser>(x => x.IsArchived), Input.For<AppUser>(x => x.ArchivedDate)
]
});
});
}
42 changes: 1 addition & 41 deletions api/MyApp/Configure.AuthRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class ConfigureAuthRepository : IHostingStartup
{
public void Configure(IWebHostBuilder builder) => builder
.ConfigureServices(services => services.AddSingleton<IAuthRepository>(c =>
new OrmLiteAuthRepository<AppUser, UserAuthDetails>(c.Resolve<IDbConnectionFactory>()) {
new OrmLiteAuthRepository<AppUser, UserAuthDetails>(c.GetRequiredService<IDbConnectionFactory>()) {
UseDistinctRoleTables = true
}))
.ConfigureAppHost(appHost => {
Expand All @@ -61,46 +61,6 @@ public void Configure(IWebHostBuilder builder) => builder
CreateUser(authRepo, "[email protected]", "Admin User", "p@55wOrd", roles: new[] { RoleNames.Admin });
CreateUser(authRepo, "[email protected]", "The Manager", "p@55wOrd", roles: new[] { "Employee", "Manager" });
CreateUser(authRepo, "[email protected]", "A Employee", "p@55wOrd", roles: new[] { "Employee" });
// Removing unused UserName in Admin Users UI
appHost.Plugins.Add(new ServiceStack.Admin.AdminUsersFeature {
// Show custom fields in Search Results
QueryUserAuthProperties = new() {
nameof(AppUser.Id),
nameof(AppUser.Email),
nameof(AppUser.DisplayName),
nameof(AppUser.Department),
nameof(AppUser.CreatedDate),
nameof(AppUser.LastLoginDate),
},
QueryMediaRules = new()
{
MediaRules.ExtraSmall.Show<AppUser>(x => new { x.Id, x.Email, x.DisplayName }),
MediaRules.Small.Show<AppUser>(x => x.Department),
},
// Add Custom Fields to Create/Edit User Forms
FormLayout = new() {
Input.For<AppUser>(x => x.Email),
Input.For<AppUser>(x => x.DisplayName),
Input.For<AppUser>(x => x.Company),
Input.For<AppUser>(x => x.Department, c => c.FieldsPerRow(2)),
Input.For<AppUser>(x => x.PhoneNumber, c => {
c.Type = Input.Types.Tel;
c.FieldsPerRow(2);
}),
Input.For<AppUser>(x => x.Nickname, c => {
c.Help = "Public alias (3-12 lower alpha numeric chars)";
c.Pattern = "^[a-z][a-z0-9_.-]{3,12}$";
//c.Required = true;
}),
Input.For<AppUser>(x => x.ProfileUrl, c => c.Type = Input.Types.Url),
Input.For<AppUser>(x => x.IsArchived), Input.For<AppUser>(x => x.ArchivedDate),
}
});
},
afterConfigure: appHost => {
appHost.AssertPlugin<AuthFeature>().AuthEvents.Add(new AppUserAuthEvents());
Expand Down
13 changes: 6 additions & 7 deletions api/MyApp/Configure.AutoQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ public void Configure(IWebHostBuilder builder) => builder
.ConfigureServices(services => {
// Enable Audit History
services.AddSingleton<ICrudEvents>(c =>
new OrmLiteCrudEvents(c.Resolve<IDbConnectionFactory>()));
})
.ConfigureAppHost(appHost => {
new OrmLiteCrudEvents(c.GetRequiredService<IDbConnectionFactory>()));
// For TodosService
appHost.Plugins.Add(new AutoQueryDataFeature());
services.AddPlugin(new AutoQueryDataFeature());
// For Bookings https://github.com/NetCoreApps/BookingsCrud
appHost.Plugins.Add(new AutoQueryFeature {
services.AddPlugin(new AutoQueryFeature {
MaxLimit = 1000,
//IncludeTotal = true,
});
})
.ConfigureAppHost(appHost => {
appHost.Resolve<ICrudEvents>().InitSchema();
});
}

0 comments on commit bd733e2

Please sign in to comment.