Socket
Socket
Sign inDemoInstall

cloudserve

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cloudserve

Run small websites embedded in a Cloudflare Worker.


Version published
Maintainers
1
Created

Readme

Source

cloudserve

Run small websites embedded in a Cloudflare Worker.

Install

Globally:

npm install -g cloudserve

Per-project:

npm install cloudserve

Usage

cloudserve can either be run manually or as part of a Wrangler build command.

Manually:

cloudserve ./path/to/website ./manifest.ts

With Wrangler (add to your existing wrangler.toml file):

[build]
command = "cloudserve ./path/to/website ./manifest.ts"

An example Worker that uses the created manifest and serves static files, falling back to 404 if not found:

import { __STATIC_FILES } from "./manifest";
import { lookupStaticAsset } from "cloudserve";

export default {
	async fetch(req: Request, _: never, __: never) {
		const file = lookupStaticAsset(req, __STATIC_FILES);
		if (file != null) {
			return file;
		}

		return lookupStaticAsset(req, __STATIC_FILES, {
			overridePath: "/404.html",
		});
	},
};

FAQs

Last updated on 25 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc