Setup API and setup WEB package

This commit is contained in:
2026-03-17 16:05:32 +00:00
parent 7b70c25393
commit 4707661ffd
18 changed files with 4815 additions and 16 deletions
+2 -1
View File
@@ -1 +1,2 @@
golang 1.26.0
golang 1.26.0
nodejs 25.8.1
+9
View File
@@ -0,0 +1,9 @@
.DEFAULT_GOAL := build
build-ui:
cd ./cmd/web/ui && npm build
.PHONY: build-ui
build:
go build
.PHONY: build
+19 -8
View File
@@ -2,21 +2,32 @@ package api
import (
"sync"
"time"
"github.com/BlackChaosNL/Orchestra/cmd/api/routes"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/cors"
"github.com/kataras/golog"
)
var app *fiber.App
const idleTimeout = 5 * time.Second
func StartAPIServer(wg *sync.WaitGroup) {
defer wg.Done()
r := fiber.New()
app = fiber.New(fiber.Config{IdleTimeout: idleTimeout})
app.Use(golog.New())
app.Use(cors.New())
r.Group("/api/v1/")
g := app.Group("/api/v1/")
r.Get("/api/v1/", func(c fiber.Ctx) error {
return c.Status(200).JSON(&fiber.Map{
"ping": "pong!",
})
})
routes.GlobalRouter(g)
r.Listen(":8080")
golog.Fatal(app.Listen(":9810"))
}
func StopAPIService() {
app.Shutdown()
golog.Print("Test")
}
+21
View File
@@ -0,0 +1,21 @@
package routes
import (
"time"
"github.com/gofiber/fiber/v3"
)
func GlobalRouter(r fiber.Router) {
r.Get("/", func(c fiber.Ctx) error {
return c.Status(200).JSON(&fiber.Map{
"ping": "pong!",
})
})
r.Get("/time", func(c fiber.Ctx) error {
return c.Status(200).JSON(&fiber.Map{
"current_time": time.Now(),
})
})
}
+25 -1
View File
@@ -2,12 +2,36 @@ package web
import (
"sync"
"time"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/cors"
"github.com/gofiber/fiber/v3/middleware/static"
"github.com/kataras/golog"
)
var app *fiber.App
const idleTimeout = 5 * time.Second
func StartWebServer(wg *sync.WaitGroup) {
defer wg.Done()
golog.Print("Web started")
app = fiber.New(fiber.Config{IdleTimeout: idleTimeout})
app.Use(golog.New())
app.Use(cors.New())
app.Get("/", static.New("./ui/dist"), static.Config{
MaxAge: 0,
})
app.Get("/static/*", static.New("./ui/dist/static", static.Config{
MaxAge: 31536000, // 1 year
}))
golog.Fatal(app.Listen(":9800"))
}
func StopAPIService() {
app.Shutdown()
}
+28
View File
@@ -0,0 +1,28 @@
dist
.wrangler
.output
.vercel
.netlify
.vinxi
app.config.timestamp_*.js
# Environment
.env
.env*.local
# dependencies
/node_modules
# IDEs and editors
/.idea
.project
.classpath
*.launch
.settings/
# Temp
gitignore
# System Files
.DS_Store
Thumbs.db
+36
View File
@@ -0,0 +1,36 @@
## Usage
Those templates dependencies are maintained via [pnpm](https://pnpm.io) via `pnpm up -Lri`.
This is the reason you see a `pnpm-lock.yaml`. That being said, any package manager will work. This file can be safely be removed once you clone a template.
```bash
$ npm install # or pnpm install or yarn install
```
### Learn more on the [Solid Website](https://solidjs.com) and come chat with us on our [Discord](https://discord.com/invite/solidjs)
## Available Scripts
In the project directory, you can run:
### `npm run dev` or `npm start`
Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br>
### `npm run build`
Builds the app for production to the `dist` folder.<br>
It correctly bundles Solid in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!
## Deployment
You can deploy the `dist` folder to any static host provider (netlify, surge, now, etc.)
## This project was created with the [Solid CLI](https://github.com/solidjs-community/solid-cli)
+15
View File
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>Solid App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script src="/src/index.tsx" type="module"></script>
</body>
</html>
+2827
View File
File diff suppressed because it is too large Load Diff
+24
View File
@@ -0,0 +1,24 @@
{
"name": "vite-template-solid",
"version": "0.0.0",
"description": "",
"type": "module",
"scripts": {
"start": "vite",
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
},
"license": "MIT",
"devDependencies": {
"@tailwindcss/vite": "^4.1.13",
"solid-devtools": "^0.34.3",
"tailwindcss": "^4.1.13",
"typescript": "^5.9.2",
"vite": "^7.1.4",
"vite-plugin-solid": "^2.11.8"
},
"dependencies": {
"solid-js": "^1.9.9"
}
}
+1739
View File
File diff suppressed because it is too large Load Diff
+9
View File
@@ -0,0 +1,9 @@
import type { Component } from 'solid-js';
const App: Component = () => {
return (
<p class="text-4xl text-green-700 text-center py-20">Hello tailwind!</p>
);
};
export default App;
+1
View File
@@ -0,0 +1 @@
@import 'tailwindcss';
+16
View File
@@ -0,0 +1,16 @@
/* @refresh reload */
import './index.css';
import { render } from 'solid-js/web';
import 'solid-devtools';
import App from './App';
const root = document.getElementById('root');
if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
throw new Error(
'Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got misspelled?',
);
}
render(() => <App />, root!);
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
// General
"jsx": "preserve",
"jsxImportSource": "solid-js",
"target": "ESNext",
// Modules
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"module": "ESNext",
"moduleResolution": "bundler",
"noEmit": true,
// Type Checking & Safety
"strict": true,
"types": ["vite/client"]
}
}
+14
View File
@@ -0,0 +1,14 @@
import tailwindcss from '@tailwindcss/vite';
import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
import devtools from 'solid-devtools/vite';
export default defineConfig({
plugins: [devtools(), solidPlugin(), tailwindcss()],
server: {
port: 3000,
},
build: {
target: 'esnext',
},
});
+4
View File
@@ -2,6 +2,8 @@ module github.com/BlackChaosNL/Orchestra
go 1.26.0
require github.com/tidwall/gjson v1.18.0
require (
github.com/andybalholm/brotli v1.2.0 // indirect
github.com/gofiber/fiber/v3 v3.1.0 // indirect
@@ -13,6 +15,8 @@ require (
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/philhofer/fwd v1.2.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/tinylib/msgp v1.6.3 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.69.0 // indirect
+6 -6
View File
@@ -1,7 +1,7 @@
package main
import (
"context"
"fmt"
"log"
"os"
"os/signal"
@@ -26,9 +26,6 @@ func main() {
var wg sync.WaitGroup
golog.Install(log.New(os.Stdout, "", 0))
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()
wg.Add(2)
go api.StartAPIServer(&wg)
@@ -36,6 +33,9 @@ func main() {
wg.Wait()
<-ctx.Done()
golog.Print(context.Cause(ctx))
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
_ = <-c // Wait for signal from OS.Signal
api.StopAPIService()
fmt.Println("Gracefully shutting down...")
}