feat: move to Deno.serve (#1427)

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
This commit is contained in:
Lino Le Van
2023-07-12 14:37:53 +02:00
committed by GitHub
co-authored by Marvin Hagemeister
parent 46ae49d654
commit e2a1bf8643
24 changed files with 67 additions and 151 deletions
+6 -2
View File
@@ -120,11 +120,15 @@ the value of `acme` in your middleware.
To set the stage for this section, `MiddlewareHandlerContext` looks like this:
```ts
export interface MiddlewareHandlerContext<State = Record<string, unknown>>
extends ConnInfo {
export interface MiddlewareHandlerContext<State = Record<string, unknown>> {
next: () => Promise<Response>;
state: State;
destination: router.DestinationKind;
remoteAddr: {
transport: "tcp" | "udp";
hostname: string;
port: number;
};
}
```
+1 -1
View File
@@ -36,7 +36,7 @@ caching **will** cause your project to not function correctly.
Here is an example `Dockerfile` for a Fresh project:
```dockerfile
FROM denoland/deno:1.33.2
FROM denoland/deno:1.35.0
ARG GIT_REVISION
ENV DENO_DEPLOYMENT_ID=${GIT_REVISION}
+6 -2
View File
@@ -100,11 +100,15 @@ export const handler = [
To set the stage for this section, `MiddlewareHandlerContext` looks like this:
```ts
export interface MiddlewareHandlerContext<State = Record<string, unknown>>
extends ConnInfo {
export interface MiddlewareHandlerContext<State = Record<string, unknown>> {
next: () => Promise<Response>;
state: State;
destination: router.DestinationKind;
remoteAddr: {
transport: "tcp" | "udp";
hostname: string;
port: number;
};
}
```
+2 -11
View File
@@ -17,19 +17,10 @@ export async function start(routes: Manifest, opts: StartOptions = {});
things get interesting. `StartOptions` looks like this:
```
export type StartOptions = ServeInit & FreshOptions & {
/**
* UNSTABLE: use the `Deno.serve` API as the underlying HTTP server instead of
* the `std/http` API. Do not use this in production.
*
* This option is experimental and may be removed in a future Fresh release.
*/
experimentalDenoServe?: boolean;
};
export type StartOptions = ServeInit & FreshOptions;
```
You can play around with `Deno.serve` if you'd like, but heed the warning. The
good stuff is really in...
The good stuff is really in...
```ts
export interface FreshOptions {
+1
View File
@@ -23,6 +23,7 @@ below.
| 1.0.0-1.0.2 | >=10.8.1 <11.0.0 | >=5.2.0 <6.0.0 | >= 1.23.0 |
| 1.1.0-1.1.5 | >=10.8.1 <11.0.0 | >=5.2.0 <6.0.0 | >= 1.25.0 |
| 1.2.0 | >=10.15.0 <11.0.0 | >=6.1.0 | >= 1.25.0 |
| 1.3.0 | >=10.15.0 <11.0.0 | >=6.1.0 | >= 1.35.0 |
## Updating dependencies
+2 -4
View File
@@ -53,13 +53,11 @@ export default function FooPage() {
```ts
// tests/main_test.ts
import { createHandler } from "$fresh/server.ts";
import { createHandler, ServeHandlerInfo } from "$fresh/server.ts";
import manifest from "../fresh.gen.ts";
import { assert, assertEquals } from "$std/testing/asserts.ts";
import type { ConnInfo } from "$std/http/server.ts";
const CONN_INFO: ConnInfo = {
localAddr: { hostname: "127.0.0.1", port: 8000, transport: "tcp" },
const CONN_INFO: ServeHandlerInfo = {
remoteAddr: { hostname: "127.0.0.1", port: 53496, transport: "tcp" },
};
+1 -1
View File
@@ -10,7 +10,7 @@ framework. You'll learn how to create a new project, run it locally, edit and
create pages, fetch data, handle user interactions, and how to then deploy the
project to [Deno Deploy][deno-deploy].
The documentation assumes you have Deno 1.31.0 or later installed.
The documentation assumes you have Deno 1.35.0 or later installed.
To install Deno, follow the
[installation instructions in the Deno manual][manual-installation].