minitel-cloudflare-worker
Advanced tools
Comparing version 1.1.2 to 1.1.3
{ | ||
"name": "minitel-cloudflare-worker", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "A cloudflare worker for access through MiniPAVI", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -7,3 +7,3 @@ import { z } from 'zod'; | ||
providePavi?: boolean; | ||
provideDirectUrl?: boolean; | ||
provideUrlParams?: boolean; | ||
} | ||
@@ -49,3 +49,3 @@ | ||
providePavi: false, | ||
provideDirectUrl: false, | ||
provideUrlParams: false, | ||
...options, | ||
@@ -67,12 +67,10 @@ }; | ||
(async () => { | ||
server.accept(); | ||
const stream = new Duplex(); | ||
server.addEventListener('message', (event) => stream.write(event.data)); | ||
stream.on('data', (data) => server.send(data)); | ||
server.addEventListener('close', () => stream.end()); | ||
stream.on('close', () => server.close()); | ||
server.accept(); | ||
const stream = new Duplex(); | ||
server.addEventListener('message', (event) => stream.write(event.data)); | ||
stream.on('data', (data) => server.send(data)); | ||
server.addEventListener('close', () => stream.end()); | ||
stream.on('close', () => server.close()); | ||
server.addEventListener('open', () => minitelFactory(stream, request)); | ||
})(); | ||
setImmediate(() => minitelFactory(stream, request)); | ||
@@ -92,7 +90,7 @@ return new Response(null, { | ||
if (!success) { | ||
return new Response(`Malformed request: ${JSON.stringify(error)}`, { | ||
status: 400, | ||
}); | ||
} | ||
// if (!success) { | ||
// return new Response(`Malformed request: ${JSON.stringify(error)}`, { | ||
// status: 400, | ||
// }); | ||
// } | ||
@@ -103,5 +101,5 @@ if (reqUrl.pathname === '/') { | ||
if (fullOptions.providePavi) | ||
newParams.append('pavi', JSON.stringify(data.PAVI)); | ||
if (fullOptions.provideDirectUrl && 'DIRECTURL' in data) | ||
newParams.append('directUrl', JSON.stringify(data.DIRECTURL)); | ||
newParams.append('pavi', JSON.stringify(data?.PAVI)); | ||
if (fullOptions.provideUrlParams && 'URLPARAMS' in (data || {})) | ||
newParams.append('urlParams', JSON.stringify(data?.URLPARAMS)); | ||
@@ -108,0 +106,0 @@ return new Response( |
26028
376