From b2f71c291e6aae47a885f4019ba7ce0fd08fef20 Mon Sep 17 00:00:00 2001 From: Taylor Beseda Date: Wed, 28 Feb 2024 16:28:42 -0700 Subject: [PATCH] shoveling --- .github/workflows/CI.yml | 2 +- package.json | 24 ++++++++++++++---------- src/http/any-catchall/index.mjs | 31 ++++++++++++++++++++++++++----- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d996f93..9e3a86f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,7 +1,7 @@ name: Node CI # Push tests commits; pull_request tests PR merges -on: [ push, pull_request ] +on: [ ] defaults: run: diff --git a/package.json b/package.json index 3902894..a59b3b7 100644 --- a/package.json +++ b/package.json @@ -32,30 +32,34 @@ ".arc" ], "dependencies": { - "@architect/asap": "^7.0.4", - "@architect/functions": "^8.0.1", - "@begin/data": "^5.0.1", + "@architect/asap": "^7.0.7", + "@architect/functions": "^8.0.4", + "@begin/data": "^5.0.3", "@enhance/arc-plugin-rollup": "^2.0.0", "@enhance/arc-plugin-styles": "^5.0.5", - "@enhance/core": "^0.0.3-RC.1", + "@enhance/core": "alpha", "@enhance/enhance-style-transform": "^0.1.2", "@enhance/import-transform": "^4.0.1", - "@enhance/loader": "^0.0.1-RC.2", - "@enhance/ssr": "^3.5.1", + "@enhance/loader": "alpha", + "@enhance/ssr": "^3.5.2", "glob": "^9.3.5", - "header-timers": "^0.2.0", + "header-timers": "^0.2.1", "path-to-regexp": "^6.2.1" }, "devDependencies": { "@architect/eslint-config": "^2.1.2", - "@architect/sandbox": "^6.0.1", - "eslint": "^8.56.0", + "@architect/sandbox": "^6.0.2", + "eslint": "^8.57.0", "tap-arc": "^1.2.2", - "tape": "^5.7.4", + "tape": "^5.7.5", "tiny-json-http": "^7.5.1" }, "eslintConfig": { "extends": "@architect/eslint-config", + "parserOptions": { + "sourceType": "module", + "ecmaVersion": 2022 + }, "overrides": [ { "files": [ diff --git a/src/http/any-catchall/index.mjs b/src/http/any-catchall/index.mjs index d16a515..f022587 100644 --- a/src/http/any-catchall/index.mjs +++ b/src/http/any-catchall/index.mjs @@ -1,7 +1,15 @@ import path from 'node:path' import url from 'node:url' + import arc from '@architect/functions' -import router from './router.mjs' +import loader from '@enhance/loader' +import core from '@enhance/core' +import importTransform from '@enhance/import-transform' +import styleTransform from '@enhance/enhance-style-transform' + +import { getState, head, preflight, postflight } from './helpers.mjs' + +const DEBUG = 1 const here = path.dirname(url.fileURLToPath(import.meta.url)) // SOMEDAY: import.meta.dirname const basePath = path.join(here, 'node_modules', '@architect', 'views') @@ -15,10 +23,23 @@ const basePath = path.join(here, 'node_modules', '@architect', 'views') // "Core" routeAndRender // post-route: fingerprint paths + merge headers -export function createRouter (base) { - base = base || basePath +let config = await loader({ basePath }) + +export async function createRouter (base) { + if (base) config = await loader({ basePath: base }) + + const app = core({ + ...config, + ssrOptions: { + scriptTransforms: [ importTransform({ lookup: arc.static }) ], + styleTransforms: [ styleTransform ], + }, + state: getState(), + head, + debug: DEBUG > 0, + }) - // return arc.http(router.bind({}, { basePath: base })) + return app } -export const handler = routeAndRender() +export const handler = (await createRouter()).routeAndRender