Skip to content

Serve file server with single zip file as file system in Deno.

License

Notifications You must be signed in to change notification settings

hyp3rflow/zipland

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zipland

Serve file server with one-single zip file in Deno.

Support

zip

  • just zip32 with deflated or uncompressed

serving

  • plaintext
  • deflate

Examples

You can serve your zip file with just single line.

import { serveZip } from "https://deno.land/x/zipland/mod.ts";

serveZip("./my.zip");

Or you can serve the zip file in your own serve implementation.

import { serve } from "https://deno.land/std/http/mod.ts";
import {
  disassembleZip,
  serveZipFiles,
} from "https://deno.land/x/zipland/mod.ts";

const file = await Deno.open(path);
const zip = await disassembleZip(zip);
if (zip) {
  const handler = (req: Request): Promise<Response> => {
    const pathname = new URL(req.url).pathname;
    switch (pathname) {
      case "/file": {
        return serveZipFiles(req, zip, { urlRoot: "/file" });
      }
    }
    // serve other things too!
  };
  serve(handler);
}

You can see and run above example in /test directory