mirror of
https://github.com/gitroomhq/postiz-agent.git
synced 2026-09-14 13:46:24 +08:00
feat: cli fix
This commit is contained in:
+14
-1
@@ -289,7 +289,13 @@ async function handleDeviceToken(req: IncomingMessage, res: ServerResponse) {
|
||||
|
||||
// --- Server ---
|
||||
const server = createServer(async (req, res) => {
|
||||
const url = new URL(req.url || '/', SERVER_URL);
|
||||
let url: URL;
|
||||
try {
|
||||
url = new URL(req.url || '/', SERVER_URL);
|
||||
} catch {
|
||||
json(res, 400, { error: 'invalid_url' });
|
||||
return;
|
||||
}
|
||||
const method = req.method?.toUpperCase();
|
||||
|
||||
try {
|
||||
@@ -334,6 +340,13 @@ async function start() {
|
||||
});
|
||||
}
|
||||
|
||||
process.on('uncaughtException', (err) => {
|
||||
console.error('Uncaught exception:', err);
|
||||
});
|
||||
process.on('unhandledRejection', (err) => {
|
||||
console.error('Unhandled rejection:', err);
|
||||
});
|
||||
|
||||
start().catch((err) => {
|
||||
console.error('Failed to start:', err);
|
||||
process.exit(1);
|
||||
|
||||
Reference in New Issue
Block a user