Skip to content

Commit 715759f

Browse files
authored
feat: restrict handler to POST /data endpoint only (#3)
* feat: restrict handler to POST /data endpoint only * chore: refactor endpoint name
1 parent 71be71c commit 715759f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ Chunk.hashFunction = (data: Uint8Array): Uint8Array => {
4545
method: request.method,
4646
url: request.url,
4747
}, 'Incoming request');
48+
49+
if (request.url !== '/upload' || request.method !== 'POST') {
50+
response.writeHead(404, { 'Content-Type': 'application/json' });
51+
response.end(JSON.stringify({ error: 'Not found' }));
52+
return;
53+
}
4854

4955
request.on('data', chunk => chunks.push(chunk))
5056

0 commit comments

Comments
 (0)