-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathmain.ts
51 lines (44 loc) · 1.47 KB
/
main.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
import Router, { RoutesList } from './lib/router.ts';
import Server from './lib/server.ts';
import {
DirectoryHandlerOptions,
FileHandlerOptions,
RouteHandler,
RouteOptions,
ServerOptions
} from './lib/types.ts';
export * as types from './lib/types.ts';
export { default as Router } from './lib/router.ts';
export { default as Server } from './lib/server.ts';
export { default as Toolkit } from './lib/toolkit.ts';
export { default as Request } from './lib/request.ts';
export { default as Response } from './lib/response.ts';
/**
* Returns a route handler function that serves the specified directory using `h.directory()`
*/
export const directory = (path: string, options?: DirectoryHandlerOptions): RouteHandler => {
return (request, h) => {
return h.directory(path, options);
};
}
/**
* Returns a route handler function that serves the specified file using `h.file()`
*/
export const file = (path: string, options?: FileHandlerOptions): RouteHandler => {
return (request, h) => {
return h.file(path, options);
};
};
/**
* Returns a new instance of the Server class
*/
export const server = (options?: ServerOptions): Server => {
return new Server(options);
};
/**
* Returns a new instance of the Router class
*/
export const router = (route?: RoutesList, options?: RouteOptions | RouteHandler, handler?: RouteHandler): Router => {
return new Router(route, options, handler);
};
export default { directory, file, server, router };