@as-integrations/h3 1.1.4 → 1.1.6
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/dist/index.cjs +3 -8
- package/dist/index.d.cts +14 -0
- package/dist/index.d.mts +14 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +4 -9
- package/package.json +21 -22
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const server = require('@apollo/server');
|
|
3
4
|
const h3 = require('h3');
|
|
4
5
|
|
|
5
6
|
function startServerAndCreateH3Handler(server, options) {
|
|
@@ -41,7 +42,7 @@ async function toGraphqlRequest(event) {
|
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
44
|
function normalizeHeaders(headers) {
|
|
44
|
-
const headerMap =
|
|
45
|
+
const headerMap = new server.HeaderMap();
|
|
45
46
|
for (const [key, value] of Object.entries(headers)) {
|
|
46
47
|
if (Array.isArray(value)) {
|
|
47
48
|
headerMap.set(key, value.join(","));
|
|
@@ -60,13 +61,7 @@ function normalizeQueryString(url) {
|
|
|
60
61
|
async function normalizeBody(event) {
|
|
61
62
|
const PayloadMethods = ["PATCH", "POST", "PUT", "DELETE"];
|
|
62
63
|
if (h3.isMethod(event, PayloadMethods)) {
|
|
63
|
-
|
|
64
|
-
const content = typeof body === "string" ? body : body?.toString();
|
|
65
|
-
if (h3.getRequestHeader(event, "content-type") === "application/json") {
|
|
66
|
-
return content ? JSON.parse(content) : {};
|
|
67
|
-
} else {
|
|
68
|
-
return content;
|
|
69
|
-
}
|
|
64
|
+
return await h3.readBody(event);
|
|
70
65
|
}
|
|
71
66
|
}
|
|
72
67
|
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseContext, ContextFunction, ApolloServer } from '@apollo/server';
|
|
2
|
+
import { H3Event, EventHandler } from 'h3';
|
|
3
|
+
|
|
4
|
+
type WithRequired<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
5
|
+
interface H3ContextFunctionArgument {
|
|
6
|
+
event: H3Event;
|
|
7
|
+
}
|
|
8
|
+
interface H3HandlerOptions<TContext extends BaseContext> {
|
|
9
|
+
context?: ContextFunction<[H3ContextFunctionArgument], TContext>;
|
|
10
|
+
}
|
|
11
|
+
declare function startServerAndCreateH3Handler(server: ApolloServer<BaseContext>, options?: H3HandlerOptions<BaseContext>): EventHandler;
|
|
12
|
+
declare function startServerAndCreateH3Handler<TContext extends BaseContext>(server: ApolloServer<TContext>, options: WithRequired<H3HandlerOptions<TContext>, 'context'>): EventHandler;
|
|
13
|
+
|
|
14
|
+
export { type H3ContextFunctionArgument, type H3HandlerOptions, startServerAndCreateH3Handler };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseContext, ContextFunction, ApolloServer } from '@apollo/server';
|
|
2
|
+
import { H3Event, EventHandler } from 'h3';
|
|
3
|
+
|
|
4
|
+
type WithRequired<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
5
|
+
interface H3ContextFunctionArgument {
|
|
6
|
+
event: H3Event;
|
|
7
|
+
}
|
|
8
|
+
interface H3HandlerOptions<TContext extends BaseContext> {
|
|
9
|
+
context?: ContextFunction<[H3ContextFunctionArgument], TContext>;
|
|
10
|
+
}
|
|
11
|
+
declare function startServerAndCreateH3Handler(server: ApolloServer<BaseContext>, options?: H3HandlerOptions<BaseContext>): EventHandler;
|
|
12
|
+
declare function startServerAndCreateH3Handler<TContext extends BaseContext>(server: ApolloServer<TContext>, options: WithRequired<H3HandlerOptions<TContext>, 'context'>): EventHandler;
|
|
13
|
+
|
|
14
|
+
export { type H3ContextFunctionArgument, type H3HandlerOptions, startServerAndCreateH3Handler };
|
package/dist/index.d.ts
CHANGED
|
@@ -11,4 +11,4 @@ interface H3HandlerOptions<TContext extends BaseContext> {
|
|
|
11
11
|
declare function startServerAndCreateH3Handler(server: ApolloServer<BaseContext>, options?: H3HandlerOptions<BaseContext>): EventHandler;
|
|
12
12
|
declare function startServerAndCreateH3Handler<TContext extends BaseContext>(server: ApolloServer<TContext>, options: WithRequired<H3HandlerOptions<TContext>, 'context'>): EventHandler;
|
|
13
13
|
|
|
14
|
-
export { H3ContextFunctionArgument, H3HandlerOptions, startServerAndCreateH3Handler };
|
|
14
|
+
export { type H3ContextFunctionArgument, type H3HandlerOptions, startServerAndCreateH3Handler };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HeaderMap } from '@apollo/server';
|
|
2
|
+
import { eventHandler, isMethod, setHeaders, getHeaders, readBody } from 'h3';
|
|
2
3
|
|
|
3
4
|
function startServerAndCreateH3Handler(server, options) {
|
|
4
5
|
server.startInBackgroundHandlingStartupErrorsByLoggingAndFailingAllRequests();
|
|
@@ -39,7 +40,7 @@ async function toGraphqlRequest(event) {
|
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
function normalizeHeaders(headers) {
|
|
42
|
-
const headerMap =
|
|
43
|
+
const headerMap = new HeaderMap();
|
|
43
44
|
for (const [key, value] of Object.entries(headers)) {
|
|
44
45
|
if (Array.isArray(value)) {
|
|
45
46
|
headerMap.set(key, value.join(","));
|
|
@@ -58,13 +59,7 @@ function normalizeQueryString(url) {
|
|
|
58
59
|
async function normalizeBody(event) {
|
|
59
60
|
const PayloadMethods = ["PATCH", "POST", "PUT", "DELETE"];
|
|
60
61
|
if (isMethod(event, PayloadMethods)) {
|
|
61
|
-
|
|
62
|
-
const content = typeof body === "string" ? body : body?.toString();
|
|
63
|
-
if (getRequestHeader(event, "content-type") === "application/json") {
|
|
64
|
-
return content ? JSON.parse(content) : {};
|
|
65
|
-
} else {
|
|
66
|
-
return content;
|
|
67
|
-
}
|
|
62
|
+
return await readBody(event);
|
|
68
63
|
}
|
|
69
64
|
}
|
|
70
65
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@as-integrations/h3",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "An Apollo Server integration for use with h3 or Nuxt",
|
|
5
5
|
"repository": "github:apollo-server-integrations/apollo-server-integration-h3",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
11
|
"import": "./dist/index.mjs",
|
|
13
12
|
"require": "./dist/index.cjs"
|
|
14
13
|
}
|
|
@@ -21,31 +20,31 @@
|
|
|
21
20
|
],
|
|
22
21
|
"peerDependencies": {
|
|
23
22
|
"@apollo/server": "^4.1.1",
|
|
24
|
-
"h3": "^
|
|
23
|
+
"h3": "^1.8.0"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
27
|
-
"@apollo/server": "^4.
|
|
28
|
-
"@apollo/server-integration-testsuite": "^4.
|
|
29
|
-
"@apollo/utils.withrequired": "^
|
|
30
|
-
"@jest/globals": "^29.
|
|
26
|
+
"@apollo/server": "^4.9.1",
|
|
27
|
+
"@apollo/server-integration-testsuite": "^4.9.1",
|
|
28
|
+
"@apollo/utils.withrequired": "^3.0.0",
|
|
29
|
+
"@jest/globals": "^29.6.3",
|
|
31
30
|
"@nuxtjs/eslint-config-typescript": "^12.0.0",
|
|
32
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
33
|
-
"@typescript-eslint/parser": "^
|
|
34
|
-
"@vitest/coverage-c8": "^0.
|
|
35
|
-
"eslint": "^8.
|
|
36
|
-
"eslint-config-prettier": "^
|
|
37
|
-
"eslint-plugin-unused-imports": "^
|
|
38
|
-
"graphql": "^16.
|
|
39
|
-
"h3": "^1.0
|
|
40
|
-
"jest": "^29.
|
|
41
|
-
"prettier": "^
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "^6.4.1",
|
|
32
|
+
"@typescript-eslint/parser": "^6.4.1",
|
|
33
|
+
"@vitest/coverage-c8": "^0.33.0",
|
|
34
|
+
"eslint": "^8.47.0",
|
|
35
|
+
"eslint-config-prettier": "^9.0.0",
|
|
36
|
+
"eslint-plugin-unused-imports": "^3.0.0",
|
|
37
|
+
"graphql": "^16.8.0",
|
|
38
|
+
"h3": "^1.8.0",
|
|
39
|
+
"jest": "^29.6.3",
|
|
40
|
+
"prettier": "^3.0.2",
|
|
42
41
|
"standard-version": "^9.5.0",
|
|
43
|
-
"ts-jest": "^29.
|
|
44
|
-
"typescript": "^
|
|
45
|
-
"unbuild": "^
|
|
46
|
-
"vitest": "^0.
|
|
42
|
+
"ts-jest": "^29.1.1",
|
|
43
|
+
"typescript": "^5.1.6",
|
|
44
|
+
"unbuild": "^2.0.0",
|
|
45
|
+
"vitest": "^0.34.2"
|
|
47
46
|
},
|
|
48
|
-
"packageManager": "pnpm@
|
|
47
|
+
"packageManager": "pnpm@8.6.12",
|
|
49
48
|
"scripts": {
|
|
50
49
|
"build": "unbuild",
|
|
51
50
|
"test": "vitest dev",
|