Compare commits
5 Commits
7bb7df788e
...
80907a89a9
| Author | SHA1 | Date | |
|---|---|---|---|
| 80907a89a9 | |||
| 2472374157 | |||
| b72a10db94 | |||
| d097988dfd | |||
| cb9e8e1107 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -4,6 +4,9 @@ frontend/.tanstack/
|
||||
frontend/.output/
|
||||
frontend/.nitro/
|
||||
releases/
|
||||
LstWrapper/bin
|
||||
LstWrapper/publish
|
||||
LstWrapper/obj
|
||||
|
||||
# ---> Go
|
||||
# If you prefer the allow list template instead of the deny list, see community template:
|
||||
@@ -184,3 +187,4 @@ test-results/
|
||||
backend/go.sum
|
||||
BUILD_NUMBER
|
||||
scripts/resetDanger.js
|
||||
LstWrapper/Program_vite_as_Static.txt
|
||||
|
||||
9
LstWrapper/LstWrapper.csproj
Normal file
9
LstWrapper/LstWrapper.csproj
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
85
LstWrapper/Program.cs
Normal file
85
LstWrapper/Program.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Net.Http;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
// to build the binary dotnet publish -c Release -o ./publish
|
||||
// Go backend
|
||||
builder.Services.AddHttpClient("GoBackend", client =>
|
||||
{
|
||||
client.BaseAddress = new Uri("http://localhost:8080");
|
||||
client.Timeout = TimeSpan.FromSeconds(30);
|
||||
});
|
||||
|
||||
// Node frontend
|
||||
builder.Services.AddHttpClient("NodeFrontend", client =>
|
||||
{
|
||||
client.BaseAddress = new Uri("http://localhost:3000");
|
||||
client.Timeout = TimeSpan.FromSeconds(30);
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.Use((Func<HttpContext, Func<Task>, Task>)(async (context, next) =>
|
||||
{
|
||||
var clientFactory = context.RequestServices.GetRequiredService<IHttpClientFactory>();
|
||||
|
||||
var isApiRequest =
|
||||
context.Request.Path.StartsWithSegments("/api") ||
|
||||
context.Request.Path.StartsWithSegments("/graphql") ||
|
||||
context.Request.Path.StartsWithSegments("/auth") ||
|
||||
!context.Request.Method.Equals("GET", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
var client = clientFactory.CreateClient(isApiRequest ? "GoBackend" : "NodeFrontend");
|
||||
|
||||
try
|
||||
{
|
||||
var requestUri = context.Request.Path + context.Request.QueryString;
|
||||
|
||||
var request = new HttpRequestMessage(
|
||||
new HttpMethod(context.Request.Method),
|
||||
requestUri);
|
||||
|
||||
foreach (var header in context.Request.Headers)
|
||||
{
|
||||
if (!request.Headers.TryAddWithoutValidation(header.Key, header.Value.ToArray()))
|
||||
{
|
||||
request.Content ??= new StreamContent(context.Request.Body);
|
||||
request.Content.Headers.TryAddWithoutValidation(header.Key, header.Value.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
if (context.Request.ContentLength > 0 || context.Request.Headers.ContainsKey("Transfer-Encoding"))
|
||||
{
|
||||
request.Content = new StreamContent(context.Request.Body);
|
||||
}
|
||||
|
||||
var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, context.RequestAborted);
|
||||
|
||||
context.Response.StatusCode = (int)response.StatusCode;
|
||||
|
||||
foreach (var header in response.Headers)
|
||||
{
|
||||
context.Response.Headers[header.Key] = header.Value.ToArray();
|
||||
}
|
||||
|
||||
foreach (var header in response.Content.Headers)
|
||||
{
|
||||
context.Response.Headers[header.Key] = header.Value.ToArray();
|
||||
}
|
||||
|
||||
context.Response.Headers.Remove("transfer-encoding");
|
||||
|
||||
await response.Content.CopyToAsync(context.Response.Body);
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
context.Response.StatusCode = isApiRequest ? 503 : 502;
|
||||
await context.Response.WriteAsync($"{(isApiRequest ? "Go API" : "Frontend")} unavailable: {ex.Message}");
|
||||
}
|
||||
}));
|
||||
|
||||
app.Run();
|
||||
23
LstWrapper/Properties/launchSettings.json
Normal file
23
LstWrapper/Properties/launchSettings.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "http://localhost:5015",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7208;http://localhost:5015",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
LstWrapper/appsettings.Development.json
Normal file
8
LstWrapper/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
9
LstWrapper/appsettings.json
Normal file
9
LstWrapper/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
15
LstWrapper/web.config
Normal file
15
LstWrapper/web.config
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<location path="." inheritInChildApplications="false">
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<aspNetCore processPath="dotnet"
|
||||
arguments=".\LstWrapper.dll"
|
||||
stdoutLogEnabled="true"
|
||||
stdoutLogFile=".\logs\stdout"
|
||||
hostingModel="inprocess" />
|
||||
</system.webServer>
|
||||
</location>
|
||||
</configuration>
|
||||
6
LstWrapper/wwwroot/index.html
Normal file
6
LstWrapper/wwwroot/index.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<p>The new begining to lst</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -16,10 +16,14 @@ func main() {
|
||||
c.JSON(200, gin.H{"message": "pong"})
|
||||
})
|
||||
|
||||
r.Any("/api", errorApiLoc)
|
||||
r.Any("/", errorLoc)
|
||||
r.Run(":8080")
|
||||
}
|
||||
|
||||
func errorLoc(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"message": "welcome to lst system you might have just encountered an incorrect area of the app"})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"message": "welcome to lst system you might have just encountered an incorrect area of the app"})
|
||||
}
|
||||
func errorApiLoc(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"message": "looks like you have encountered an api route that dose not exist"})
|
||||
}
|
||||
|
||||
@@ -1,21 +1,27 @@
|
||||
---
|
||||
services:
|
||||
lst_backend:
|
||||
# build: . # Tell Docker Compose to build the image using the Dockerfile in the current directory
|
||||
image: git.tuffraid.net/cowch/logistics_support_tool:backend-latest
|
||||
container_name: lst_backend # A friendly name for your running container
|
||||
volumes:
|
||||
- /path/to/frontend/backend:/data
|
||||
ports:
|
||||
- "8080:8080"
|
||||
restart: unless-stopped
|
||||
lst_backend:
|
||||
# build: . # Tell Docker Compose to build the image using the Dockerfile in the current directory
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./backend/Dockerfile
|
||||
image: git.tuffraid.net/cowch/logistics_support_tool:backend-latest
|
||||
container_name: lst_backend # A friendly name for your running container
|
||||
volumes:
|
||||
- /path/to/backend/data:/data
|
||||
ports:
|
||||
- "8080:8080"
|
||||
restart: unless-stopped
|
||||
|
||||
lst_frontend:
|
||||
# build: . # Tell Docker Compose to build the image using the Dockerfile in the current directory
|
||||
image: git.tuffraid.net/cowch/logistics_support_tool:frontend-latest
|
||||
container_name: lst_frontend # A friendly name for your running container
|
||||
volumes:
|
||||
- /path/to/frontend/data:/data
|
||||
ports:
|
||||
- "3120:3000"
|
||||
restart: unless-stopped
|
||||
lst_frontend:
|
||||
# build: . # Tell Docker Compose to build the image using the Dockerfile in the current directory
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./frontend/Dockerfile
|
||||
image: git.tuffraid.net/cowch/logistics_support_tool:frontend-latest
|
||||
container_name: lst_frontend # A friendly name for your running container
|
||||
volumes:
|
||||
- /path/to/frontend/data:/data
|
||||
ports:
|
||||
- "3120:3000"
|
||||
restart: unless-stopped
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "logistics_support_tool",
|
||||
"version": "0.0.3-alpha.22",
|
||||
"version": "0.0.1-alpha.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "logistics_support_tool",
|
||||
"version": "0.0.3-alpha.22",
|
||||
"version": "0.0.1-alpha.1",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"dotenv": "^17.2.0",
|
||||
|
||||
@@ -21,7 +21,7 @@ if (Test-Path $envFile) {
|
||||
}
|
||||
|
||||
if (-not $env:BUILD_NAME) {
|
||||
Write-Warning "BUILD_NAME environment variable is not set. Cannot create BUILD_NUMBER file"
|
||||
Write-Warning "BUILD_NAME environment variable is not set. Please make sure you have entered the correct info the env"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
@@ -66,17 +66,38 @@ if ($existingZips.Count -gt $keepReleases) {
|
||||
|
||||
Write-Host "`nPackaging release: $($zipName)"
|
||||
|
||||
$filesToInclude = @(
|
||||
"backend\lst_backend.exe",
|
||||
"frontend\.nitro",
|
||||
"frontend\.tanstack",
|
||||
"frontend\.output",
|
||||
"frontend\public",
|
||||
"package.json",
|
||||
"CHANGELOG.md",
|
||||
"README.md"
|
||||
# Create a temporary staging directory
|
||||
$tempStageDir = New-Item -ItemType Directory -Path (Join-Path $env:TEMP "lst_staging") -Force
|
||||
|
||||
# Copy files to organized structure
|
||||
$filesToCopy = @(
|
||||
@{ Source = "backend\lst_backend.exe"; Destination = "backend\lst_backend.exe" },
|
||||
@{ Source = "LstWrapper\publish\*"; Destination = "lstwrapper\" },
|
||||
@{ Source = "frontend\.nitro"; Destination = "frontend\.nitro" },
|
||||
@{ Source = "frontend\.tanstack"; Destination = "frontend\.tanstack" },
|
||||
@{ Source = "frontend\.output"; Destination = "frontend\.output" },
|
||||
@{ Source = "frontend\public"; Destination = "frontend\public" },
|
||||
@{ Source = "package.json"; Destination = "frontend\package.json" },
|
||||
@{ Source = "CHANGELOG.md"; Destination = "CHANGELOG.md" },
|
||||
@{ Source = "README.md"; Destination = "README.md" }
|
||||
)
|
||||
|
||||
Compress-Archive -Path $filesToInclude -DestinationPath $zipPath
|
||||
foreach ($file in $filesToCopy) {
|
||||
$destPath = Join-Path $tempStageDir $file.Destination
|
||||
New-Item -ItemType Directory -Path (Split-Path $destPath -Parent) -Force | Out-Null
|
||||
Copy-Item -Path $file.Source -Destination $destPath -Recurse -Force
|
||||
}
|
||||
|
||||
Write-Host "`nRelease package created at: $($zipPath)"
|
||||
# Create the zip from the staged directory
|
||||
Compress-Archive -Path "$tempStageDir\*" -DestinationPath $zipPath
|
||||
|
||||
# Clean up temporary directory
|
||||
Remove-Item $tempStageDir -Recurse -Force
|
||||
|
||||
Write-Host "`nRelease package created at: $($zipPath)"
|
||||
Write-Host "Organized structure:"
|
||||
Write-Host "- backend/"
|
||||
Write-Host "- frontend/"
|
||||
Write-Host "- lstwrapper/"
|
||||
Write-Host "- CHANGELOG.md"
|
||||
Write-Host "- README.md"
|
||||
Reference in New Issue
Block a user