release: v0.5.1 — 存储后端生产级硬化(CRC-32/全库加密/WAL分片/页面化存储/多标签页锁/e2e)+ 深度审查修复(假实现接线/死代码清理)
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* MetonaSqlark E2E 静态文件服务器(Playwright webServer 用)
|
||||
* 与 MetonaEditor 的 e2e 服务模式保持一致:Node http 静态服务,不依赖 python3。
|
||||
* 用法: node tests/e2e/server.cjs [port]
|
||||
*/
|
||||
const http = require('http');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const ROOT = path.resolve(__dirname, '..', '..');
|
||||
const PORT = Number(process.argv[2] || process.env.E2E_PORT || 3344);
|
||||
|
||||
const MIME = {
|
||||
'.html': 'text/html; charset=utf-8',
|
||||
'.js': 'text/javascript',
|
||||
'.mjs': 'text/javascript',
|
||||
'.cjs': 'text/javascript',
|
||||
'.css': 'text/css',
|
||||
'.json': 'application/json',
|
||||
'.svg': 'image/svg+xml',
|
||||
'.png': 'image/png',
|
||||
};
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
let p = decodeURIComponent((req.url || '/').split('?')[0]);
|
||||
// 根路径指向 e2e harness(playwright webServer 探测要求 2xx/3xx)
|
||||
if (p === '/') p = '/tests/e2e/harness.html';
|
||||
const file = path.resolve(ROOT, '.' + p);
|
||||
if (!file.startsWith(ROOT) || !fs.existsSync(file) || !fs.statSync(file).isFile()) {
|
||||
res.writeHead(404); res.end('404 Not Found'); return;
|
||||
}
|
||||
res.writeHead(200, { 'Content-Type': MIME[path.extname(file)] || 'text/plain' });
|
||||
fs.createReadStream(file).pipe(res);
|
||||
});
|
||||
|
||||
server.listen(PORT, '127.0.0.1', () => {
|
||||
console.log(`E2E server · http://127.0.0.1:${PORT}/`);
|
||||
});
|
||||
Reference in New Issue
Block a user