cfw icon indicating copy to clipboard operation
cfw copied to clipboard

feat: add dotenv

Open licitdev opened this issue 2 years ago • 0 comments

Allow dynamic import of environment variables through a .env file.

Improves the quality of life when populating environment variables locally.

Example cfw.js

module.exports = {
	name: 'worker',
	profile: 'default',
	entry: 'index.ts',
	routes: process.env.WORKER_ROUTES.split(',').filter((route) => route),
	globals: {
		KV_STORE: `KV:${KV_STORE}`,
		SOME_ENV_VAR: `ENV:${process.env.SOME_ENV_VAR}`,
		SOME_SECRET: `SECRET:${process.env.SOME_SECRET}`,
	},
};

Example .env

WORKER_ROUTES=https://a.com/*,b.com/*
KV_STORE=abcd1234abcd1234abcd1234abcd1234
SOME_ENV_VAR=somevalue
SOME_SECRET=shhhhhhh

licitdev avatar May 22 '22 16:05 licitdev