@jakechampion/c-at-e-file-server

0.0.2-main • Public • Published

c-at-e-file-server

JavaScript library used to serve files from Fastly Object Store.

It is ideal for serving files built from a static site generator such as 11ty.

Install

npm

npm install c-at-e-file-server

API

get(store_name, request)

Retrieve a file from a Fastly Object Store.

Returns: response or null

store_name

Type: string

The name of the Fastly Object Store to search within.

request

Type: request

The request to search for a corresponding response for.

Important:

  • If the request path ends in /, then index.html is appended to the path when searching the Object Store
  • If the request path does not have an extension, then index.html is appended to the path when searching the Object Store
import { get } from "c-at-e-file-server";

async function app(event) {
  const response = await get('site', request);
  if (response) {
    return response
  } else {
    return new Response(null, { status: 404 });
  }
}

addEventListener("fetch", event => event.respondWith(app(event)));

Readme

Keywords

none

Package Sidebar

Install

npm i @jakechampion/c-at-e-file-server

Weekly Downloads

0

Version

0.0.2-main

License

MIT

Unpacked Size

16.9 kB

Total Files

4

Last publish

Collaborators

  • jakechampion