Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions CommBank-Server/CommBank-Server.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.2.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommBank", "CommBank.csproj", "{DA325BC3-4E6C-F2D7-EC8F-60E5F66E0C6C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DA325BC3-4E6C-F2D7-EC8F-60E5F66E0C6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA325BC3-4E6C-F2D7-EC8F-60E5F66E0C6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA325BC3-4E6C-F2D7-EC8F-60E5F66E0C6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA325BC3-4E6C-F2D7-EC8F-60E5F66E0C6C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D84EEE77-21D2-4995-90D6-0729E7460244}
EndGlobalSection
EndGlobal
4 changes: 2 additions & 2 deletions CommBank-Server/CommBank.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>CommBank_Server</RootNamespace>
Expand All @@ -13,7 +13,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
<PackageReference Include="MongoDB.Driver" Version="2.18.0" />
<PackageReference Include="MongoDB.Driver" Version="2.21.1" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions CommBank-Server/Models/Goal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class Goal

public string? Name { get; set; }

public string? icon { get; set; }
public UInt64 TargetAmount { get; set; } = 0;

public DateTime TargetDate { get; set; }
Expand Down
23 changes: 16 additions & 7 deletions CommBank-Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@

var builder = WebApplication.CreateBuilder(args);

// Add services to the container
builder.Services.AddControllers();

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

builder.Configuration.SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("Secrets.json");
// Load configuration from appsettings.json
var mongoSettings = builder.Configuration.GetSection("MongoDbSettings");
var connectionString = mongoSettings.GetValue<string>("ConnectionString");
var databaseName = mongoSettings.GetValue<string>("DatabaseName");

System.Net.ServicePointManager.SecurityProtocol =
System.Net.SecurityProtocolType.Tls12 |
System.Net.SecurityProtocolType.Tls13;

var mongoClient = new MongoClient(builder.Configuration.GetConnectionString("CommBank"));
var mongoDatabase = mongoClient.GetDatabase("CommBank");
// Initialize MongoDB
var mongoClient = new MongoClient(connectionString);
var mongoDatabase = mongoClient.GetDatabase(databaseName);

// Register services
IAccountsService accountsService = new AccountsService(mongoDatabase);
IAuthService authService = new AuthService(mongoDatabase);
IGoalsService goalsService = new GoalsService(mongoDatabase);
Expand All @@ -28,10 +37,12 @@
builder.Services.AddSingleton(transactionsService);
builder.Services.AddSingleton(usersService);

// Enable CORS
builder.Services.AddCors();

var app = builder.Build();

// Configure middleware
app.UseCors(builder => builder
.AllowAnyOrigin()
.AllowAnyMethod()
Expand All @@ -44,10 +55,8 @@
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();

app.Run();
8 changes: 6 additions & 2 deletions CommBank-Server/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
"AllowedHosts": "*",

"MongoDbSettings": {
"ConnectionString": "mongodb+srv://User:MyPass123@cluster0.wl956f0.mongodb.net/commbank?retryWrites=true&w=majority&tls=true&tlsInsecure=true",
"DatabaseName": "commbank"
}
}