Compare commits
2 Commits
74dc481081
...
5140b3cd14
Author | SHA1 | Date | |
---|---|---|---|
5140b3cd14 | |||
6168e11725 |
7
ActiveAllocator.API/.env
Normal file
7
ActiveAllocator.API/.env
Normal file
@ -0,0 +1,7 @@
|
||||
ActiveAllocator__Database__Host=database
|
||||
ActiveAllocator__Database__Port=5432
|
||||
|
||||
|
||||
POSTGRES_PASSWORD=nqA3UV3CliLLHpLL
|
||||
PGADMIN_DEFAULT_EMAIL=admin@admin.com
|
||||
PGADMIN_DEFAULT_PASSWORD=3254
|
@ -15,7 +15,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<ContainerImageName>activeallocator</ContainerImageName>
|
||||
<ContainerImageName>ActiveAllocator</ContainerImageName>
|
||||
<PublishProfile>DefaultContainer</PublishProfile>
|
||||
<ContainerImageTags>1.0.0;latest</ContainerImageTags>
|
||||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import SessionManager from "../auth/SessionManager";
|
||||
import { BASE_URL } from "./Settings";
|
||||
import { DEV_URL } from "./Settings";
|
||||
|
||||
export const EndPoints = {
|
||||
USERS: "Users",
|
||||
@ -19,6 +19,14 @@ export const EndPoints = {
|
||||
AUTOCLASS_TRIGGERTRANSACTIONRULES: "Autoclass/TriggerTransactionRules",
|
||||
}
|
||||
|
||||
function getOrigin() {
|
||||
if (window.location.href.includes("http://localhost") || window.location.href.includes("https://localhost"))
|
||||
return DEV_URL;
|
||||
else
|
||||
return window.location.origin + "/"
|
||||
//return WINDOW_BASE_URL === undefined || WINDOW_BASE_URL.contains("localhost") ? DEV_URL : WINDOW_BASE_URL;
|
||||
}
|
||||
|
||||
export function getData(endPoint) {
|
||||
|
||||
let token=SessionManager.getToken();
|
||||
@ -32,7 +40,7 @@ export function getData(endPoint) {
|
||||
'Authorization': 'Bearer ' + token
|
||||
},
|
||||
}
|
||||
return fetch(BASE_URL + endPoint, payload)
|
||||
return fetch(getOrigin() + endPoint, payload)
|
||||
.then(function(response) {
|
||||
if (!response.ok) {
|
||||
throw Error(response.statusText);
|
||||
@ -56,7 +64,7 @@ export function postDataForLogin(type, userData) {
|
||||
body: JSON.stringify(userData)
|
||||
|
||||
}
|
||||
return fetch(BASE_URL + type, payload)
|
||||
return fetch(getOrigin() + type, payload)
|
||||
.then(function(response) {
|
||||
return response.json();
|
||||
}).then(function(result) {
|
||||
@ -79,7 +87,7 @@ export function postData(endPoint, inputObj) {
|
||||
body: JSON.stringify(inputObj)
|
||||
|
||||
}
|
||||
return fetch(BASE_URL + endPoint, payload)
|
||||
return fetch(getOrigin() + endPoint, payload)
|
||||
.then(function(response) {
|
||||
return response.json();
|
||||
}).then(function(result) {
|
||||
@ -100,7 +108,7 @@ export function deleteData(endPoint) {
|
||||
'Authorization': 'Bearer ' + token
|
||||
},
|
||||
}
|
||||
return fetch(BASE_URL + endPoint, payload)
|
||||
return fetch(getOrigin() + endPoint, payload)
|
||||
.then(function(response) {
|
||||
if (!response.ok) {
|
||||
throw Error(response.statusText);
|
||||
@ -126,7 +134,7 @@ export function putData(endPoint, obj) {
|
||||
body: JSON.stringify(obj)
|
||||
|
||||
}
|
||||
return fetch(BASE_URL + endPoint, payload)
|
||||
return fetch(getOrigin() + endPoint, payload)
|
||||
.then(function(response) {
|
||||
return response.json();
|
||||
}).then(function(result) {
|
||||
|
@ -1 +1,3 @@
|
||||
export const BASE_URL = "https://localhost:7260/";//window.baseURL;
|
||||
//export const BASE_URL = "https://localhost:7260/";
|
||||
|
||||
export const DEV_URL = "https://localhost:7260/";
|
16
ActiveAllocator.API/Configs/DatabaseConfig.cs
Normal file
16
ActiveAllocator.API/Configs/DatabaseConfig.cs
Normal file
@ -0,0 +1,16 @@
|
||||
namespace ActiveAllocator.API.Configs;
|
||||
|
||||
public class DatabaseConfig
|
||||
{
|
||||
public string Host { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string User { get; set; }
|
||||
public string Password { get; set; }
|
||||
public uint Port { get; set; }
|
||||
|
||||
public string GetConnectionString()
|
||||
{
|
||||
//Server=localhost;Port=15432;Database=aadb;User Id=postgres;Password=nqA3UV3CliLLHpLL"
|
||||
return $"Server={Host};Port={Port};Database={Name};User Id={User};Password={Password}";
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ internal class Program
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
@ -26,6 +27,11 @@ internal class Program
|
||||
.SetIsOriginAllowed(_ => true)
|
||||
.AllowCredentials();
|
||||
});
|
||||
|
||||
options.AddPolicy(name: MyAllowSpecificOrigins, policy =>
|
||||
{
|
||||
policy.WithOrigins(builder.Configuration.GetSection("ActiveAllocator:AllowedHosts").Get<string[]>());
|
||||
});
|
||||
});
|
||||
|
||||
builder.Services.AddControllersWithViews().AddJsonOptions(x =>
|
||||
@ -43,13 +49,19 @@ internal class Program
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "AA API", Version = "v1" });
|
||||
});
|
||||
|
||||
builder.Services.AddAutoMapper(typeof(Program));
|
||||
builder.Services.AddDbContext<DataContext>(opt =>
|
||||
opt.UseNpgsql(builder.Configuration.GetConnectionString("PSQLConnection")));
|
||||
|
||||
// Configure strongly typed settings object
|
||||
builder.Services.Configure<AppSettings>(builder.Configuration.GetSection("AppSettings"));
|
||||
builder.Services.Configure<EnvelopeFundConfig>(builder.Configuration.GetSection("EnvelopeFund"));
|
||||
builder.Services.Configure<DatabaseConfig>(builder.Configuration.GetSection("ActiveAllocator:Database"));
|
||||
|
||||
DatabaseConfig dbConfig = builder.Configuration.GetSection("ActiveAllocator:Database").Get<DatabaseConfig>();
|
||||
|
||||
builder.Services.AddAutoMapper(typeof(Program));
|
||||
builder.Services.AddDbContext<DataContext>(opt =>
|
||||
opt.UseNpgsql(dbConfig.GetConnectionString()));
|
||||
//opt.UseNpgsql(builder.Configuration.GetConnectionString("PSQLConnection")));
|
||||
|
||||
//GetConnectionString
|
||||
|
||||
builder.Services.AddScoped<IUserService, UserService>();
|
||||
builder.Services.AddScoped<IJwtUtils, JwtUtils>();
|
||||
@ -83,6 +95,7 @@ internal class Program
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
app.UseRouting();
|
||||
app.UseCors(MyAllowSpecificOrigins);
|
||||
|
||||
// custom jwt auth middleware
|
||||
app.UseMiddleware<JwtMiddleware>();
|
||||
|
@ -1,4 +1,16 @@
|
||||
{
|
||||
"ActiveAllocator": {
|
||||
"Database": {
|
||||
"Host": "localhost",
|
||||
"Name": "aadb",
|
||||
"User": "postgres",
|
||||
"Password": "nqA3UV3CliLLHpLL",
|
||||
"Port": "15432"
|
||||
},
|
||||
"AllowedHosts": [
|
||||
"*"
|
||||
]
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"PSQLConnection": "Server=localhost;Port=15432;Database=aadb;User Id=postgres;Password=nqA3UV3CliLLHpLL"
|
||||
},
|
||||
@ -9,9 +21,8 @@
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"AppSettings": {
|
||||
"Secret": "5de80277015f9fd564c4d1cc2cf827dbb1774cd66e7d79aa258d9c35a9f67f32fc6cf0dc24244242bd9501288e0fd69e315b"
|
||||
"AppSettings": {
|
||||
"Secret": "5de80277015f9fd564c4d1cc2cf827dbb1774cd66e7d79aa258d9c35a9f67f32fc6cf0dc24244242bd9501288e0fd69e315b"
|
||||
},
|
||||
"EnvelopeFund": {
|
||||
"CheckIntervalInMinutes": 10
|
||||
|
@ -4,8 +4,27 @@ services:
|
||||
activeallocator-site:
|
||||
image: activeallocator:1.0.0
|
||||
container_name: activeallocator
|
||||
env_file:
|
||||
- .env
|
||||
# environment:
|
||||
# - ActiveAllocator__Database__Port=15432
|
||||
#build:
|
||||
#context: .
|
||||
#dockerfile: MoviesAPI/Dockerfile
|
||||
ports:
|
||||
- 80:80
|
||||
- 7555:7260
|
||||
depends_on:
|
||||
- database
|
||||
|
||||
database:
|
||||
container_name: activeallocator-db
|
||||
image: 'postgres:15'
|
||||
#ports:
|
||||
# - 15432:5432
|
||||
env_file:
|
||||
- .env
|
||||
#networks:
|
||||
# - postgres-network
|
||||
volumes:
|
||||
- ./pg-db_data/:/var/lib/postgresql/data/
|
||||
|
5
Clean.sh
Executable file
5
Clean.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
rm -r ActiveAllocator.API/bin
|
||||
rm -r ActiveAllocator.API/obj
|
||||
rm -r ActiveAllocator.API/ClientApp/build
|
4
Publish.sh
Executable file
4
Publish.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
./Clean.sh
|
||||
|
||||
dotnet publish
|
111
README.md
111
README.md
@ -36,6 +36,8 @@ Use [layoutit.com](https://www.layoutit.com/build).
|
||||
|
||||
Easy background worker [guide](https://dev.to/htissink/easy-guide-to-worker-services-in-net-core-oc1)
|
||||
|
||||
Adding Settings with Docker and `appsettings.json`. [Link](https://stackoverflow.com/questions/48298284/merging-appsettings-with-environment-variables-in-net-core)
|
||||
|
||||
### Back-end Functions
|
||||
|
||||
### Accounts & Envelopes
|
||||
@ -56,115 +58,6 @@ Credit Envelope (CE)
|
||||
If an account or envelope is ```null``` we call it ```(void)```, a placeholder entity that isn't tracked.
|
||||
|
||||
|
||||
#### Scenarios
|
||||
|
||||
```
|
||||
Conflicting Debit & Credit Entities
|
||||
|
||||
If (DA != null && DE.Account != DA)
|
||||
If (CA != null && CE.Account != CA)
|
||||
If (DE.Account != DA)
|
||||
If (DE.Account != DA)
|
||||
If (DE.Account != DA)
|
||||
```
|
||||
|
||||
```
|
||||
Envelopes Affecting Accounts
|
||||
|
||||
If Envelope Accounts differ, account transfer is performed as well as envelope value adjusting.
|
||||
If Envelopes use the same Account (or null envelope) Account value is unaffected.
|
||||
|
||||
Operations with Envelopes should always trigger an update to the virtual balance of the underlying account.
|
||||
|
||||
```
|
||||
```
|
||||
DA -> CA
|
||||
DE -> CE
|
||||
|
||||
Value is deducted from DA
|
||||
Value is added to CA
|
||||
Value is deducted from DE
|
||||
Value is added to CE
|
||||
DE.A Value isn't necessarily changed
|
||||
CE.A Value isn't necessarily changed
|
||||
```
|
||||
```csharp
|
||||
if (DA != null)
|
||||
{
|
||||
addAmount(DA, -amount);
|
||||
}
|
||||
|
||||
if (DE != null)
|
||||
{
|
||||
addAmount(DE, -amount);
|
||||
}
|
||||
|
||||
if (CA != null)
|
||||
{
|
||||
addAmount(CA, amount);
|
||||
}
|
||||
|
||||
if (CE != null)
|
||||
{
|
||||
addAmount(CE, amount);
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
DA -> CA
|
||||
null -> null
|
||||
|
||||
Value is deducted from DA
|
||||
Value is added to CA
|
||||
```
|
||||
|
||||
```
|
||||
DA -> null
|
||||
null -> null
|
||||
|
||||
Value is deducted from DA
|
||||
```
|
||||
|
||||
```
|
||||
null -> CA
|
||||
null -> null
|
||||
|
||||
Value is added to CA
|
||||
```
|
||||
|
||||
```
|
||||
null -> null
|
||||
DE -> CE
|
||||
|
||||
Value is deducted from DE
|
||||
If DE Account differs from CE Account,
|
||||
then value must also be transferred between accounts
|
||||
|
||||
Value is added to CE
|
||||
```
|
||||
|
||||
```
|
||||
null -> null
|
||||
DE -> null
|
||||
|
||||
Value is deducted from DE
|
||||
Virtual Value is returned to Envelope Account
|
||||
```
|
||||
|
||||
|
||||
|
||||
Add virtual balance to account
|
||||
|
||||
Debit Account -> Credit Envelope = true
|
||||
Debit Envelope -> Credit Account = true
|
||||
Debit Account -> (void) = false
|
||||
(void) -> Credit Account = false
|
||||
Debit Envelope -> (void) = false
|
||||
(void) -> Credit Envelope = false
|
||||
|
||||
Debit Account & Debit Envelope -> Credit Envelope = error
|
||||
|
||||
|
||||
## Dev Environment Setup
|
||||
|
||||
On Archlinux install the following to use dotnet: ```sudo pacman -Sy dotnet-sdk dotnet-runtime aspnet-runtime```.
|
||||
|
Loading…
x
Reference in New Issue
Block a user