@graphql-mesh/http 0.3.7 → 0.3.8-alpha-20230103084335-a555628ec
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/cjs/index.js +8 -15
- package/esm/index.js +8 -15
- package/package.json +3 -3
package/cjs/index.js
CHANGED
|
@@ -49,22 +49,15 @@ function createMeshHTTPHandler({ baseDir, getBuiltMesh, rawServeConfig = {}, pla
|
|
|
49
49
|
return undefined;
|
|
50
50
|
});
|
|
51
51
|
if (staticFiles) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const indexFile = await cross_helpers_1.fs.promises.readFile(indexPath);
|
|
57
|
-
return new router_1.Response(indexFile, {
|
|
58
|
-
status: 200,
|
|
59
|
-
headers: {
|
|
60
|
-
'Content-Type': 'text/html',
|
|
61
|
-
},
|
|
62
|
-
});
|
|
52
|
+
router.get('/:relativePath+', async (request) => {
|
|
53
|
+
let { relativePath } = request.params;
|
|
54
|
+
if (!relativePath) {
|
|
55
|
+
relativePath = 'index.html';
|
|
63
56
|
}
|
|
64
|
-
const
|
|
65
|
-
if (await (0, utils_1.pathExists)(
|
|
66
|
-
const
|
|
67
|
-
return new router_1.Response(
|
|
57
|
+
const absolutePath = cross_helpers_1.path.join(baseDir, staticFiles, relativePath);
|
|
58
|
+
if (await (0, utils_1.pathExists)(absolutePath)) {
|
|
59
|
+
const readStream = cross_helpers_1.fs.createReadStream(absolutePath);
|
|
60
|
+
return new router_1.Response(readStream, {
|
|
68
61
|
status: 200,
|
|
69
62
|
});
|
|
70
63
|
}
|
package/esm/index.js
CHANGED
|
@@ -46,22 +46,15 @@ export function createMeshHTTPHandler({ baseDir, getBuiltMesh, rawServeConfig =
|
|
|
46
46
|
return undefined;
|
|
47
47
|
});
|
|
48
48
|
if (staticFiles) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const indexFile = await fs.promises.readFile(indexPath);
|
|
54
|
-
return new Response(indexFile, {
|
|
55
|
-
status: 200,
|
|
56
|
-
headers: {
|
|
57
|
-
'Content-Type': 'text/html',
|
|
58
|
-
},
|
|
59
|
-
});
|
|
49
|
+
router.get('/:relativePath+', async (request) => {
|
|
50
|
+
let { relativePath } = request.params;
|
|
51
|
+
if (!relativePath) {
|
|
52
|
+
relativePath = 'index.html';
|
|
60
53
|
}
|
|
61
|
-
const
|
|
62
|
-
if (await pathExists(
|
|
63
|
-
const
|
|
64
|
-
return new Response(
|
|
54
|
+
const absolutePath = path.join(baseDir, staticFiles, relativePath);
|
|
55
|
+
if (await pathExists(absolutePath)) {
|
|
56
|
+
const readStream = fs.createReadStream(absolutePath);
|
|
57
|
+
return new Response(readStream, {
|
|
65
58
|
status: 200,
|
|
66
59
|
});
|
|
67
60
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/http",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8-alpha-20230103084335-a555628ec",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "*"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@graphql-mesh/cross-helpers": "0.3.0",
|
|
10
|
-
"@graphql-mesh/runtime": "0.46.
|
|
10
|
+
"@graphql-mesh/runtime": "0.46.5-alpha-20230103084335-a555628ec",
|
|
11
11
|
"@graphql-mesh/types": "0.89.3",
|
|
12
12
|
"@graphql-mesh/utils": "0.43.4",
|
|
13
|
-
"@whatwg-node/router": "0.
|
|
13
|
+
"@whatwg-node/router": "0.1.2",
|
|
14
14
|
"graphql-yoga": "3.2.1",
|
|
15
15
|
"itty-router-extras": "0.4.2",
|
|
16
16
|
"tslib": "^2.4.0"
|