/
mod.ts
143 lines (140 loc) · 3.92 KB
/
mod.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Copyright 2018-2022 the oak authors. All rights reserved. MIT license.
/**
* A middleware framework for handling HTTP with Deno.
*
* oak works well on both Deno CLI and Deno deploy, and is inspired by
* [koa](https://koajs.com/). It works well with both the Deno CLI and
* [Deno Deploy](https://deno.com/deploy).
*
* ### Example server
*
* A minimal router server which responds with content on `/`. With Deno CLI
* this will listen on port 8080 and on Deploy, this will simply serve requests
* received on the application.
*
* ```ts
* import { Application, Router } from "https://deno.land/x/oak/mod.ts";
*
* const router = new Router();
* router.get("/", (ctx) => {
* ctx.response.body = `<!DOCTYPE html>
* <html>
* <head><title>Hello oak!</title><head>
* <body>
* <h1>Hello oak!</h1>
* </body>
* </html>
* `;
* });
*
* const app = new Application();
* app.use(router.routes());
* app.use(router.allowedMethods());
*
* app.listen({ port: 8080 });
* ```
*
* ### Using Deno's flash server
*
* Currently, Deno's flash server is not the default, even with the `--unstable`
* flag. In order to use the flash server, you need to provide the
* {@linkcode FlashServer} to the {@linkcode Application} constructor:
*
* ```ts
* import { Application, FlashServer } from "https://deno.land/x/oak/mod.ts";
*
* const app = new Application({ serverConstructor: FlashServer });
*
* // register middleware
*
* app.listen({ port: 8080 });
* ```
*
* Note the currently Deno's flash server requires the `--unstable` flag. If it
* isn't present, the application will error on listening.
*
* @module
*/
export { Application } from "./application.ts";
export type {
ApplicationOptions,
ListenOptions,
ListenOptionsBase,
ListenOptionsTls,
State,
} from "./application.ts";
export type {
BodyBytes,
BodyContentTypes,
BodyForm,
BodyFormData,
BodyJson,
BodyOptions,
BodyOptionsContentTypes,
BodyReader,
BodyStream,
BodyText,
BodyType,
BodyUndefined,
} from "./body.ts";
export { Context, type ContextSendOptions } from "./context.ts";
export * as helpers from "./helpers.ts";
export {
Cookies,
type CookiesGetOptions,
type CookiesSetDeleteOptions,
} from "./cookies.ts";
export * as etag from "./etag.ts";
export { HttpRequest } from "./http_request.ts";
export { FlashServer, hasFlash } from "./http_server_flash.ts";
export { HttpServer as HttpServerNative } from "./http_server_native.ts";
export { type NativeRequest } from "./http_server_native_request.ts";
export { proxy } from "./middleware/proxy.ts";
export type { ProxyOptions } from "./middleware/proxy.ts";
export { compose as composeMiddleware } from "./middleware.ts";
export type { Middleware } from "./middleware.ts";
export { FormDataReader } from "./multipart.ts";
export type {
FormDataBody,
FormDataFile,
FormDataReadOptions,
} from "./multipart.ts";
export { ifRange, MultiPartStream, parseRange } from "./range.ts";
export type { ByteRange } from "./range.ts";
export { Request } from "./request.ts";
export { REDIRECT_BACK, Response } from "./response.ts";
export { Router } from "./router.ts";
export type {
Route,
RouteParams,
RouterAllowedMethodsOptions,
RouterContext,
RouterMiddleware,
RouterOptions,
RouterParamMiddleware,
} from "./router.ts";
export { send } from "./send.ts";
export type { SendOptions } from "./send.ts";
export { ServerSentEvent } from "./server_sent_event.ts";
export type {
ServerSentEventInit,
ServerSentEventTarget,
} from "./server_sent_event.ts";
/** Utilities for making testing oak servers easier. */
export * as testing from "./testing.ts";
export type {
ErrorStatus,
HTTPMethods,
RedirectStatus,
ServerConstructor,
} from "./types.d.ts";
export { isErrorStatus, isRedirectStatus } from "./util.ts";
// Re-exported from `std/http`
export {
createHttpError,
errors as httpErrors,
HttpError,
isHttpError,
Status,
STATUS_TEXT,
} from "./deps.ts";