feat: init proj

This commit is contained in:
2026-03-31 13:11:54 +08:00
commit 8f75ea24d6
38 changed files with 6826 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import { Router } from 'express';
import { generateSurgeConfig } from '../services/generator.js';
const router = Router();
// GET /surge - Surge client subscription endpoint (no auth required)
router.get('/', (req, res) => {
const host = req.headers.host || 'localhost:3456';
const protocol = req.secure ? 'https' : 'http';
const hostUrl = `${protocol}://${host}/surge`;
const config = generateSurgeConfig(hostUrl);
res.set({
'Content-Type': 'text/plain; charset=utf-8',
'Content-Disposition': 'attachment; filename=sub-router.conf',
});
res.send(config);
});
// GET /api/config/preview - preview generated config
router.get('/preview', (req, res) => {
const host = req.headers.host || 'localhost:3456';
const protocol = req.secure ? 'https' : 'http';
const hostUrl = `${protocol}://${host}/surge`;
const config = generateSurgeConfig(hostUrl);
res.json({ config });
});
export default router;