grammy 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage, ServerResponse } from "http";
|
|
2
|
-
/**
|
|
3
|
-
* HTTP Web frameworks for which grammY provides compatible callback out of the
|
|
4
|
-
* box.
|
|
5
|
-
*/
|
|
6
|
-
export declare type SupportedFrameworks = "express" | "http" | "https" | "koa" | "fastify" | "worktop" | "callback" | "aws-lambda";
|
|
7
|
-
export declare const defaultFramework: SupportedFrameworks;
|
|
8
|
-
export declare const frameworkAdapters: {
|
|
9
|
-
express: (req: any, res: any) => {
|
|
10
|
-
update: Promise<any>;
|
|
11
|
-
end: () => any;
|
|
12
|
-
respond: (json: string) => void;
|
|
13
|
-
};
|
|
14
|
-
http: (req: IncomingMessage, res: ServerResponse) => {
|
|
15
|
-
update: Promise<any>;
|
|
16
|
-
end: () => void;
|
|
17
|
-
respond: (json: string) => void;
|
|
18
|
-
};
|
|
19
|
-
https: (req: IncomingMessage, res: ServerResponse) => {
|
|
20
|
-
update: Promise<any>;
|
|
21
|
-
end: () => void;
|
|
22
|
-
respond: (json: string) => void;
|
|
23
|
-
};
|
|
24
|
-
koa: (ctx: any) => {
|
|
25
|
-
update: Promise<any>;
|
|
26
|
-
end: () => string;
|
|
27
|
-
respond: (json: string) => void;
|
|
28
|
-
};
|
|
29
|
-
fastify: (req: any, reply: any) => {
|
|
30
|
-
update: Promise<any>;
|
|
31
|
-
end: () => any;
|
|
32
|
-
respond: (json: string) => any;
|
|
33
|
-
};
|
|
34
|
-
worktop: (req: any, res: any) => {
|
|
35
|
-
update: Promise<any>;
|
|
36
|
-
end: () => any;
|
|
37
|
-
respond: (json: string) => any;
|
|
38
|
-
};
|
|
39
|
-
"aws-lambda": (event: any, _context: any, callback: any) => {
|
|
40
|
-
update: any;
|
|
41
|
-
end: () => any;
|
|
42
|
-
respond: (json: string) => any;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.frameworkAdapters = exports.defaultFramework = void 0;
|
|
4
|
-
exports.defaultFramework = "express";
|
|
5
|
-
exports.frameworkAdapters = {
|
|
6
|
-
express: (req, res) => ({
|
|
7
|
-
update: Promise.resolve(req.body),
|
|
8
|
-
end: () => res.end(),
|
|
9
|
-
respond: (json) => {
|
|
10
|
-
res.set("Content-Type", "application/json");
|
|
11
|
-
res.send(json);
|
|
12
|
-
},
|
|
13
|
-
}),
|
|
14
|
-
http: (req, res) => ({
|
|
15
|
-
update: new Promise((resolve) => {
|
|
16
|
-
const chunks = [];
|
|
17
|
-
req
|
|
18
|
-
.on("data", (chunk) => chunks.push(chunk))
|
|
19
|
-
.on("end", () => {
|
|
20
|
-
const raw = Buffer.concat(chunks).toString("utf-8");
|
|
21
|
-
resolve(JSON.parse(raw));
|
|
22
|
-
});
|
|
23
|
-
}),
|
|
24
|
-
end: () => res.end(),
|
|
25
|
-
respond: (json) => {
|
|
26
|
-
return res
|
|
27
|
-
.writeHead(200, { "Content-Type": "application/json" })
|
|
28
|
-
.end(json);
|
|
29
|
-
},
|
|
30
|
-
}),
|
|
31
|
-
https: (req, res) => ({
|
|
32
|
-
update: new Promise((resolve) => {
|
|
33
|
-
const chunks = [];
|
|
34
|
-
req
|
|
35
|
-
.on("data", (chunk) => chunks.push(chunk))
|
|
36
|
-
.on("end", () => {
|
|
37
|
-
const raw = Buffer.concat(chunks).toString("utf-8");
|
|
38
|
-
resolve(JSON.parse(raw));
|
|
39
|
-
});
|
|
40
|
-
}),
|
|
41
|
-
end: () => res.end(),
|
|
42
|
-
respond: (json) => {
|
|
43
|
-
return res
|
|
44
|
-
.writeHead(200, { "Content-Type": "application/json" })
|
|
45
|
-
.end(json);
|
|
46
|
-
},
|
|
47
|
-
}),
|
|
48
|
-
koa: (ctx) => ({
|
|
49
|
-
update: Promise.resolve(ctx.request.body),
|
|
50
|
-
end: () => (ctx.body = ""),
|
|
51
|
-
respond: (json) => {
|
|
52
|
-
ctx.set("Content-Type", "application/json");
|
|
53
|
-
ctx.response.body = json;
|
|
54
|
-
},
|
|
55
|
-
}),
|
|
56
|
-
fastify: (req, reply) => ({
|
|
57
|
-
update: Promise.resolve(req.body),
|
|
58
|
-
end: () => reply.send({}),
|
|
59
|
-
respond: (json) => reply.send(json),
|
|
60
|
-
}),
|
|
61
|
-
worktop: (req, res) => ({
|
|
62
|
-
update: Promise.resolve(req.body.json()),
|
|
63
|
-
end: () => res.end(),
|
|
64
|
-
respond: (json) => res.send(200, json),
|
|
65
|
-
}),
|
|
66
|
-
"aws-lambda": (event, _context, callback) => ({
|
|
67
|
-
update: JSON.parse(event.body),
|
|
68
|
-
end: () => callback(null, { statusCode: 200 }),
|
|
69
|
-
respond: (json) => callback(null, {
|
|
70
|
-
statusCode: 200,
|
|
71
|
-
body: json,
|
|
72
|
-
}),
|
|
73
|
-
}),
|
|
74
|
-
// please open a PR if you want to add another
|
|
75
|
-
};
|