OverviewFilesCommitsIssuesDocsReleasesPeers

holepunchto-kb / skills / serve-drive / api-extract.json

73 lines · json ref:
{
  "repo": "serve-drive",
  "timestamp": "2026-01-16T23:55:51.984Z",
  "entryPoint": "index.js",
  "exports": {
    "packageJson": {
      "main": "index.js"
    }
  },
  "api": {
    "file": "index.js",
    "exports": [
      {
        "type": "default",
        "name": "class"
      }
    ],
    "classes": [
      {
        "name": "ServeDrive"
      }
    ],
    "functions": [
      {
        "name": "onclose"
      },
      {
        "name": "listen"
      },
      {
        "name": "done"
      },
      {
        "name": "nool"
      },
      {
        "name": "noop"
      },
      {
        "name": "getHost"
      },
      {
        "name": "parseURL"
      },
      {
        "name": "encodePathName"
      },
      {
        "name": "decodePathName"
      }
    ]
  },
  "readme": {
    "content": "# serve-drive\n\nHTTP drive server for entries delivery. Auto detects types like video, images, etc\n\n```\nnpm i serve-drive\n```\n\n## Usage\n\nSingle drive:\n```js\nconst ServeDrive = require('serve-drive')\nconst Localdrive = require('localdrive')\n\nconst drive = new Localdrive('./my-folder')\nawait drive.put('/index.html', Buffer.from('hi'))\n\nconst serve = new ServeDrive({ get: ({ key, filename, version }) => drive })\nawait serve.ready()\nconsole.log('Listening on http://localhost:' + serve.address().port)\n\n// Try visiting http://localhost:49833/index.html\n```\n\nMultiple drives:\n```js\nconst Localdrive = require('localdrive')\nconst Hyperdrive = require('hyperdrive')\nconst Corestore = require('corestore')\n\nconst drive1 = new Localdrive('./my-folder-a')\nconst drive2 = new Hyperdrive(new Corestore('./store1'))\n\nawait drive1.put('/index.html', Buffer.from('a'))\nawait drive2.put('/index.html', Buffer.from('b'))\n\nconst serve = new ServeDrive({\n  get ({ key, filename, version }) {\n    if (key === null) re",
    "sections": [
      "intro",
      "usage",
      "api",
      "license"
    ],
    "hasApi": true,
    "hasExamples": true,
    "exampleCount": 5,
    "examples": [
      "npm i serve-drive",
      "const ServeDrive = require('serve-drive')\nconst Localdrive = require('localdrive')\n\nconst drive = new Localdrive('./my-folder')\nawait drive.put('/index.html', Buffer.from('hi'))\n\nconst serve = new ServeDrive({ get: ({ key, filename, version }) => drive })\nawait serve.ready()\nconsole.log('Listening on http://localhost:' + serve.address().port)\n\n// Try visiting http://localhost:49833/index.html",
      "const Localdrive = require('localdrive')\nconst Hyperdrive = require('hyperdrive')\nconst Corestore = require('corestore')\n\nconst drive1 = new Localdrive('./my-folder-a')\nconst drive2 = new Hyperdrive(new Corestore('./store1'))\n\nawait drive1.put('/index.html', Buffer.from('a'))\nawait drive2.put('/index.html', Buffer.from('b'))\n\nconst serve = new ServeDrive({\n  get ({ key, filename, version }) {\n    if (key === null) return drive1 // Default\n    if (key.equals(drive2.key)) return drive2\n    return null\n  }\n})\n\nawait serve.ready()\nconsole.log('Listening on http://localhost:' + serve.address().port)\n\n// Try visiting http://localhost:49833/index.html?key=<id-or-key>"
    ]
  },
  "patterns": [
    "streaming"
  ]
}