diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml
index 77180fcd..7c89bf12 100644
--- a/.github/workflows/CD.yml
+++ b/.github/workflows/CD.yml
@@ -16,13 +16,16 @@ permissions:
contents: read
jobs:
- deploy-cfw:
+ deploy-cloudflare-worker:
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
+ - name: setup pnpm
+ run: npm install -g pnpm
+
- name: Setup Wrangler
uses: cloudflare/wrangler-action@v3
with:
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index 8e5dccb7..2ce9fe76 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -25,69 +25,61 @@ jobs:
- name: setup repo
uses: actions/checkout@v3
+ - name: setup pnpm
+ run: npm install -g pnpm
+
+ - name: setup packages
+ run: pnpm install
+
- name: setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Run profile
- run: deno task profile
+ run: pnpm profile:deno
- unit-test-deno:
+ profile-bun:
runs-on: ubuntu-latest
steps:
- name: setup repo
uses: actions/checkout@v3
- - name: setup Deno
- uses: denoland/setup-deno@v1
- with:
- deno-version: v1.x
-
- # - name: Verify formatting
- # run: deno fmt --check
-
- - name: run linter
- run: deno lint
-
- - name: run tests
- run: deno task test
-
- test-run-bun:
- runs-on: ubuntu-latest
+ - name: setup pnpm
+ run: npm install -g pnpm
- steps:
- - name: setup repo
- uses: actions/checkout@v3
+ - name: setup packages
+ run: pnpm install
- - name: setup Bun.sh
+ - name: setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- - name: bun intall
- run: bun install
-
- - name: bun run
- run: npm run test:bun
- after_script:
- - pkill bun
+ - name: Run profile
+ run: pnpm profile:bun
- test-run-wrangler:
+ unit-test-deno:
runs-on: ubuntu-latest
steps:
- name: setup repo
uses: actions/checkout@v3
- - name: npm intall
- run: npm install
+ - name: setup pnpm
+ run: npm install -g pnpm
- - name: setup Wrangler
- run: npm install -g wrangler
+ - name: setup Deno
+ uses: denoland/setup-deno@v1
+ with:
+ deno-version: v1.x
+
+ # - name: Verify formatting
+ # run: deno fmt --check
- - name: wrangler dev
- run: npm run test:cfw
- after_script:
- - pkill node
+ - name: run linter
+ run: deno lint
+
+ - name: run tests
+ run: pnpm test
diff --git a/example/preactSSR/router.ts b/example/preactSSR/router.ts
index 084b9db9..f75fb50e 100644
--- a/example/preactSSR/router.ts
+++ b/example/preactSSR/router.ts
@@ -6,7 +6,7 @@ import {
cacher,
ssr,
file,
-} from "../../index.ts"; //"https://deno.land/x/peko/mod.ts"
+} from "../../mod.ts"; //"https://deno.land/x/peko/mod.ts"
import { renderToString } from "preact-render-to-string";
// Preact page components and HTML template for ssrHandler render logic
diff --git a/example/preactSSR/src/pages/Home.ts b/example/preactSSR/src/pages/Home.ts
index ada1fbf7..4c4aac9d 100644
--- a/example/preactSSR/src/pages/Home.ts
+++ b/example/preactSSR/src/pages/Home.ts
@@ -24,7 +24,7 @@ const Home = () => {
Handlers
diff --git a/example/auth/app.ts b/example/singleFileAuth/app.ts
similarity index 98%
rename from example/auth/app.ts
rename to example/singleFileAuth/app.ts
index 903b931d..9d38166a 100644
--- a/example/auth/app.ts
+++ b/example/singleFileAuth/app.ts
@@ -1,4 +1,4 @@
-import * as Peko from "../../index.ts"; // "https://deno.land/x/peko/mod.ts"
+import * as Peko from "../../mod.ts"; // "https://deno.land/x/peko/mod.ts"
const html = String;
const router = new Peko.Router();
diff --git a/lib/handlers/static.ts b/lib/handlers/file.ts
similarity index 100%
rename from lib/handlers/static.ts
rename to lib/handlers/file.ts
diff --git a/index.ts b/mod.ts
similarity index 83%
rename from index.ts
rename to mod.ts
index e265fa71..e0d89e4d 100644
--- a/index.ts
+++ b/mod.ts
@@ -1,5 +1,5 @@
/**
- * Featherweight HTTP routing and utils for apps on the edge.
+ * Featherweight apps on the edge
*/
// Core classes, functions & types
@@ -7,20 +7,21 @@ export * from "./lib/Router.ts";
export * from "./lib/types.ts";
// Handlers
-export * from "./lib/handlers/static.ts";
-export * from "./lib/handlers/ssr.ts";
+export * from "./lib/handlers/file.ts";
export * from "./lib/handlers/sse.ts";
+export * from "./lib/handlers/ssr.ts";
// Middlewares
-export * from "./lib/middleware/logger.ts";
-export * from "./lib/middleware/cacher.ts";
export * from "./lib/middleware/authenticator.ts";
+export * from "./lib/middleware/cacher.ts";
+export * from "./lib/middleware/logger.ts";
// Utils
export * from "./lib/utils/CacheItem.ts";
export * from "./lib/utils/Cascade.ts";
export * from "./lib/utils/Crypto.ts";
export * from "./lib/utils/helpers.ts";
+export * from "./lib/utils/Profiler.ts";
import { Router } from "./lib/Router.ts";
export default Router;
diff --git a/scripts/bun/profile.ts b/scripts/bun/profile.ts
index 4a2c6fc9..eade3a18 100644
--- a/scripts/bun/profile.ts
+++ b/scripts/bun/profile.ts
@@ -3,7 +3,7 @@ import { getTestRouter } from "../../tests/mocks/middleware.ts";
const testRouter = getTestRouter();
const server = Bun.serve({
- port: 9797,
+ port: 8080,
fetch(req) {
return testRouter.handle(req);
},
@@ -15,7 +15,7 @@ const handleResults = await Profiler.run(testRouter, {
});
const serveResults = await Profiler.run(testRouter, {
mode: "serve",
- url: "http://localhost:7777",
+ url: "http://localhost:8080",
count: 100,
});
diff --git a/scripts/deno/main.ts b/scripts/deno/main.ts
index 4958904f..d2e897e9 100644
--- a/scripts/deno/main.ts
+++ b/scripts/deno/main.ts
@@ -1,6 +1,11 @@
import router from "../../example/preactSSR/router.ts";
// Start Deno server with Peko router :^)
-Deno.serve((req) => router.handle(req));
+Deno.serve(
+ {
+ port: 7777,
+ },
+ (req) => router.handle(req)
+);
console.log("Deno server running with Peko router <3");
diff --git a/scripts/deno/profile.ts b/scripts/deno/profile.ts
index 0b360685..9f388fce 100644
--- a/scripts/deno/profile.ts
+++ b/scripts/deno/profile.ts
@@ -5,7 +5,7 @@ const testRouter = getTestRouter();
const abortController = new AbortController();
Deno.serve(
{
- port: 7778,
+ port: 7777,
signal: abortController.signal,
},
(req) => testRouter.handle(req)
diff --git a/tests/handlers/static_test.ts b/tests/handlers/file_test.ts
similarity index 96%
rename from tests/handlers/static_test.ts
rename to tests/handlers/file_test.ts
index fa11e390..4e0b7d74 100644
--- a/tests/handlers/static_test.ts
+++ b/tests/handlers/file_test.ts
@@ -1,8 +1,8 @@
import { assert } from "https://deno.land/std@0.218.0/assert/mod.ts";
import { Router, RequestContext } from "../../lib/Router.ts";
-import { file } from "../../lib/handlers/static.ts";
+import { file } from "../../lib/handlers/file.ts";
-Deno.test("HANDLER: Static", async (t) => {
+Deno.test("HANDLER: File", async (t) => {
const server = new Router();
const ctx = new RequestContext(server, new Request("http://localhost"));
const fileURL = new URL(import.meta.url);