1
0

3 Commits

Author SHA1 Message Date
1b2956b437 add more tests 2024-01-20 02:14:39 +01:00
64458ca755 even more tests 2024-01-19 21:04:54 +01:00
eeea1102af working on testing 2024-01-19 00:37:29 +01:00
8 changed files with 34 additions and 32 deletions

View File

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

View File

@@ -1,21 +0,0 @@
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,6 +1,6 @@
.github/
src/
tests/
test/
.nvmrc
MIGRATION.md
tsconfig.json

View File

@@ -240,6 +240,7 @@ Key | Type | Default Value
### Supported Methods
- `router.any(url, [...handlers])`
- `router.connect(url, [...handlers])`
- `router.delete(url, [...handlers])`
- `router.get(url, [...handlers])`
- `router.head(url, [...handlers])`
@@ -247,6 +248,7 @@ Key | Type | Default Value
- `router.patch(url, [...handlers])`
- `router.post(url, [...handlers])`
- `router.put(url, [...handlers])`
- `router.trace(url, [...handlers])`
#### `url` (string)

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@tsndr/cloudflare-worker-router",
"version": "3.2.3",
"version": "3.1.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@tsndr/cloudflare-worker-router",
"version": "3.2.3",
"version": "3.1.3",
"license": "MIT",
"devDependencies": {
"@cloudflare/workers-types": "^4.20231025.0",

View File

@@ -1,12 +1,11 @@
{
"name": "@tsndr/cloudflare-worker-router",
"version": "3.2.3",
"version": "3.1.3",
"description": "",
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"build": "tsc",
"test": "jest"
"build": "tsc"
},
"repository": {
"type": "git",

View File

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

View File

@@ -175,6 +175,17 @@ export class Router<Env = any, CtxExt = {}, ReqExt = {}> {
return this
}
/**
* Register CONNECT route
*
* @param {string} url
* @param {RouterHandler[]} handlers
* @returns {Router}
*/
public connect(url: string, ...handlers: RouterHandler<Env, CtxExt, ReqExt>[]): Router<Env, CtxExt, ReqExt> {
return this.register('CONNECT', url, handlers)
}
/**
* Register DELETE route
*
@@ -252,6 +263,17 @@ export class Router<Env = any, CtxExt = {}, ReqExt = {}> {
return this.register('PUT', url, handlers)
}
/**
* Register TRACE route
*
* @param {string} url
* @param {RouterHandler[]} handlers
* @returns {Router}
*/
public trace(url: string, ...handlers: RouterHandler<Env, CtxExt, ReqExt>[]): Router<Env, CtxExt, ReqExt> {
return this.register('TRACE', url, handlers)
}
/**
* Register route, ignoring method
*