forked from utily/cloudly-http
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
19 lines (16 loc) · 996 Bytes
/
index.ts
File metadata and controls
19 lines (16 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { Client } from "./Client"
import { Method } from "./Method"
import * as Parser from "./Parser"
import * as Serializer from "./Serializer"
import { Request } from "./Request"
import { Response } from "./Response"
import { fetch } from "./fetch"
import * as Search from "./Search"
Parser.add(async request => await request.text(), "text/plain", "text/html")
Parser.add(async request => await request.json(), "application/json")
Parser.add(async request => Object.fromEntries((await request.formData()).entries()), "multipart/form-data")
Parser.add(async request => Search.parse(await request.text()), "application/x-www-form-urlencoded")
Serializer.add(async body => (typeof body == "string" ? body : body.toString()), "text/plain", "text/html")
Serializer.add(async body => JSON.stringify(body), "application/json")
Serializer.add(async body => Search.stringify(body), "application/x-www-form-urlencoded")
export { Client, Method, Parser, Serializer, Request, Response, fetch, Search }