Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: filenames #194

Merged
merged 7 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
68 changes: 30 additions & 38 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion example/preactSSR/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion example/preactSSR/src/pages/Home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Home = () => {
<h2 id="handlers">Handlers</h2>
<ul>
<li><a target="_blank" href="https://github.com/sebringrose/peko/blob/main/handlers/ssr.ts">Server-side render</a></li>
<li><a target="_blank" href="https://github.com/sebringrose/peko/blob/main/handlers/static.ts">Static assets</a></li>
<li><a target="_blank" href="https://github.com/sebringrose/peko/blob/main/handlers/file.ts">Static files</a></li>
<li><a target="_blank" href="https://github.com/sebringrose/peko/blob/main/handlers/sse.ts">Server-sent events</a></li>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion example/auth/app.ts → example/singleFileAuth/app.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
File renamed without changes.
11 changes: 6 additions & 5 deletions index.ts → mod.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
/**
* Featherweight HTTP routing and utils for apps on the edge.
* Featherweight apps on the edge
*/

// Core classes, functions & types
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;
4 changes: 2 additions & 2 deletions scripts/bun/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand All @@ -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,
});

Expand Down
7 changes: 6 additions & 1 deletion scripts/deno/main.ts
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion scripts/deno/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const testRouter = getTestRouter();
const abortController = new AbortController();
Deno.serve(
{
port: 7778,
port: 7777,
signal: abortController.signal,
},
(req) => testRouter.handle(req)
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/static_test.ts → tests/handlers/file_test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { assert } from "https://deno.land/[email protected]/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);
Expand Down
Loading