altair-koa-middleware
Advanced tools
Comparing version 5.0.9 to 5.0.14
import * as KoaRouter from '@koa/router'; | ||
import { RenderOptions } from 'altair-static'; | ||
export declare const createRouteExplorer: ({ router, url, opts }: { | ||
export declare const createRouteExplorer: ({ router, url, opts, }: { | ||
router: KoaRouter; | ||
@@ -8,1 +8,2 @@ url: string; | ||
}) => void; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -6,3 +6,3 @@ 'use strict'; | ||
const altair_static_1 = require("altair-static"); | ||
const createRouteExplorer = ({ router, url, opts }) => { | ||
const createRouteExplorer = ({ router, url, opts, }) => { | ||
router.get(url, async (ctx, next) => { | ||
@@ -18,5 +18,6 @@ ctx.body = (0, altair_static_1.renderAltair)({ baseURL: ctx.url.replace(/\/?$/, '/'), ...opts }); | ||
router.get(`${url}/:path+`, async (ctx) => { | ||
await send(ctx, ctx.params.path, { root: (0, altair_static_1.getDistDirectory)() }); | ||
const path = ctx.params.path; | ||
await send(ctx, path || '', { root: (0, altair_static_1.getDistDirectory)() }); | ||
}); | ||
}; | ||
exports.createRouteExplorer = createRouteExplorer; |
@@ -23,6 +23,4 @@ import * as Koa from 'koa'; | ||
app | ||
.use(router.routes()) | ||
.use(router.allowedMethods()); | ||
app.use(router.routes()).use(router.allowedMethods()); | ||
app.listen(port, () => console.log(`Listening on port ${port}`)); |
{ | ||
"name": "altair-koa-middleware", | ||
"version": "5.0.9", | ||
"version": "5.0.14", | ||
"description": "Koa middleware for altair graphql client", | ||
@@ -34,3 +34,3 @@ "main": "./build/src/index.js", | ||
"@koa/router": "^10.1.1", | ||
"altair-static": "^5.0.9", | ||
"altair-static": "^5.0.14", | ||
"koa-send": "^5.0.1" | ||
@@ -50,3 +50,3 @@ }, | ||
"ts-node": "^10.2.1", | ||
"typescript": "4.7.4" | ||
"typescript": "^4.9.4" | ||
}, | ||
@@ -57,3 +57,3 @@ "funding": { | ||
}, | ||
"gitHead": "bb19c4d45b1c36dc8f380d87d05297c63f447a2e" | ||
"gitHead": "973420e96faf2c099c806a26a119659c10c0f4ee" | ||
} |
@@ -8,2 +8,3 @@ # altair-koa-middleware | ||
### Installation | ||
This is a node module and can be installed using npm: | ||
@@ -40,5 +41,3 @@ | ||
app | ||
.use(router.routes()) | ||
.use(router.allowedMethods()); | ||
app.use(router.routes()).use(router.allowedMethods()); | ||
@@ -53,2 +52,3 @@ app.listen(3500); | ||
### Contributing | ||
Everyone is welcome to contribute. See anything that needs improving, create an issue. And if you're up for it, create a PR! :D | ||
@@ -55,0 +55,0 @@ |
@@ -7,9 +7,16 @@ 'use strict'; | ||
export const createRouteExplorer = ({ router, url, opts }: { router: KoaRouter, url: string, opts: RenderOptions }) => { | ||
export const createRouteExplorer = ({ | ||
router, | ||
url, | ||
opts, | ||
}: { | ||
router: KoaRouter; | ||
url: string; | ||
opts: RenderOptions; | ||
}) => { | ||
router.get(url, async (ctx, next) => { | ||
ctx.body = renderAltair({ baseURL: ctx.url.replace(/\/?$/, '/'), ...opts }); | ||
await next(); | ||
}) | ||
}); | ||
@@ -20,7 +27,8 @@ // Use the main favicon for my API subdomain. | ||
ctx.redirect(`/favicon.ico`); | ||
}) | ||
}); | ||
router.get(`${url}/:path+`, async ctx => { | ||
await send(ctx, ctx.params.path, { root: getDistDirectory() }); | ||
}) | ||
const path = ctx.params.path; | ||
await send(ctx, path || '', { root: getDistDirectory() }); | ||
}); | ||
}; |
{ | ||
"exclude": [ | ||
"example/**", | ||
"build/**/*.d.ts" | ||
], | ||
"extends": "../../tsconfig.json", | ||
"exclude": ["example/**", "build/**/*.d.ts"], | ||
"compilerOptions": { | ||
@@ -12,10 +10,5 @@ "outDir": "build/", | ||
"module": "commonjs", | ||
"lib": [ | ||
"dom", | ||
"esnext" | ||
], | ||
"types": [ | ||
"node" | ||
] | ||
"lib": ["dom", "esnext"], | ||
"types": ["node"] | ||
} | ||
} |
6626
89
Updatedaltair-static@^5.0.14