Skip to content

Commit e4f93a3

Browse files
authored
Merge branch 'main' into copilot/fix-websocket-upgrade-issue
2 parents e5d32d8 + 18cdfde commit e4f93a3

3 files changed

Lines changed: 62 additions & 6 deletions

File tree

.github/copilot-instructions.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copilot Instructions for oak
2+
3+
## Overview
4+
5+
oak is a middleware framework for Deno's native HTTP server,
6+
[Deno Deploy](https://deno.com/deploy), Node.js, [Bun](https://bun.sh/), and
7+
[Cloudflare Workers](https://workers.cloudflare.com/). It is inspired by
8+
[Koa](https://github.com/koajs/koa/) and includes a middleware router inspired
9+
by [@koa/router](https://github.com/koajs/router/). The package is distributed
10+
via [JSR](https://jsr.io/@oak/oak).
11+
12+
## Repository Structure
13+
14+
- **Root-level `.ts` files** — Core framework modules (e.g., `application.ts`,
15+
`router.ts`, `context.ts`, `request.ts`, `response.ts`, `body.ts`, `send.ts`).
16+
- **`middleware/`** — Built-in middleware (etag, proxy, serve).
17+
- **`utils/`** — Internal utility functions and type guards.
18+
- **`*.test.ts`** — Test files co-located with source files.
19+
- **`deps.ts`** — Centralized runtime dependencies (always import shared deps from here).
20+
- **`deps_test.ts`** — Centralized test-only dependencies.
21+
- **`mod.ts`** — Public entry point that re-exports the full public API.
22+
- **`types.ts`** — Shared TypeScript types and interfaces.
23+
- **`examples/`** — Example usage scripts (not published).
24+
- **`fixtures/`** — Test fixtures (not published).
25+
- **`docs/`** — Documentation site source (not published).
26+
27+
## Development Commands
28+
29+
All commands use the [Deno](https://deno.com/) toolchain (no `npm` or build step needed).
30+
31+
| Task | Command |
32+
|---|---|
33+
| Run tests | `deno task test` |
34+
| Run tests with coverage | `deno task test:coverage` |
35+
| Generate lcov report | `deno task coverage` |
36+
| Format code | `deno fmt` |
37+
| Check formatting | `deno fmt --check` |
38+
| Lint code | `deno lint` |
39+
40+
## Coding Conventions
41+
42+
- **Language**: TypeScript, targeting Deno-first with cross-runtime support (Node.js, Bun).
43+
- **Copyright header**: Every source file begins with:
44+
```ts
45+
// Copyright 2018-2025 the oak authors. All rights reserved. MIT license.
46+
```
47+
- **Imports**: Use relative imports with `.ts` extensions (e.g., `import { foo } from "./bar.ts"`).
48+
Shared dependencies are imported via `deps.ts`; test-only dependencies via `deps_test.ts`.
49+
- **JSDoc**: Public APIs are documented with JSDoc. Module-level doc comments end with a `@module` tag.
50+
- **Formatting**: Enforced by `deno fmt`. Do not manually adjust whitespace or indentation.
51+
- **Linting**: Enforced by `deno lint`. The `no-import-prefix` rule is disabled (see `deno.json`).
52+
- **Tests**: Co-located `*.test.ts` files. Use `assertEquals`, `assertStrictEquals`, and
53+
`assertRejects` from `deps_test.ts`. Mock helpers are defined locally within test files.
54+
- **Error handling**: Use the `errors` object from `deps.ts` for HTTP error classes.
55+
- **Exports**: All public symbols are re-exported from `mod.ts`. The `deno.json`
56+
`exports` field also defines the package entry points for JSR publishing.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -795,11 +795,11 @@ await app.listen({ port: 8000 });
795795
```
796796

797797
A route passed is converted to a regular expression using
798-
[path-to-regexp](https://github.com/pillarjs/path-to-regexp), which means
799-
parameters expressed in the pattern will be converted. `path-to-regexp` has
800-
advanced usage which can create complex patterns which can be used for matching.
801-
Check out the
802-
[documentation for that library](https://github.com/pillarjs/path-to-regexp#parameters)
798+
[path-to-regexp](https://github.com/pillarjs/path-to-regexp/tree/6.x), which
799+
means parameters expressed in the pattern will be converted. `path-to-regexp`
800+
has advanced usage which can create complex patterns which can be used for
801+
matching. Check out the
802+
[documentation for that library](https://github.com/pillarjs/path-to-regexp/tree/6.x#parameters)
803803
if you have advanced use cases.
804804

805805
In most cases, the type of `context.params` is automatically inferred from the

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"test:coverage": "deno test --coverage=./cov --junit-path=junit.xml --allow-read --allow-write --allow-net --cert ./examples/tls/RootCA.crt --parallel --ignore=npm"
3939
},
4040
"fmt": {
41-
"exclude": ["README.md"]
41+
"exclude": ["README.md", ".github/copilot-instructions.md"]
4242
},
4343
"lint": {
4444
"rules": {

0 commit comments

Comments
 (0)