Skip to content

Commit 1178d2b

Browse files
committed
Basic implementation of project
0 parents  commit 1178d2b

File tree

251 files changed

+29150
-0
lines changed

Some content is hidden

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

251 files changed

+29150
-0
lines changed

.env

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# ASPNET Core Environment
2+
ASPNETCORE_ENVIRONMENT=Development
3+
ASPNETCORE_HTTPS_URLS=http://+:80;https://+:443
4+
ASPNETCORE_HTTP_URLS=http://+:80
5+
CERT_PASSWORD=P@ssword123!
6+
CERT_PATH=/https/aspnetapp.pfx
7+
ENABLE_SCALAR=true
8+
9+
# JWT Configuration
10+
JWT_TOKEN=IoHZ86eQYeKpMyqOXpopMT0qqfoT0wz4oLKl/VjOv4Wt5z7IZExGY191Qmht7EEy3K5NN/n47SC2lTmZCM4+mQ==
11+
JWT_ISSUER=AuthServer
12+
JWT_AUDIENCE=MicroServiceApp
13+
14+
# Api Gateway Configuration
15+
REDIS_HOST=redis
16+
REDIS_PORT=6379
17+
18+
# MinIO Configuration
19+
MINIO_ACCESS_KEY_ID=admin
20+
MINIO_SECRET_ACCESS_KEY=admin123
21+
MINIO_BUCKET=uploads
22+
MINIO_ENDPOINT=minio:9000
23+
MINIO_USE_PATH_STYLE_ENDPOINT=true
24+
MINIO_SERVER_URL=http://localhost:9000
25+
MINIO_CONSOLE_ADDRESS=":9090"
26+
27+
# RabbitMQ Configuration
28+
RABBITMQ_HOST=rabbitmq
29+
RABBITMQ_PORT=5672
30+
RABBITMQ_USER=user
31+
RABBITMQ_PASS=password
32+
33+
# Laravel Configuration
34+
DB_CONNECTION=pgsql
35+
36+
# Database Configuration
37+
DB_HOST=database
38+
DB_PORT=5432
39+
DB_DATABASE=project
40+
DB_USERNAME=postgres
41+
DB_PASSWORD=P@ssword123!
42+
43+
# pgAdmin Configuration
44+
PGADMIN_DEFAULT_EMAIL=[email protected]
45+
PGADMIN_DEFAULT_PASSWORD=admin
46+
47+
# Spring Boot Configuration
48+
SPRING_DATASOURCE_URL=jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_DATABASE}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
notes
2+
planning

.vscode/launch.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"command": "cd frontend && npm run dev",
9+
"name": "Run npm start",
10+
"request": "launch",
11+
"type": "node-terminal"
12+
},
13+
14+
{
15+
"name": "GO: Launch file",
16+
"type": "go",
17+
"request": "launch",
18+
"mode": "debug",
19+
"program": "${file}"
20+
},
21+
{
22+
"name": "C#: ApiGateway [https]",
23+
"type": "dotnet",
24+
"request": "launch",
25+
"projectPath": "${workspaceFolder}\\ApiGateway\\ApiGateway\\ApiGateway.csproj",
26+
"launchConfigurationId": "TargetFramework=;https",
27+
"serverReadyAction": {
28+
"action": "openExternally",
29+
"pattern": "\\bNow listening on:\\s+(https?://\\S+)",
30+
"uriFormat": "%s/scalar/v1"
31+
}
32+
},
33+
{
34+
"name": "C#: AuthService [https]",
35+
"type": "dotnet",
36+
"request": "launch",
37+
"projectPath": "${workspaceFolder}\\AuthService\\AuthService\\AuthService.csproj",
38+
"launchConfigurationId": "TargetFramework=;https",
39+
"serverReadyAction": {
40+
"action": "openExternally",
41+
"pattern": "\\bNow listening on:\\s+(https?://\\S+)",
42+
"uriFormat": "%s/scalar/v1"
43+
}
44+
}
45+
]
46+
}

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"java.compile.nullAnalysis.mode": "automatic",
3+
"java.configuration.updateBuildConfiguration": "interactive"
4+
}

ApiGateway/.dockerignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**/.dockerignore
2+
**/.env
3+
**/.git
4+
**/.gitignore
5+
**/.project
6+
**/.settings
7+
**/.toolstarget
8+
**/.vs
9+
**/.vscode
10+
**/.idea
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/azds.yaml
15+
**/bin
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
LICENSE
25+
README.md

ApiGateway/.idea/.idea.ApiGateway/.idea/.gitignore

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

ApiGateway/.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"dotnet.defaultSolution": "ApiGateway.sln"
3+
}

ApiGateway/ApiGateway.sln

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiGateway", "ApiGateway\ApiGateway.csproj", "{6BE22BDD-953E-410E-888B-E72B9C02A1C7}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AuthService", "..\AuthService\AuthService\AuthService.csproj", "{2F5A1506-6F14-488F-80E3-07AEED90E6BE}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedObjects", "..\SharedObjects\SharedObjects\SharedObjects.csproj", "{7582DD6A-28E7-44A2-9CBA-8818F8F5344A}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatabaseManager", "..\DatabaseManager\DatabaseManager\DatabaseManager.csproj", "{87D47386-3B9B-4752-938E-5DE6F2055645}"
13+
EndProject
14+
Global
15+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
16+
Debug|Any CPU = Debug|Any CPU
17+
Release|Any CPU = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20+
{6BE22BDD-953E-410E-888B-E72B9C02A1C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{6BE22BDD-953E-410E-888B-E72B9C02A1C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{6BE22BDD-953E-410E-888B-E72B9C02A1C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{6BE22BDD-953E-410E-888B-E72B9C02A1C7}.Release|Any CPU.Build.0 = Release|Any CPU
24+
{2F5A1506-6F14-488F-80E3-07AEED90E6BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25+
{2F5A1506-6F14-488F-80E3-07AEED90E6BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{2F5A1506-6F14-488F-80E3-07AEED90E6BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{2F5A1506-6F14-488F-80E3-07AEED90E6BE}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{7582DD6A-28E7-44A2-9CBA-8818F8F5344A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{7582DD6A-28E7-44A2-9CBA-8818F8F5344A}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{7582DD6A-28E7-44A2-9CBA-8818F8F5344A}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{7582DD6A-28E7-44A2-9CBA-8818F8F5344A}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{87D47386-3B9B-4752-938E-5DE6F2055645}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33+
{87D47386-3B9B-4752-938E-5DE6F2055645}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{87D47386-3B9B-4752-938E-5DE6F2055645}.Release|Any CPU.ActiveCfg = Release|Any CPU
35+
{87D47386-3B9B-4752-938E-5DE6F2055645}.Release|Any CPU.Build.0 = Release|Any CPU
36+
EndGlobalSection
37+
GlobalSection(SolutionProperties) = preSolution
38+
HideSolutionNode = FALSE
39+
EndGlobalSection
40+
EndGlobal
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
3+
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/CustomBuildToolPath/@EntryValue">C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\MSBuild.exe</s:String></wpf:ResourceDictionary>

ApiGateway/ApiGateway/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bin
2+
obj
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="AspNetCore.HealthChecks.Redis" Version="9.0.0" />
12+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.3" />
13+
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="9.0.3" />
14+
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.3.0" />
15+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.3" />
16+
<PackageReference Include="Microsoft.Extensions.Caching.Hybrid" Version="9.4.0" />
17+
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.2" />
18+
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="8.7.0" />
19+
<PackageReference Include="Scalar.AspNetCore" Version="2.1.1" />
20+
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.7.0" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<Content Include="..\.dockerignore">
25+
<Link>.dockerignore</Link>
26+
</Content>
27+
</ItemGroup>
28+
29+
<ItemGroup>
30+
<ProjectReference Include="..\..\SharedObjects\SharedObjects\SharedObjects.csproj" />
31+
</ItemGroup>
32+
33+
</Project>
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
using ApiGateway.Services;
2+
using Microsoft.AspNetCore.Authorization;
3+
using Microsoft.AspNetCore.Mvc;
4+
using SharedObjects.DTOs;
5+
using SharedObjects.Models;
6+
using SharedObjects.Responses;
7+
8+
namespace ApiGateway.Controllers;
9+
10+
[ApiController]
11+
[Route("[controller]")]
12+
public class AuthController(ISendRequestService sendRequestService) : ControllerBase
13+
{
14+
[Authorize(AuthenticationSchemes = "Bearer")]
15+
[Authorize(Roles = "admin")]
16+
[HttpPost("register")]
17+
public async Task<ActionResult<ApiResponse<User>>> Register(AdminRegisterDto request)
18+
{
19+
return await sendRequestService.SendRequestAsync<ApiResponse<User>>(HttpMethod.Post, "/auth/register", ServiceType.AuthService, body:request);
20+
// try
21+
// {
22+
// var client = httpClientFactory.CreateClient();
23+
//
24+
// var response = await client.PostAsJsonAsync("http://auth/auth/register", request);
25+
//
26+
// if (!response.IsSuccessStatusCode)
27+
// {
28+
// var errorContent = await response.Content.ReadAsStringAsync();
29+
// return StatusCode((int)response.StatusCode, errorContent);
30+
// }
31+
//
32+
// var user = await response.Content.ReadFromJsonAsync<User>();
33+
//
34+
// return user is null
35+
// ? StatusCode(500, "Failed to deserialize user object from AuthService.") :
36+
// Ok(user);
37+
// }
38+
// catch (Exception ex)
39+
// {
40+
// Console.WriteLine(ex.Message);
41+
// return StatusCode(500, $"An error occurred: {ex.Message}");
42+
// }
43+
}
44+
45+
[HttpPost("login")]
46+
public async Task<ActionResult<ApiResponse<TokenResponseDto>>> Login(UserLoginDto request)
47+
{
48+
49+
return await sendRequestService.SendRequestAsync<ApiResponse<TokenResponseDto>>(HttpMethod.Post, "/auth/login", ServiceType.AuthService, body:request);
50+
// try
51+
// {
52+
// var client = httpClientFactory.CreateClient();
53+
//
54+
// var response = await client.PostAsJsonAsync("http://auth/auth/login", request);
55+
//
56+
// if (!response.IsSuccessStatusCode)
57+
// {
58+
// var errorContent = await response.Content.ReadAsStringAsync();
59+
// return StatusCode((int)response.StatusCode, errorContent);
60+
// }
61+
//
62+
// var token = await response.Content.ReadFromJsonAsync<TokenResponseDto>();
63+
//
64+
// return token is null
65+
// ? StatusCode(500, "Failed to deserialize user object from AuthService.") :
66+
// Ok(token);
67+
// }
68+
// catch (Exception ex)
69+
// {
70+
// Console.WriteLine(ex.Message);
71+
// return StatusCode(500, $"An error occurred: {ex.Message}");
72+
// }
73+
}
74+
75+
[HttpPost("refresh-token")]
76+
public async Task<ActionResult<ApiResponse<TokenResponseDto>>> RefreshToken(RefreshTokenRequestDto request)
77+
{
78+
return await sendRequestService.SendRequestAsync<ApiResponse<TokenResponseDto>>(HttpMethod.Post, "/auth/refresh-token", ServiceType.AuthService, body:request);
79+
// try
80+
// {
81+
// var client = httpClientFactory.CreateClient();
82+
//
83+
// var response = await client.PostAsJsonAsync("htstp://auth/auth/refresh-token", request);
84+
//
85+
// if (!response.IsSuccessStatusCode)
86+
// {
87+
// var errorContent = await response.Content.ReadAsStringAsync();
88+
// return StatusCode((int)response.StatusCode, errorContent);
89+
// }
90+
//
91+
// var token = await response.Content.ReadFromJsonAsync<TokenResponseDto>();
92+
//
93+
// return token is null
94+
// ? StatusCode(500, "Failed to deserialize user object from AuthService.") :
95+
// Ok(token);
96+
// }
97+
// catch (Exception ex)
98+
// {
99+
// Console.WriteLine(ex.Message);
100+
// return StatusCode(500, $"An error occurred: {ex.Message}");
101+
// }
102+
}
103+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using ApiGateway.Services;
2+
using Microsoft.AspNetCore.Authorization;
3+
using Microsoft.AspNetCore.Mvc;
4+
5+
namespace ApiGateway.Controllers;
6+
7+
[ApiController]
8+
[Route("[controller]")]
9+
[Authorize(AuthenticationSchemes = "Bearer")]
10+
[Authorize(Roles = "admin")]
11+
public class CompanyController(ISendRequestService requestService) : ControllerBase
12+
{
13+
// TODO: implement
14+
}

0 commit comments

Comments
 (0)