feat: Add website v1
All checks were successful
Queue Release Build / prepare (push) Successful in 13s
Queue Release Build / build-windows (push) Successful in 36m11s
Queue Release Build / build-linux (push) Successful in 41m21s
Queue Release Build / finalize (push) Successful in 3m44s

Not final:
Needs more file icons
clean up some text
This commit is contained in:
2026-03-12 01:33:45 +01:00
parent be465fd297
commit 106212ef3d
46 changed files with 18686 additions and 0 deletions

76
website/src/server.ts Normal file
View File

@@ -0,0 +1,76 @@
import { APP_BASE_HREF } from '@angular/common';
import { CommonEngine, isMainModule } from '@angular/ssr/node';
import express from 'express';
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import bootstrap from './main.server';
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
const browserDistFolder = resolve(serverDistFolder, '../browser');
const indexHtml = join(serverDistFolder, 'index.server.html');
const app = express();
const commonEngine = new CommonEngine();
/**
* Proxy endpoint for Gitea releases API to avoid CORS issues.
*/
app.get('/api/releases', async (req, res) => {
try {
const response = await fetch('https://git.azaaxin.com/api/v1/repos/myxelium/Toju/releases', {
headers: { 'Accept': 'application/json' },
});
if (!response.ok) {
res.status(response.status).json({ error: `Upstream returned ${response.status}` });
return;
}
const data = await response.json();
res.setHeader('Cache-Control', 'public, max-age=300'); // cache 5 min
res.json(data);
} catch (err) {
console.error('Proxy fetch error:', err);
res.status(502).json({ error: 'Failed to fetch releases from upstream' });
}
});
/**
* Serve static files from /browser
*/
app.get(
'**',
express.static(browserDistFolder, {
maxAge: '1y',
index: 'index.html'
}),
);
/**
* Handle all other requests by rendering the Angular application.
*/
app.get('**', (req, res, next) => {
const { protocol, originalUrl, baseUrl, headers } = req;
commonEngine
.render({
bootstrap,
documentFilePath: indexHtml,
url: `${protocol}://${headers.host}${originalUrl}`,
publicPath: browserDistFolder,
providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }],
})
.then((html) => res.send(html))
.catch((err) => next(err));
});
/**
* Start the server if this module is the main entry point.
* The server listens on the port defined by the `PORT` environment variable, or defaults to 4000.
*/
if (isMainModule(import.meta.url)) {
const port = process.env['PORT'] || 4000;
app.listen(port, () => {
console.log(`Node Express server listening on http://localhost:${port}`);
});
}
export default app;