@jackdbd/hosting-utils
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@jackdbd/hosting-utils

Utilities for working with the configuration files of various hosting providers.

Installation

npm install @jackdbd/hosting-utils

Note: this library was tested on Node.js >=18. It might work on other Node.js versions though.

Usage

Let's say that you are hosting your Eleventy site on Vercel and that you want to programmatically add a Content-Security-Policy header to a bunch of routes. You could do something like this:

import { updateVercelJSON } from '@jackdbd/hosting-utils'

await updateVercelJSON({
  headerKey: 'Content-Security-Policy',
  headerValue: "default-src 'self'; img-src 'self' cdn.example.com;",
  filepath: '_site/vercel.json',
  sources: ['/(404|index).html', '/posts/**/*.html']
})

Configuration

Read these resources to understand how to configure _headers, serve.json, vercel.json.

Troubleshooting

This plugin uses the debug library for logging. You can control what's logged using the DEBUG environment variable.

For example, if you set your environment variables in a .envrc file, you can do:

# print all logging statements
export DEBUG=hosting-utils:*

Dependencies

Package Version
netlify-headers-parser ^7.1.4
proper-lockfile ^4.1.2

⚠️ Peer Dependencies

This package defines 1 peer dependency.

Peer Version range
debug >=4.0.0

License

© 2022 - 2024 Giacomo Debidda // MIT License

Package Sidebar

Install

npm i @jackdbd/hosting-utils

Weekly Downloads

19

Version

1.0.0

License

MIT

Unpacked Size

30.3 kB

Total Files

24

Last publish

Collaborators

  • jackdbd