Skip to content

Commit 081338d

Browse files
committed
Added selfhosted downloads
1 parent 0e1380b commit 081338d

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

frontend/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
},
4242
"dependencies": {
4343
"@carbon/charts-svelte": "^1.22.3",
44-
"echarts": "^5.5.1"
44+
"echarts": "^5.5.1",
45+
"toml": "^3.0.0"
4546
}
4647
}

frontend/src/lib/loadConfig.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import toml from 'toml';
4+
import os from 'os';
5+
6+
const CONFIG_PATH = path.join(os.homedir(), '.config/appgoblin/config.toml');
7+
8+
export default function loadConfig() {
9+
try {
10+
const configContent = fs.readFileSync(CONFIG_PATH, 'utf-8');
11+
const parsedConfig = toml.parse(configContent);
12+
return parsedConfig.cloud?.adstxt_endpoint || null;
13+
} catch (error) {
14+
console.error('Failed to load config:', error);
15+
return null;
16+
}
17+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { RequestHandler } from '@sveltejs/kit';
2+
import loadConfig from '$lib/loadConfig.js';
3+
4+
export const GET: RequestHandler = async ({ params }) => {
5+
const domain = params.domain || '';
6+
const adstxtEndpoint = loadConfig();
7+
8+
return new Response(null, {
9+
status: 302,
10+
headers: {
11+
Location: `${adstxtEndpoint}${domain}/latest.csv`
12+
}
13+
});
14+
};

0 commit comments

Comments
 (0)