New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Koa #617
Comments
@jaydenseric Nice to see someone trying to build around Altair 🙂What challenges are you facing with using This is how |
I worked out how to get it working with import altair from 'altair-static'
import send from 'koa-send'
import { ROUTE_PATH_GRAPHQL, ROUTE_PATH_EXPLORER } from '../config'
/**
* Creates the explorer route.
*/
export const createRouteExplorer = ({ router }) => {
router.get(ROUTE_PATH_EXPLORER, async (ctx, next) => {
if (ctx.path.substr(-1) !== '/') {
ctx.status = 301
ctx.redirect(`${ctx.path}/`)
}
ctx.body = altair.renderAltair({
endpointURL: ROUTE_PATH_GRAPHQL
})
await next()
})
// I prefer to use the main favicon for my API subdomain.
router.get(`${ROUTE_PATH_EXPLORER}/favicon.ico`, ctx => {
ctx.status = 301
ctx.redirect(`/favicon.ico`)
})
router.get(`${ROUTE_PATH_EXPLORER}/:path+`, async ctx => {
await send(ctx, ctx.params.path, { root: altair.getDistDirectory() })
})
} To publish generic middleware you probably wouldn't want to assume the presence of |
Nice! When are you going to publish the koa middleware npm package?
|
The Still anticipating the release of your koa package! 😊 |
@jaydenseric Would you publish this as a package, or you would prefer if I published it myself? |
You've been very encouraging! It's probably best for the community though for all the different middlewares to be available side by side with |
Alright. |
Thanks for releasing the Koa middleware, I'll give it a go now :) It would be nice to mention the koa middleware in the readme, next to the Express content: https://github.com/imolorhe/altair#usage-with-express
|
Yeah, good point. |
Is your feature request related to a problem? Please describe.
I struggling to work out how to serve Altair using
altair-static
via a custom route in a Koa app.Describe the solution you'd like
Official Koa middleware that would allow Alitair to be served via a custom route in a Koa app.
The text was updated successfully, but these errors were encountered: