1
0

18 Commits

Author SHA1 Message Date
fd7dce7256 3.2.5 2024-09-28 01:53:00 +02:00
1d72a15ca6 update readme 2024-09-28 01:51:05 +02:00
a740f1b103 audit fix 2024-07-15 22:14:32 +02:00
21dc38b676 update keywords 2024-02-24 21:03:35 +01:00
9df19a50cd change to module 2024-02-24 20:59:03 +01:00
7dce99214d switch to vitest 2024-02-24 20:55:23 +01:00
5aedc0248d 3.2.4 2024-01-20 23:39:07 +01:00
3aecc4ca5f update npmignore 2024-01-20 23:38:58 +01:00
e04bcfb395 3.2.3 2024-01-20 23:32:28 +01:00
f2ba5f5bc5 update npmignore 2024-01-20 23:32:17 +01:00
306c046adb update test 2024-01-20 02:49:45 +01:00
2dab64be19 rename job 2024-01-20 02:37:12 +01:00
175deddc9c fix import 2024-01-20 02:36:32 +01:00
ff638ad04f add testing github action 2024-01-20 02:35:06 +01:00
b118c28dc7 3.2.2 2024-01-20 02:28:22 +01:00
9451f466fc move test file to tests directory 2024-01-20 02:27:50 +01:00
71fcd6c3c0 3.2.1 2024-01-20 02:25:07 +01:00
e55392d890 remove connect and trace method 2024-01-20 02:24:38 +01:00
11 changed files with 1178 additions and 3420 deletions

View File

@@ -11,3 +11,7 @@ indent_style = tab
[README.md] [README.md]
indent_style = space indent_style = space
indent_size = 4 indent_size = 4
[{package,package-lock}.json]
indent_style = space
indent_size = 2

View File

@@ -1,8 +1,8 @@
name: Publish (main) name: Publish
on: on:
release: release:
types: [published] types: [ published ]
jobs: jobs:
publish: publish:

21
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: latest
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test

View File

@@ -1,7 +1,10 @@
.github/
src/
test/
.nvmrc
MIGRATION.md
tsconfig.json
.editorconfig .editorconfig
.github/
.gitignore
.nvmrc
coverage/
jest.config.ts
MIGRATION.md
src/
tests/
tsconfig.json

View File

@@ -4,8 +4,6 @@ Cloudflare Workers Router is a super lightweight router (1.0K gzipped) with midd
When I was trying out Cloudflare Workers I almost immediately noticed how fast it was compared to other serverless offerings. So I wanted to build a full-fledged API to see how it performs doing real work, but since I wasn't able to find a router that suited my needs I created my own. When I was trying out Cloudflare Workers I almost immediately noticed how fast it was compared to other serverless offerings. So I wanted to build a full-fledged API to see how it performs doing real work, but since I wasn't able to find a router that suited my needs I created my own.
I worked a lot with [Express.js](https://expressjs.com/) in the past and really enjoyed their middleware approach, but since none of the available Cloudflare Worker routers offered middleware support at the time, I felt the need to create this router.
## Contents ## Contents
@@ -240,7 +238,6 @@ Key | Type | Default Value
### Supported Methods ### Supported Methods
- `router.any(url, [...handlers])` - `router.any(url, [...handlers])`
- `router.connect(url, [...handlers])`
- `router.delete(url, [...handlers])` - `router.delete(url, [...handlers])`
- `router.get(url, [...handlers])` - `router.get(url, [...handlers])`
- `router.head(url, [...handlers])` - `router.head(url, [...handlers])`
@@ -248,7 +245,6 @@ Key | Type | Default Value
- `router.patch(url, [...handlers])` - `router.patch(url, [...handlers])`
- `router.post(url, [...handlers])` - `router.post(url, [...handlers])`
- `router.put(url, [...handlers])` - `router.put(url, [...handlers])`
- `router.trace(url, [...handlers])`
#### `url` (string) #### `url` (string)
@@ -296,7 +292,7 @@ wrangler init <name>
Use of TypeScript is strongly encouraged :) Use of TypeScript is strongly encouraged :)
```bash ```bash
npm i -D @tsndr/cloudflare-worker-router npm i @tsndr/cloudflare-worker-router
``` ```

View File

@@ -1,9 +0,0 @@
import type { Config } from 'jest'
const config: Config = {
preset: 'ts-jest',
testEnvironment: 'node',
verbose: true
}
export default config

4503
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,23 +1,23 @@
{ {
"name": "@tsndr/cloudflare-worker-router", "name": "@tsndr/cloudflare-worker-router",
"version": "3.2.0", "version": "3.2.5",
"description": "", "description": "",
"main": "index.js", "type": "module",
"exports": "./index.js",
"types": "index.d.ts", "types": "index.d.ts",
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"test": "jest" "test": "vitest"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/tsndr/cloudflare-worker-router.git" "url": "git+https://github.com/tsndr/cloudflare-worker-router.git"
}, },
"keywords": [ "keywords": [
"api",
"cloudflare", "cloudflare",
"cloudflare-worker", "cloudflare-worker",
"cloudflare-workers", "cloudflare-workers",
"express",
"expressjs",
"framework", "framework",
"middleware", "middleware",
"router", "router",
@@ -32,12 +32,9 @@
}, },
"homepage": "https://github.com/tsndr/cloudflare-worker-router#readme", "homepage": "https://github.com/tsndr/cloudflare-worker-router#readme",
"devDependencies": { "devDependencies": {
"@cloudflare/workers-types": "^4.20231025.0", "@cloudflare/workers-types": "^4.20240222.0",
"@jest/globals": "^29.7.0", "@edge-runtime/vm": "^3.2.0",
"@types/jest": "^29.5.11", "typescript": "^5.3.3",
"jest": "^29.7.0", "vitest": "^1.3.1"
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"typescript": "^5.2.2"
} }
} }

View File

@@ -1,5 +1,5 @@
import { describe, expect, test } from '@jest/globals' import { describe, expect, test } from 'vitest'
import { Router } from '.' import { Router } from '../src/index'
describe('Router', () => { describe('Router', () => {
test('use', async () => { test('use', async () => {

9
vite.config.ts Normal file
View File

@@ -0,0 +1,9 @@
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
environment: 'edge-runtime',
reporters: ['verbose'],
watch: false
}
})