diff --git a/changelog.md b/changelog.md index c4f630f..bbd2622 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,36 @@ +## [v0.11.0](https://github.com/azurystudio/cheetah/releases/tag/v0.11.0) + +- **Bug Fixes** + + - Decode query parameters. + +- **New Features** + + - **Preflight Mode.** + + If enabled, cheetah will attempt to find the matching `.get()` handler for an incoming HEAD request. Your existing `.head()` handlers won't be impacted. + + ```ts + new cheetah({ + preflight: true + }) + ``` + + - You can now configure the `cache` or `cors` option for an entire collection of routes. + + ```ts + new Collection({ + cache: false, + cors: '*' + }) + ``` + + *These won't overwrite the options set for individual routes.* + +- **Revisions** + + - The `cache.duration` option has been deprecated. Please use the `cache.maxAge` option instead. + ## [v0.10.0](https://github.com/azurystudio/cheetah/releases/tag/v0.10.0) - **New Features** diff --git a/guide/accessories/jwt.md b/guide/accessories/jwt.md index e6ce8f5..83dd50f 100644 --- a/guide/accessories/jwt.md +++ b/guide/accessories/jwt.md @@ -3,7 +3,7 @@ ## jwt (JSON Web Token) ```ts -import { jwt } from 'https://deno.land/x/cheetah@v0.10.0/x/mod.ts' +import { jwt } from 'https://deno.land/x/cheetah@v0.11.0/x/mod.ts' ``` #### Generating a Secret @@ -13,7 +13,7 @@ You can parse either a [CryptoKey](https://developer.mozilla.org/en-US/docs/Web/ This key can then be parsed to the functions. ```ts -import { createKey } from 'https://deno.land/x/cheetah@v0.10.0/x/mod.ts' +import { createKey } from 'https://deno.land/x/cheetah@v0.11.0/x/mod.ts' const key = await createKey() ``` diff --git a/guide/accessories/otp.md b/guide/accessories/otp.md index 054c3ae..80d741b 100644 --- a/guide/accessories/otp.md +++ b/guide/accessories/otp.md @@ -3,7 +3,7 @@ ## otp (One Time Password) ```ts -import { otp } from 'https://deno.land/x/cheetah@v0.10.0/x/mod.ts' +import { otp } from 'https://deno.land/x/cheetah@v0.11.0/x/mod.ts' ``` ### Usage diff --git a/guide/accessories/sendMail.md b/guide/accessories/sendMail.md index 7da77ce..b1e30f5 100644 --- a/guide/accessories/sendMail.md +++ b/guide/accessories/sendMail.md @@ -5,7 +5,7 @@ > **Note**: This module is specifically designed for Cloudflare Workers as it uses [mailchannels](https://blog.cloudflare.com/sending-email-from-workers-with-mailchannels) under the hood, which is free if you deploy your app to Cloudflare Workers. ```ts -import { sendMail } from 'https://deno.land/x/cheetah@v0.10.0/x/mod.ts' +import { sendMail } from 'https://deno.land/x/cheetah@v0.11.0/x/mod.ts' await sendMail({ subject: 'Example', diff --git a/guide/deploying.md b/guide/deploying.md index e4fe4a7..f8e2274 100644 --- a/guide/deploying.md +++ b/guide/deploying.md @@ -9,7 +9,7 @@ cheetah can run on [Cloudflare Workers](https://workers.cloudflare.com) as well > **Note**: This example uses the [Module Worker](https://blog.cloudflare.com/workers-javascript-modules) syntax. ```ts -import cheetah from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' +import cheetah from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' const app = new cheetah() .get('/', () => 'Hello World') @@ -22,14 +22,14 @@ export default app // or: export default { fetch: app.fetch } To compile your application into a single JavaScript file that you can deploy to Cloudflare Workers, run the following command: ```bash -# deno run -A https://deno.land/x/cheetah@v0.10.0/build.ts -deno run -A https://deno.land/x/cheetah@v0.10.0/build.ts mod.ts mod.js +# deno run -A https://deno.land/x/cheetah@v0.11.0/build.ts +deno run -A https://deno.land/x/cheetah@v0.11.0/build.ts mod.ts mod.js ``` ### Deno (Deploy) ```ts -import cheetah from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' +import cheetah from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' import { serve } from 'https://deno.land/std@0.191.0/http/server.ts' const app = new cheetah() diff --git a/guide/get_started.md b/guide/get_started.md index 5ef4ff7..10da480 100644 --- a/guide/get_started.md +++ b/guide/get_started.md @@ -9,13 +9,13 @@ #### Deno ```bash - deno run --allow-read=. --allow-write=. --allow-net https://deno.land/x/cheetah@v0.10.0/new.ts --template deno + deno run --allow-read=. --allow-write=. --allow-net https://deno.land/x/cheetah@v0.11.0/new.ts --template deno ``` #### Cloudflare ```bash - deno run --allow-read=. --allow-write=. --allow-net https://deno.land/x/cheetah@v0.10.0/new.ts --template cloudflare + deno run --allow-read=. --allow-write=. --allow-net https://deno.land/x/cheetah@v0.11.0/new.ts --template cloudflare ``` - Now you should have a basic app with good default preferences. **Make sure to read the `readme.md` file in your project root to learn more.** diff --git a/guide/nesting.md b/guide/nesting.md index edaa287..82fb806 100644 --- a/guide/nesting.md +++ b/guide/nesting.md @@ -5,7 +5,7 @@ You can split your app into multiple files using **collections**. Creating a new collection is also quite simple: ```ts -import cheetah, { Collection } from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' +import cheetah, { Collection } from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' const collection = new Collection() .get('/example', () => 'Hello World') diff --git a/guide/parsing_and_validation.md b/guide/parsing_and_validation.md index a9778df..1bc3ebb 100644 --- a/guide/parsing_and_validation.md +++ b/guide/parsing_and_validation.md @@ -7,8 +7,8 @@ This enables the conversion of a FormData request body into a JSON object *(if the request body has the MIME type `multipart/form-data`)*. ```ts -import cheetah from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' -import zod, { z } from 'https://deno.land/x/cheetah@v0.10.0/validator/zod.ts' +import cheetah from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' +import zod, { z } from 'https://deno.land/x/cheetah@v0.11.0/validator/zod.ts' const app = new cheetah({ validator: zod @@ -30,8 +30,8 @@ app.get('/example', { - #### Setup ```ts - import cheetah from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' - import typebox, { Type } from 'https://deno.land/x/cheetah@v0.10.0/validator/typebox.ts' + import cheetah from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' + import typebox, { Type } from 'https://deno.land/x/cheetah@v0.11.0/validator/typebox.ts' const app = new cheetah({ validator: typebox @@ -103,8 +103,8 @@ app.get('/example', { - #### Setup ```ts - import cheetah from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' - import zod, { z } from 'https://deno.land/x/cheetah@v0.10.0/validator/zod.ts' + import cheetah from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' + import zod, { z } from 'https://deno.land/x/cheetah@v0.11.0/validator/zod.ts' const app = new cheetah({ validator: zod diff --git a/guide/plugins/helmet.md b/guide/plugins/helmet.md index 2c7137b..2e3c843 100644 --- a/guide/plugins/helmet.md +++ b/guide/plugins/helmet.md @@ -5,8 +5,8 @@ > This plugin is based on [express.js' helmet](https://github.com/helmetjs/helmet). ```ts -import cheetah from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' -import helmet from 'https://deno.land/x/cheetah@v0.10.0/plugins/helmet.ts' +import cheetah from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' +import helmet from 'https://deno.land/x/cheetah@v0.11.0/plugins/helmet.ts' const app = new cheetah() .use(helmet()) diff --git a/guide/plugins/index.md b/guide/plugins/index.md index cff71d4..5ce91cf 100644 --- a/guide/plugins/index.md +++ b/guide/plugins/index.md @@ -19,7 +19,7 @@ If you want to add additional functionality to your application on a global, per Plugins let you create and publish reusable functions for your own and open source purposes. ```ts -import cheetah, { createPlugin } from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' +import cheetah, { createPlugin } from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' export const myPlugin = createPlugin<{ option: string // < settings the user can pass to the plugin @@ -42,7 +42,7 @@ const app = new cheetah() Alternatively, you can create one without settings: ```ts -import cheetah, { createPlugin } from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' +import cheetah, { createPlugin } from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' export const myPlugin = createPlugin({ beforeParsing(c) { // access context to modify request/response diff --git a/guide/reasons/chaining_and_nesting.md b/guide/reasons/chaining_and_nesting.md index 37f02a0..82eb0cc 100644 --- a/guide/reasons/chaining_and_nesting.md +++ b/guide/reasons/chaining_and_nesting.md @@ -3,7 +3,7 @@ ## ๐Ÿ”— Chaining ```ts -import cheetah from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' +import cheetah from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' const app = new cheetah() .get('/cake', () => '๐ŸŽ‚') // GET '/cake' @@ -16,7 +16,7 @@ const app = new cheetah() ## ๐Ÿชน Nesting ```ts -import cheetah, { Collection } from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' +import cheetah, { Collection } from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' const fastFood = new Collection() .get('/burger', () => '๐Ÿ”') // GET '/fast-food/burger' diff --git a/guide/reasons/light.md b/guide/reasons/light.md index 7d08beb..9bd34a2 100644 --- a/guide/reasons/light.md +++ b/guide/reasons/light.md @@ -4,7 +4,7 @@ | Module | Size | | --- | --- | -| Core | 10.84 KB | -| Validator (TypeBox) | 120.48 KB | +| Core | 11.75 KB | +| Validator (TypeBox) | 119.7 KB | | Validator (Zod) | 52.91 KB | | Accessories | 36.04 KB | diff --git a/guide/reasons/schema_validation.md b/guide/reasons/schema_validation.md index fb10d60..b696d44 100644 --- a/guide/reasons/schema_validation.md +++ b/guide/reasons/schema_validation.md @@ -7,8 +7,8 @@ When building a large API with cheetah, you probably want some sort of validatio With cheetah, this is fairly straightforward. The following example uses [Zod](https://github.com/colinhacks/zod) as the validator and verifies that the body of the incoming request is of the type string and has the format of an emoji. ```ts -import cheetah from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' -import zod, { z } from 'https://deno.land/x/cheetah@v0.10.0/validator/zod.ts' +import cheetah from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' +import zod, { z } from 'https://deno.land/x/cheetah@v0.11.0/validator/zod.ts' const app = new cheetah({ validator: zod diff --git a/guide/reasons/simple.md b/guide/reasons/simple.md index fc61b76..224af8f 100644 --- a/guide/reasons/simple.md +++ b/guide/reasons/simple.md @@ -5,7 +5,7 @@ cheetah has built-in support for [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS). You can configure it according to the [specification](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin) of the `Access-Control-Allow-Origin` header. ```ts -import cheetah from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' +import cheetah from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' const app = new cheetah({ cors: '*' @@ -19,7 +19,7 @@ const app = new cheetah({ cheetah has out-of-the-box support for caching using the [Cache API](https://developer.mozilla.org/en-US/docs/Web/API/Cache). ```ts -import cheetah from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' +import cheetah from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' const app = new cheetah({ cache: { @@ -36,7 +36,7 @@ const app = new cheetah({ cheetah prints out all incoming requests and the status code of their corresponding response to the console when you enable debug mode. ```ts -import cheetah from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' +import cheetah from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' const app = new cheetah({ debug: true diff --git a/guide/syntax.md b/guide/syntax.md index 2f86a57..b6b5790 100644 --- a/guide/syntax.md +++ b/guide/syntax.md @@ -5,7 +5,7 @@ ### Suggested ```ts -import cheetah from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' +import cheetah from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' // #1 const app = new cheetah() @@ -32,7 +32,7 @@ const app = new cheetah() [Express.js](https://github.com/expressjs/express)ish ```ts -import cheetah from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' +import cheetah from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' const app = new cheetah() @@ -48,7 +48,7 @@ app.get('/b', c => { [Hono](https://github.com/honojs/hono)ish ```ts -import cheetah from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' +import cheetah from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' const app = new cheetah() .get('/a', c => c.text('Hello World')) diff --git a/readme.md b/readme.md index 7480507..836a6b2 100644 --- a/readme.md +++ b/readme.md @@ -26,7 +26,7 @@ ### Sneak Peek ```ts -import cheetah from 'https://deno.land/x/cheetah@v0.10.0/mod.ts' +import cheetah from 'https://deno.land/x/cheetah@v0.11.0/mod.ts' import { serve } from 'https://deno.land/std@0.191.0/http/server.ts' const app = new cheetah()