Diplodocus

Table of contents

Diplodocus

Diplodocus is Static Assets Serving System only for Deno Deploy.

"Diplodocus" sounds like "Deploy docs" a little...?

Quick start

Create docs directly and some markdown pages.

├── docs/
│  ├── about.md
│  ├── index.md
│  └── pages/
│     ├── 01.md
│     ├── 02.md
│     └── 03.md
└── server.ts

Add links in index.md.

# index
- [about](/about)
- [page 01](/page/01)
- [page 02](/page/02)
- [page 03](/page/03)

Create server.ts. This is almost same as a sample script of Deno Deploy Beta 2.

// server.ts
import { Diplodocus } from "https://deno.land/x/diplodocus/mod.ts";

const diplodocus = await Diplodocus.load();

const port = 8080;
const listener = Deno.listen({ port });
console.log(`HTTP server listening on http://localhost:${port}`);

async function handleConn(conn: Deno.Conn) {
  const httpConn = Deno.serveHttp(conn);
  for await (const e of httpConn) {
    e.respondWith(diplodocus.handler(e.request));
  }
}

for await (const conn of listener) {
  handleConn(conn);
}

Run server.ts by deno run or deployctl and access to the local server.

$ deno run --allow-net --allow-read --no-check ./server.ts
$ # deplyctl run --no-check ./server.ts