Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cloudflare/chanfana
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.13
Choose a base ref
...
head repository: cloudflare/chanfana
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Loading
Showing with 18,964 additions and 10,814 deletions.
  1. +0 −3 .editorconfig
  2. +0 −5 .eslintignore
  3. +0 −13 .eslintrc.js
  4. +17 −0 .github/dependabot.yml
  5. +47 −0 .github/workflows/create-pullrequest-prerelease.yml
  6. +13 −24 .github/workflows/publish.yml
  7. +24 −0 .github/workflows/semgrep.yml
  8. +12 −33 .github/workflows/test.yml
  9. +3 −1 .gitignore
  10. +0 −5 .husky/commit-msg
  11. +0 −8 .husky/common.sh
  12. +2 −6 .husky/pre-commit
  13. 0 .prettierignore
  14. +0 −7 .prettierrc.js
  15. +63 −0 .vitepress/config.mts
  16. +1 −1 LICENSE
  17. +66 −524 README.md
  18. +46 −0 biome.json
  19. +0 −1 commitlint.config.js
  20. +0 −9 config/fileTransformer.js
  21. +0 −18 config/preparePublish.js
  22. +0 −7 config/tsconfig.cjs.json
  23. +0 −7 config/tsconfig.esm.json
  24. +0 −8 config/tsconfig.types.json
  25. +0 −7 config/tsconfig.umd.json
  26. +0 −30 config/webpack.config.js
  27. +354 −0 docs/advanced-topics-patterns.md
  28. +96 −0 docs/core-concepts.md
  29. +310 −0 docs/endpoints/auto/base.md
  30. +295 −0 docs/endpoints/auto/d1.md
  31. +273 −0 docs/endpoints/defining-endpoints.md
  32. +420 −0 docs/endpoints/parameters.md
  33. +242 −0 docs/endpoints/request-validation.md
  34. +251 −0 docs/endpoints/response-definition.md
  35. +376 −0 docs/error-handling.md
  36. +325 −0 docs/examples-and-recipes.md
  37. +232 −0 docs/getting-started.md
  38. BIN docs/images/logo-icon.png
  39. BIN docs/images/logo-square.png
  40. BIN docs/images/logo.png
  41. +36 −0 docs/index.md
  42. +55 −0 docs/introduction.md
  43. +183 −0 docs/openapi-configuration-customization.md
  44. +200 −0 docs/router-adapters.md
  45. +133 −0 docs/troubleshooting-and-faq.md
  46. +0 −14 jest.config.js
  47. +11,195 −9,052 package-lock.json
  48. +42 −51 package.json
  49. +170 −0 src/adapters/hono.ts
  50. +67 −0 src/adapters/ittyRouter.ts
  51. +20 −0 src/contentTypes.ts
  52. +85 −0 src/endpoints/create.ts
  53. +53 −0 src/endpoints/d1/create.ts
  54. +78 −0 src/endpoints/d1/delete.ts
  55. +76 −0 src/endpoints/d1/list.ts
  56. +36 −0 src/endpoints/d1/read.ts
  57. +92 −0 src/endpoints/d1/update.ts
  58. +106 −0 src/endpoints/delete.ts
  59. +164 −0 src/endpoints/list.ts
  60. +101 −0 src/endpoints/read.ts
  61. +73 −0 src/endpoints/types.ts
  62. +109 −0 src/endpoints/update.ts
  63. +94 −10 src/exceptions.ts
  64. +26 −5 src/index.ts
  65. +231 −119 src/openapi.ts
  66. +137 −556 src/parameters.ts
  67. +125 −100 src/route.ts
  68. +131 −60 src/types.ts
  69. +18 −13 src/ui.ts
  70. +10 −0 src/utils.ts
  71. +24 −0 src/zod/registry.ts
  72. +77 −0 src/zod/utils.ts
  73. +7 −0 tests/bindings.d.ts
  74. +7 −0 tests/index.ts
  75. +81 −0 tests/integration/hono-types.test-d.ts
  76. +178 −0 tests/integration/nested-routers-hono.test.ts
  77. +151 −0 tests/integration/nested-routers.test.ts
  78. +34 −0 tests/integration/openapi-schema.test.ts
  79. +10 −0 tests/integration/openapi.test.disabled.ts
  80. +546 −0 tests/integration/parameters.test.ts
  81. +102 −0 tests/integration/router-options.test.ts
  82. +76 −0 tests/integration/zod.ts
  83. +293 −0 tests/router.ts
  84. +8 −0 tests/tsconfig.json
  85. +14 −0 tests/utils.ts
  86. +19 −0 tests/vitest.config.ts
  87. +4 −0 tests/wrangler.toml
  88. +0 −29 tools/cleanup.js
  89. +0 −21 tools/packagejson.js
  90. +19 −67 tsconfig.json
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -12,8 +12,5 @@ trim_trailing_whitespace = true
indent_style = tab
indent_size = 4

[*.sln]
indent_style = tab

[*.{md,mdx}]
trim_trailing_whitespace = false
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

13 changes: 0 additions & 13 deletions .eslintrc.js

This file was deleted.

17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
groups:
major:
update-types: [ "major" ]
prod-deps:
dependency-type: "production"
dev-deps:
dependency-type: "development"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
47 changes: 47 additions & 0 deletions .github/workflows/create-pullrequest-prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Create Pull Request Prerelease

on: pull_request

jobs:
build:
if: ${{ github.repository_owner == 'cloudflare' }}
name: Build & Publish a Prerelease to the Adhoc Registry
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"

- run: npm install --frozen-lockfile
- run: npm run build

- name: Create package
run: npm pack

- name: Upload packaged chanfana artifact
uses: actions/upload-artifact@v4
with:
name: npm-package-chanfana-${{ github.event.number }} # encode the PR number into the artifact name
path: chanfana-*.tgz

- name: 'Comment on PR with Link'
uses: marocchino/sticky-pull-request-comment@v2
with:
number: ${{ env.WORKFLOW_RUN_PR }}
message: |
🧪 A prerelease is available for testing 🧪
You can install this latest build in your project with:
```sh
npm install --save https://prerelease-registry.devprod.cloudflare.dev/chanfana/runs/${{ github.run_id }}/npm-package-chanfana-${{ github.event.number }}
```
Or you can immediately run this with `npx`:
```sh
npx https://prerelease-registry.devprod.cloudflare.dev/chanfana/runs/${{ github.run_id }}/npm-package-chanfana-${{ github.event.number }}
```
37 changes: 13 additions & 24 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,29 @@
name: Release & Publish

name: Publish
on:
workflow_dispatch:
push:
tags:
- 'v*'

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .npmrc file to publish to npm
uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '14.x'
node-version: 22.x
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Set RELEASE_VERSION
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Apply new version
run: node config/preparePublish.js
- name: Install modules
run: npm install
- name: Build
run: npm run build
- name: Run build
run: npm run lint && npm run build
- name: Run tests
run: npm run test
- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: Setup .npmrc file to publish to GitHub Packages
uses: actions/setup-node@v1
with:
node-version: '14.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@cloudflare'
# - run: npm run addscope
# - name: Publish to GitHub Packages
# run: npm publish
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.WRANGLER_PUBLISHER_NPM_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on:
pull_request: {}
workflow_dispatch: {}
push:
branches:
- main
- master
schedule:
- cron: '0 0 * * *'
name: Semgrep config
jobs:
semgrep:
name: semgrep/ci
runs-on: ubuntu-latest
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
SEMGREP_URL: https://cloudflare.semgrep.dev
SEMGREP_APP_URL: https://cloudflare.semgrep.dev
SEMGREP_VERSION_CHECK_URL: https://cloudflare.semgrep.dev/api/check-version
container:
image: semgrep/semgrep
steps:
- uses: actions/checkout@v4
- run: semgrep ci
45 changes: 12 additions & 33 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,20 @@
name: Test

on:
push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'LICENSE'
- '.editorconfig'
branches:
- main
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'LICENSE'
- '.editorconfig'
branches:
- main
- "**"

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
node: [12.x, 14.x, 16.x]

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install modules
run: yarn
- name: Run build
run: yarn build
# - name: Run tests
# run: yarn test
node-version: 20.x
cache: "npm"

- run: npm install --frozen-lockfile
- run: npm run build
- run: npm run lint
- run: npm run test
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Logs
logs
*.log
@@ -121,3 +120,6 @@ dist
.idea/

.DS_Store
docs/site
.wrangler
.vitepress/cache
5 changes: 0 additions & 5 deletions .husky/commit-msg

This file was deleted.

8 changes: 0 additions & 8 deletions .husky/common.sh

This file was deleted.

8 changes: 2 additions & 6 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
. "$(dirname "$0")/common.sh"

npm run prettify
#npm run test
npm run lint
npm run test
Empty file removed .prettierignore
Empty file.
7 changes: 0 additions & 7 deletions .prettierrc.js

This file was deleted.

63 changes: 63 additions & 0 deletions .vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import {defineConfig} from 'vitepress'

// https://vitepress.dev/reference/site-config
export default defineConfig({
srcDir: './docs',
title: "chanfana",
description: "OpenAPI 3 and 3.1 schema generator and validator for Hono, itty-router and more!",
cleanUrls: true,
head: [['link', {rel: 'icon', type: "image/png", href: '/images/logo-icon.png'}]],
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
logo: '/images/logo-icon.png',
nav: [
{text: 'Home', link: '/'},
{text: 'Docs', link: '/introduction'},
{text: 'Examples', link: '/examples-and-recipes'}
],
sidebar: [
{
text: 'The Basics',
items: [
{text: 'Introduction', link: '/introduction'},
{text: 'Getting Started', link: '/getting-started'},
{text: 'Core Concepts', link: '/core-concepts'},
{text: 'Router Adapters', link: '/router-adapters'},
{text: 'Recipies', link: '/examples-and-recipies'},
]
},
{
text: 'Endpoints',
items: [
{text: 'Defining Endpoints', link: '/endpoints/defining-endpoints'},
{text: 'Request Validation', link: '/endpoints/request-validation'},
{text: 'Response Definition', link: '/endpoints/response-definition'},
{text: 'Parameters', link: '/endpoints/parameters'},
]
},
{
text: 'Auto Endpoints',
items: [
{text: "Base Auto Endpoints", link: '/endpoints/auto/base'},
{text: 'D1 Auto Endpoints', link: '/endpoints/auto/d1'},
]
},
{
text: 'Advanced Stuff',
items: [
{text: 'Error Handling', link: '/error-handling'},
{text: 'OpenAPI Customization', link: '/openapi-configuration-customization'},
{text: 'Advanced Patterns', link: '/advanced-topics-patterns'},
{text: 'Troubleshooting And FAQ', link: '/troubleshooting-and-faq'},
]
},
],
socialLinks: [
{icon: 'github', link: 'https://github.com/cloudflare/chanfana'}
],
footer: {
message: 'Released under the MIT License.',
copyright: 'Copyright © 2024-present Cloudflare'
}
}
})
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Cloudflare
Copyright (c) 2024 Cloudflare

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Loading