Skip to content

Commit c66eb0d

Browse files
authored
Merge pull request #36 from sentemon/workout-service
Mock Workout Service Design
2 parents 2324005 + 6943ca6 commit c66eb0d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1991
-62
lines changed

backend/src/AuthService/AuthService.Api/GraphQL/Mutation.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public async Task<KeycloakTokenResponse> Register(RegisterDto input, [Service] R
3636
HttpOnly = false,
3737
Secure = false,
3838
SameSite = SameSiteMode.Strict,
39+
MaxAge = TimeSpan.FromSeconds(result.Response.ExpiresIn)
3940
});
4041

4142
return result.Response;
@@ -56,7 +57,8 @@ public async Task<KeycloakTokenResponse> Login(LoginDto input, [Service] LoginCo
5657
Path = "/",
5758
HttpOnly = false,
5859
Secure = false,
59-
SameSite = SameSiteMode.Strict
60+
SameSite = SameSiteMode.Strict,
61+
MaxAge = TimeSpan.FromSeconds(result.Response.ExpiresIn)
6062
});
6163

6264
return result.Response;

backend/src/AuthService/AuthService.Api/Program.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,9 @@
99

1010
var hostingUrl = builder.Configuration[AppSettingsConstants.WebHostUrl];
1111
var connectionString = builder.Configuration[AppSettingsConstants.DatabaseConnectionString];
12-
var allowedOrigins = builder.Configuration.GetSection(AppSettingsConstants.AllowedOrigins).Get<string[]>();
1312

1413
builder.WebHost.UseUrls(hostingUrl ?? throw new ArgumentNullException(nameof(hostingUrl), "Hosting URL is not configured."));
1514

16-
// ToDo: move to extension method
17-
builder.Services
18-
.AddCors(options =>
19-
{
20-
options.AddPolicy("CorsPolicy", policyBuilder =>
21-
{
22-
policyBuilder
23-
.WithOrigins(allowedOrigins ?? throw new ArgumentNullException(nameof(allowedOrigins),
24-
"Allowed Origin URLs are not configured."))
25-
.AllowCredentials()
26-
.AllowAnyHeader()
27-
.AllowAnyMethod();
28-
});
29-
});
30-
3115
builder.Services.AddHttpContextAccessor();
3216

3317
builder.Services
@@ -56,8 +40,6 @@
5640

5741
// app.UseHttpsRedirection();
5842

59-
app.UseCors("CorsPolicy");
60-
6143
app.UseAuthentication();
6244
app.UseAuthorization();
6345

backend/src/AuthService/AuthService.Api/appsettings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
}
99
},
1010
"AllowedHosts": "*",
11-
"AllowedOrigins": [ "http://localhost:4000", "http://localhost:4200", "http://localhost:8080" ],
1211
"DatabaseConnectionString": "Host=localhost;Port=5432;Username=postgres;Password=mysecretpasswordfordevelopment;Database=AuthDb",
1312
"WebHostUrl": "http://0.0.0.0:8001",
1413
"Keycloak": {

backend/src/AuthService/AuthService.Domain/Constants/AppSettingsConstants.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ namespace AuthService.Domain.Constants;
33
public static class AppSettingsConstants
44
{
55
public const string WebHostUrl = "WebHostUrl";
6-
7-
public const string AllowedOrigins = "AllowedOrigins";
86

97
public const string DatabaseConnectionString = "DatabaseConnectionString";
108

backend/src/Gateway/Gateway/Constants/AppSettingsConstants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Gateway.Constants;
22

3-
public class AppSettingsConstants
3+
public static class AppSettingsConstants
44
{
55
public const string WebHostUrl = "WebHostUrl";
66
public const string AllowedOrigins = "AllowedOrigins";

backend/src/PostService/PostService.Api/Program.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,11 @@
77

88
var builder = WebApplication.CreateBuilder(args);
99

10-
var allowedOrigins = builder.Configuration.GetSection(AppSettingsConstants.AllowedOrigins).Get<string[]>();
1110
var hostingUrl = builder.Configuration[AppSettingsConstants.WebHostUrl];
1211
var connectionString = builder.Configuration[AppSettingsConstants.DatabaseConnectionString];
1312

1413
builder.WebHost.UseUrls(hostingUrl ?? throw new ArgumentNullException(nameof(hostingUrl), "Hosting URL is not configured."));
1514

16-
builder.Services
17-
.AddCors(options =>
18-
{
19-
options.AddPolicy("CorsPolicy", policyBuilder =>
20-
{
21-
policyBuilder
22-
.WithOrigins(allowedOrigins ?? throw new ArgumentNullException(nameof(allowedOrigins),
23-
"Allowed Origin URLs are not configured."))
24-
.AllowCredentials()
25-
.AllowAnyHeader()
26-
.AllowAnyMethod();
27-
});
28-
});
29-
3015
builder.Services.AddHttpContextAccessor();
3116

3217
builder.Services
@@ -57,10 +42,6 @@
5742
app.UseHttpsRedirection();
5843
}
5944

60-
app.UseStaticFiles();
61-
62-
app.UseCors("CorsPolicy");
63-
6445
app.UseAuthentication();
6546
app.UseAuthorization();
6647

backend/src/PostService/PostService.Api/appsettings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
}
77
},
88
"AllowedHosts": "*",
9-
"AllowedOrigins": [ "http://localhost:4000", "http://localhost:4200", "http://localhost:8080" ],
109
"DatabaseConnectionString": "Host=localhost;Port=5432;Username=postgres;Password=mysecretpasswordfordevelopment;Database=PostsDb",
1110
"WebHostUrl": "http://0.0.0.0:8002",
1211
"Keycloak": {

backend/src/PostService/PostService.Domain/Constants/AppSettingsConstants.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ namespace PostService.Domain.Constants;
22

33
public static class AppSettingsConstants
44
{
5-
public const string AllowedOrigins = "AllowedOrigins";
65
public const string WebHostUrl = "WebHostUrl";
76
public const string DatabaseConnectionString = "DatabaseConnectionString";
87

frontend/package-lock.json

Lines changed: 73 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
"@angular/platform-browser-dynamic": "^18.2.0",
2020
"@angular/router": "^18.2.0",
2121
"@apollo/client": "^3.11.10",
22+
"@primeng/themes": "^19.0.5",
2223
"apollo-angular": "^8.0.0",
2324
"graphql": "^16.9.0",
25+
"primeng": "^18.0.0",
2426
"rxjs": "~7.8.0",
2527
"tslib": "^2.3.0",
2628
"zone.js": "~0.14.10"

frontend/src/app/app-routing.module.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,26 @@ import {RegisterComponent} from "./features/auth/componets/register/register.com
66
import {ProfileComponent} from "./features/auth/componets/profile/profile.component";
77
import {CreatePostComponent} from "./features/posts/components/create-post/create-post.component";
88
import {PostListComponent} from "./features/posts/components/post-list/post-list.component";
9+
import {SetUpProfileComponent} from "./features/workouts/components/set-up-profile/set-up-profile.component";
10+
import {WorkoutsListComponent} from "./features/workouts/components/workouts-list/workouts-list.component";
11+
import {SetUpGuard} from "./features/workouts/services/set-up.guard";
12+
import {WorkoutComponent} from "./features/workouts/components/workout/workout.component";
13+
import {NotFoundComponent} from "./shared/not-found/not-found.component";
14+
import {NewWorkoutComponent} from "./features/workouts/components/new-workout/new-workout.component";
15+
import {CreateWorkoutComponent} from "./features/workouts/components/create-workout/create-workout.component";
916

1017
const routes: Routes = [
1118
{path: '', component: PostListComponent, canActivate: [AuthGuard] },
1219
{ path: 'login', component: LoginComponent },
1320
{ path: 'register', component: RegisterComponent },
1421
{ path: 'sentemon', component: ProfileComponent },
15-
{ path: 'create-post', component: CreatePostComponent },
22+
{ path: 'create-post', component: CreatePostComponent, canActivate: [AuthGuard] },
23+
{ path: 'workouts', component: WorkoutsListComponent, canActivate: [AuthGuard, SetUpGuard] },
24+
{ path: 'workouts/new', component: NewWorkoutComponent, canActivate: [AuthGuard] },
25+
{ path: 'workouts/create', component: CreateWorkoutComponent, canActivate: [AuthGuard] },
26+
{ path: 'workouts/:workout-name', component: WorkoutComponent, canActivate: [AuthGuard] },
27+
{ path: 'setup-profile', component: SetUpProfileComponent, canActivate: [AuthGuard] },
28+
{ path: 'not-found', component: NotFoundComponent },
1629
{ path: '**', redirectTo: '', pathMatch: 'full' }
1730
];
1831

frontend/src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {SharedModule} from "./shared/shared.module";
1212
import {graphql} from "./graphql.config";
1313
import {HTTP_INTERCEPTORS, HttpClientModule} from "@angular/common/http";
1414
import {AuthInterceptor} from "./core/services/auth.interceptor";
15+
import {WorkoutsModule} from "./features/workouts/workouts.module";
1516

1617
@NgModule({
1718
declarations: [
@@ -22,6 +23,7 @@ import {AuthInterceptor} from "./core/services/auth.interceptor";
2223
AppRoutingModule,
2324
AuthModule,
2425
PostsModule,
26+
WorkoutsModule,
2527
SharedModule,
2628
HttpClientModule,
2729
ApolloModule

frontend/src/app/features/posts/posts.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import { PostOptionsComponent } from './components/post-options/post-options.com
2222
PostOptionsComponent,
2323
],
2424
exports: [
25-
PostListComponent
25+
PostListComponent,
26+
CreatePostComponent
2627
],
2728
imports: [
2829
CommonModule,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<app-back></app-back>
2+
3+
<div class="create-workout">
4+
<div class="workout-header">
5+
<p>Title</p>
6+
<input type="text" class="workout-input">
7+
8+
<p>Description</p>
9+
<input type="text" class="workout-input">
10+
11+
<p>Image</p>
12+
<input id="file-image" type="file" class="workout-input">
13+
<label for="file-image">Upload Image</label>
14+
15+
<p>Time</p>
16+
<input type="text" class="workout-input">
17+
18+
<p>Level</p>
19+
<input type="text" class="workout-input">
20+
</div>
21+
22+
<div class="create-exercise">
23+
<div class="exercise-header">
24+
<p>Exercise Name</p>
25+
<input type="text" class="exercise-input">
26+
</div>
27+
28+
<div class="create-set">
29+
<div class="set-header">
30+
<p>Reps</p>
31+
<input type="number" class="set-input">
32+
33+
<p>Weight</p>
34+
<input type="number" class="set-input">
35+
</div>
36+
37+
<button class="set-button">Add Set</button>
38+
</div>
39+
40+
<button class="exercise-button">Add Exercise</button>
41+
</div>
42+
</div>

0 commit comments

Comments
 (0)