altair-koa-middleware 5.0.9 → 5.0.15

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/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  This is a koa middleware for mounting an instance of altair GraphQL client.
6
6
 
7
7
  ### Installation
8
+
8
9
  This is a node module and can be installed using npm:
9
10
 
10
11
  ```
@@ -36,9 +37,7 @@ createRouteExplorer({
36
37
  },
37
38
  });
38
39
 
39
- app
40
- .use(router.routes())
41
- .use(router.allowedMethods());
40
+ app.use(router.routes()).use(router.allowedMethods());
42
41
 
43
42
  app.listen(3500);
44
43
 
@@ -48,6 +47,7 @@ app.listen(3500);
48
47
  An instance of Altair GraphQL Client would be available at `/altair` of your server.
49
48
 
50
49
  ### Contributing
50
+
51
51
  Everyone is welcome to contribute. See anything that needs improving, create an issue. And if you're up for it, create a PR! :D
52
52
 
53
53
  ### License
@@ -1,7 +1,8 @@
1
1
  import * as KoaRouter from '@koa/router';
2
2
  import { RenderOptions } from 'altair-static';
3
- export declare const createRouteExplorer: ({ router, url, opts }: {
3
+ export declare const createRouteExplorer: ({ router, url, opts, }: {
4
4
  router: KoaRouter;
5
5
  url: string;
6
6
  opts: RenderOptions;
7
7
  }) => void;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createRouteExplorer = void 0;
4
4
  const send = require("koa-send");
5
5
  const altair_static_1 = require("altair-static");
6
- const createRouteExplorer = ({ router, url, opts }) => {
6
+ const createRouteExplorer = ({ router, url, opts, }) => {
7
7
  router.get(url, async (ctx, next) => {
8
8
  ctx.body = (0, altair_static_1.renderAltair)({ baseURL: ctx.url.replace(/\/?$/, '/'), ...opts });
9
9
  await next();
@@ -14,7 +14,8 @@ const createRouteExplorer = ({ router, url, opts }) => {
14
14
  ctx.redirect(`/favicon.ico`);
15
15
  });
16
16
  router.get(`${url}/:path+`, async (ctx) => {
17
- await send(ctx, ctx.params.path, { root: (0, altair_static_1.getDistDirectory)() });
17
+ const path = ctx.params.path;
18
+ await send(ctx, path || '', { root: (0, altair_static_1.getDistDirectory)() });
18
19
  });
19
20
  };
20
21
  exports.createRouteExplorer = createRouteExplorer;
package/example/index.ts CHANGED
@@ -20,8 +20,6 @@ createRouteExplorer({
20
20
  },
21
21
  });
22
22
 
23
- app
24
- .use(router.routes())
25
- .use(router.allowedMethods());
23
+ app.use(router.routes()).use(router.allowedMethods());
26
24
 
27
25
  app.listen(port, () => console.log(`Listening on port ${port}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "altair-koa-middleware",
3
- "version": "5.0.9",
3
+ "version": "5.0.15",
4
4
  "description": "Koa middleware for altair graphql client",
5
5
  "main": "./build/src/index.js",
6
6
  "types": "./build/src/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "homepage": "https://github.com/altair-graphql/altair#readme",
32
32
  "dependencies": {
33
33
  "@koa/router": "^10.1.1",
34
- "altair-static": "^5.0.9",
34
+ "altair-static": "^5.0.15",
35
35
  "koa-send": "^5.0.1"
36
36
  },
37
37
  "devDependencies": {
@@ -46,11 +46,11 @@
46
46
  "supertest": "^6.1.6",
47
47
  "ts-jest": "28.0.7",
48
48
  "ts-node": "^10.2.1",
49
- "typescript": "4.7.4"
49
+ "typescript": "^4.9.4"
50
50
  },
51
51
  "funding": {
52
52
  "type": "opencollective",
53
53
  "url": "https://opencollective.com/altair"
54
54
  },
55
- "gitHead": "bb19c4d45b1c36dc8f380d87d05297c63f447a2e"
55
+ "gitHead": "a460a8fcb8c3573ae4989769565f354ffdb92102"
56
56
  }
package/src/index.ts CHANGED
@@ -4,21 +4,29 @@ import * as send from 'koa-send';
4
4
  import * as KoaRouter from '@koa/router';
5
5
  import { getDistDirectory, renderAltair, RenderOptions } from 'altair-static';
6
6
 
7
- export const createRouteExplorer = ({ router, url, opts }: { router: KoaRouter, url: string, opts: RenderOptions }) => {
7
+ export const createRouteExplorer = ({
8
+ router,
9
+ url,
10
+ opts,
11
+ }: {
12
+ router: KoaRouter;
13
+ url: string;
14
+ opts: RenderOptions;
15
+ }) => {
8
16
  router.get(url, async (ctx, next) => {
9
-
10
17
  ctx.body = renderAltair({ baseURL: ctx.url.replace(/\/?$/, '/'), ...opts });
11
18
 
12
19
  await next();
13
- })
20
+ });
14
21
 
15
22
  // Use the main favicon for my API subdomain.
16
23
  router.get(`${url}/favicon.ico`, ctx => {
17
24
  ctx.status = 301;
18
25
  ctx.redirect(`/favicon.ico`);
19
- })
26
+ });
20
27
 
21
28
  router.get(`${url}/:path+`, async ctx => {
22
- await send(ctx, ctx.params.path, { root: getDistDirectory() });
23
- })
29
+ const path = ctx.params.path;
30
+ await send(ctx, path || '', { root: getDistDirectory() });
31
+ });
24
32
  };
package/tsconfig.json CHANGED
@@ -1,20 +1,13 @@
1
1
  {
2
- "exclude": [
3
- "example/**",
4
- "build/**/*.d.ts"
5
- ],
2
+ "extends": "../../tsconfig.json",
3
+ "exclude": ["example/**", "build/**/*.d.ts"],
6
4
  "compilerOptions": {
7
5
  "outDir": "build/",
8
6
  "rootDir": "./",
9
7
  "declaration": true,
10
8
  "target": "es2020",
11
9
  "module": "commonjs",
12
- "lib": [
13
- "dom",
14
- "esnext"
15
- ],
16
- "types": [
17
- "node"
18
- ]
10
+ "lib": ["dom", "esnext"],
11
+ "types": ["node"]
19
12
  }
20
13
  }