Skip to content

Commit

Permalink
Project update. [p][robotic]
Browse files Browse the repository at this point in the history
  • Loading branch information
jaswrks committed Aug 28, 2023
1 parent ae8abc0 commit 90f0c63
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 82 deletions.
1 change: 1 addition & 0 deletions dev/.files/eslint/config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const baseConfig = {
args: 'after-used',
caughtErrors: 'none',
ignoreRestSiblings: false,
argsIgnorePattern: '^unusedꓺ',
varsIgnorePattern: '^unusedꓺ',
caughtErrorsIgnorePattern: '^unusedꓺ',
destructuredArrayIgnorePattern: '^unusedꓺ',
Expand Down
8 changes: 6 additions & 2 deletions dev/.files/vite/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -525,18 +525,22 @@ export default async ({ mode, command, ssrBuild: isSSRBuild }) => {
exclude: vitestExcludes,
watchExclude: vitestExcludes,

restoreMocks: true, // Remove all mocks before a test begins.
unstubEnvs: true, // Remove all env stubs before a test begins.
unstubGlobals: true, // Remove all global stubs before a test begins.

// @todo Enhance web worker support.
// @todo Fix and enhance miniflare support.
environment: ['cfp', 'web', 'webw'].includes(targetEnv) ? 'jsdom' // <https://o5p.me/Gf9Cy5>.
: ['cfw'].includes(targetEnv) ? 'miniflare' // <https://o5p.me/TyF9Ot>.
: ['node'].includes(targetEnv) ? 'node' // <https://o5p.me/Gf9Cy5>.
: ['node', 'any'].includes(targetEnv) ? 'node' // <https://o5p.me/Gf9Cy5>.
: 'node', // prettier-ignore

// See: <https://o5p.me/8Pjw1d> for `environment`, `environmentMatchGlobs` precedence.
environmentMatchGlobs: [
['**/*.{cfp,web,webw}.{test,tests,spec,specs}.{' + vitestExtensions.map((e) => e.slice(1)).join(',') + '}', 'jsdom'],
['**/*.cfw.{test,tests,spec,specs}.{' + vitestExtensions.map((e) => e.slice(1)).join(',') + '}', 'miniflare'],
['**/*.node.{test,tests,spec,specs}.{' + vitestExtensions.map((e) => e.slice(1)).join(',') + '}', 'node'],
['**/*.{node,any}.{test,tests,spec,specs}.{' + vitestExtensions.map((e) => e.slice(1)).join(',') + '}', 'node'],
],
server: { deps: { external: ['**/dist/**', '**/node_modules/**'].concat(rollupConfig.external) } },
cache: { dir: path.resolve(projDir, './node_modules/.vitest') },
Expand Down
132 changes: 66 additions & 66 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.0.84",
"version": "1.0.85",
"license": "GPL-3.0-or-later",
"name": "@clevercanyon/utilities.cfw",
"description": "Utilities for JavaScript apps running in a Cloudflare Worker environment.",
Expand Down Expand Up @@ -50,7 +50,7 @@
},
"dependencies": {},
"peerDependencies": {
"@clevercanyon/utilities": "^1.0.205",
"@clevercanyon/utilities": "^1.0.208",
"@cloudflare/kv-asset-handler": "^0.2.0"
},
"peerDependenciesMeta": {},
Expand Down
24 changes: 12 additions & 12 deletions src/cfw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,30 @@ export const handleFetchEvent = async (ifeData: InitialFetchEventData): Promise<
let url: core.URL | null = null;
const { env, ctx, routes } = ifeData;

$env.capture('@global', env);
$env.capture('@global', env); // Captures environment vars.

const basePath = $env.get('@top', 'APP_BASE_PATH', '') as string;
const basePath = String($env.get('@top', 'APP_BASE_PATH', ''));

try {
request = $http.prepareRequest(request, {}) as core.Request;
url = $url.parse(request.url) as core.URL;

const feData = { request, env, ctx, routes, url }; // Recompiles data.
if (
$http.requestPathIsStatic(request, url) && //
$env.get('@top', '__STATIC_CONTENT' /* Worker site? */) &&
$str.matches(url.pathname, basePath + '/assets/**')
) {
return handleFetchStaticAssets(feData);
}
return handleFetchDynamics(feData);
//
} catch (error) {
if (error instanceof Response) {
return error as unknown as core.Response;
}
return $http.prepareResponse(request, { status: 500 }) as core.Response;
}
const feData = { request, env, ctx, routes, url }; // Recompiles data.

if (
$http.requestPathIsStatic(request, url) && //
$env.get('@top', '__STATIC_CONTENT' /* Worker site? */) &&
$str.matches(url.pathname, basePath + '/assets/**')
) {
return handleFetchStaticAssets(feData);
}
return handleFetchDynamics(feData);
};

/**
Expand Down

0 comments on commit 90f0c63

Please sign in to comment.