-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod.ts
39 lines (31 loc) · 1004 Bytes
/
mod.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { toFileUrl } from "https://deno.land/[email protected]/path/mod.ts"
import { Untar } from "https://deno.land/[email protected]/archive/untar.ts"
import {
readerFromStreamReader,
readableStreamFromReader,
} from "https://deno.land/[email protected]/streams/mod.ts"
const readableStream = await fetch(
"https://github.com/dalkak2/dotent-js/raw/main/test/1.ent"
).then(res => res.body)!
const decompressedReadableStream = readableStream!.pipeThrough(
new DecompressionStream("gzip")
)
const streamReader = decompressedReadableStream.getReader()
const untar = new Untar(readerFromStreamReader(streamReader))
let result: ReadableStream
for await (const entry of untar) {
console.log(entry.fileName)
if (entry.fileName.endsWith("/project.json")) {
result = readableStreamFromReader(entry)
break
}
}
Deno.serve(
req => {
return new Response(result, {
headers: {
"content-type": "application/json"
}
})
}
)