Skip to content

Commit

Permalink
Release/0.7.3 (#18)
Browse files Browse the repository at this point in the history
* v0.7.3 - See CHANGELOG for details
  • Loading branch information
Thesephi authored Jun 17, 2024
1 parent 3bbd89a commit c121341
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 43 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## [0.7.3] - 2024-06-17

### Added

- More symbols exported directly for better compatibilities with Cloudflare
Workers projects (esp. in IDE environments such as Visual Studio Code)

### Fixed

- Better support for JavaScript Registry documentation navigation indentation
behaviors

## [0.7.2] - 2024-06-17

### Changed
Expand Down
71 changes: 30 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MyPokedex {
}
```

## Forewords
# Forewords

If you're familiar with the
[npm library routing-controllers](https://www.npmjs.com/package/routing-controllers),
Expand All @@ -32,20 +32,18 @@ replacement for routing-controllers, as it attempts to conform to
yet. There's currently no plan to support TypeScript "experimental" decorators,
but if you feel strongly for it, please feel free to fork this repo!

## Example Usages

### Heads up
# Heads up

For easy reading, the examples below do not specify any explicit version when
installing library dependencies. But in your production code, it's advisable to
pin every dependency to a specific version.

### Deno runtime
# Deno runtime

Prerequisite:
[Deno](https://docs.deno.com/runtime/manual/getting_started/installation)

#### Example: Retrieving path parameters
## Example: Retrieving path parameters

```bash
deno add @oak/oak @dklab/oak-routing-ctrl
Expand Down Expand Up @@ -87,9 +85,7 @@ deno run --allow-env --allow-net main.ts
curl localhost:1993/v1/hello/world # prints: hello, world
```

#### Other examples

##### Retrieving path parameters and request body
## Example: Retrieving path parameters and request body

<details>
<summary>View Example</summary>
Expand All @@ -102,7 +98,6 @@ import {
Post,
useOakServer,
} from "@dklab/oak-routing-ctrl";
const app = new Application();

@Controller("/v1")
class MyController {
Expand All @@ -113,19 +108,21 @@ class MyController {
}
}

const app = new Application();
useOakServer(app, [MyController]);

await app.listen({ port: 1993 });
```

_

```bash
curl -H"Content-Type: application/json" localhost:1993/v1/tell/alice -d'{"message": "all we need is love"}'
# prints: telling alice that "all we need is love"
```

</details>

##### Retrieving request query and path parameters
## Example: Retrieving request query and path parameters

<details>
<summary>View Example</summary>
Expand All @@ -138,7 +135,6 @@ import {
Get,
useOakServer,
} from "@dklab/oak-routing-ctrl";
const app = new Application();

@Controller("/v1")
class MyController {
Expand All @@ -149,27 +145,28 @@ class MyController {
}
}

const app = new Application();
useOakServer(app, [MyController]);

await app.listen({ port: 1993 });
```

_

```bash
curl localhost:1993/v1/books/thriller\?page=2
# prints: searching for books in category "thriller" with query "page=2"
```

</details>

##### Accessing underlying context object
## Example: Accessing underlying context object

<details>
<summary>View Example</summary>

```ts
import { Application } from "@oak/oak/application";
import { Controller, Get, useOakServer } from "@dklab/oak-routing-ctrl";
const app = new Application();

@Controller()
class MyController {
Expand All @@ -181,23 +178,23 @@ class MyController {
}
}

const app = new Application();
useOakServer(app, [MyController]);

await app.listen({ port: 1993 });
```

_

```bash
curl -H"x-foo: lorem" localhost:1993/foo/bar
# prints: request header x-foo has value "lorem"
```

</details>

---
# Other runtimes

### Other runtimes

#### Node.js
## Node.js

<details>
<summary>View Example</summary>
Expand Down Expand Up @@ -241,12 +238,12 @@ await app.listen({ port: 1993 });
_

```bash
curl http://localhost:1993/hello/world # prints: hello, world
curl http://localhost:1993/v1/hello/world # prints: hello, world
```

</details>

#### Cloudflare Workers
## Cloudflare Workers

<details>
<summary>View Example</summary>
Expand All @@ -264,7 +261,7 @@ import {
ControllerMethodArgs,
Get,
useOakServer,
} from "@dklab/oak-routing-ctrl";
} from "@dklab/oak-routing-ctrl/mod";

@Controller()
class MyCloudflareWorkerController {
Expand All @@ -288,7 +285,7 @@ curl http://{your-cloudflare-worker-domain}/hello/world # prints: hello, world

</details>

#### Bun
## Bun

<details>
<summary>View Example</summary>
Expand All @@ -300,19 +297,13 @@ bunx jsr i @oak/oak @dklab/oak-routing-ctrl
_

```ts
import { Application } from "@oak/oak/application";

import {
Controller,
ControllerMethodArgs,
Get,
useOakServer,
} from "@dklab/oak-routing-ctrl";
import { Application, type RouterContext } from "@oak/oak";
import { Controller, Get, useOakServer } from "@dklab/oak-routing-ctrl";

@Controller("/v1")
class MyController {
@Get("/hello/:name")
hello(ctx) {
hello(ctx: RouterContext<"/hello/:name">) {
return `hello, ${ctx.params.name}`;
}
}
Expand All @@ -325,25 +316,23 @@ await app.listen({ port: 1993 });
_

```bash
curl http://localhost:1993/hello/world # prints: hello, world
curl http://localhost:1993/v1/hello/world # prints: hello, world
```

</details>

## Documentation
# Documentation

Documentation is hosted on the Javascript Registry:
https://jsr.io/@dklab/oak-routing-ctrl/doc

## Contributor Resources
# Contributor Resources

### Tests
## Tests

```bash
deno test -A --coverage=cov_profile
deno coverage cov_profile
```

### Test Coverage

![coverage](https://codecov.io/gh/Thesephi/oak-routing-ctrl/graphs/tree.svg?token=BA3M9P6410)
[![coverage](https://codecov.io/gh/Thesephi/oak-routing-ctrl/graphs/tree.svg?token=BA3M9P6410)](https://codecov.io/github/Thesephi/oak-routing-ctrl)
5 changes: 3 additions & 2 deletions jsr.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "@dklab/oak-routing-ctrl",
"version": "0.7.2",
"version": "0.7.3",
"exports": {
".": "./mod.ts"
".": "./mod.ts",
"./mod": "./mod.ts"
},
"exclude": [
"**/*_test.ts",
Expand Down

0 comments on commit c121341

Please sign in to comment.