mirror of
https://github.com/logto-io/logto.git
synced 2024-12-30 20:33:54 -05:00
feat: pipe sign-in routes to playground url
This commit is contained in:
parent
fca5482e5c
commit
27590ec4ad
3 changed files with 10 additions and 3 deletions
|
@ -16,6 +16,7 @@
|
||||||
"@logto/schemas": "^1.0.1",
|
"@logto/schemas": "^1.0.1",
|
||||||
"dayjs": "^1.10.5",
|
"dayjs": "^1.10.5",
|
||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
|
"got": "^11.8.2",
|
||||||
"koa": "^2.13.1",
|
"koa": "^2.13.1",
|
||||||
"koa-logger": "^3.2.1",
|
"koa-logger": "^3.2.1",
|
||||||
"koa-mount": "^4.0.0",
|
"koa-mount": "^4.0.0",
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
|
import got from 'got';
|
||||||
import Koa from 'koa';
|
import Koa from 'koa';
|
||||||
import Router from 'koa-router';
|
import Router from 'koa-router';
|
||||||
|
import { promisify } from 'util';
|
||||||
|
import stream from 'stream';
|
||||||
import { signInRoute } from '../consts';
|
import { signInRoute } from '../consts';
|
||||||
|
import { getEnv } from '../utils';
|
||||||
|
|
||||||
|
const pipeline = promisify(stream.pipeline);
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
|
|
||||||
router.get(signInRoute, (ctx) => {
|
router.get(new RegExp(`^${signInRoute}(?:/|$)`), async (ctx) => {
|
||||||
ctx.body = 'Signing in';
|
// CAUTION: this is for dev purpose only, add a switch if needed
|
||||||
|
await pipeline(got.stream.get(getEnv('PLAYGROUND_URL')), ctx.res);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function initRouter(app: Koa): void {
|
export default function initRouter(app: Koa): void {
|
||||||
|
|
|
@ -2579,7 +2579,7 @@ globby@^9.2.0:
|
||||||
pify "^4.0.1"
|
pify "^4.0.1"
|
||||||
slash "^2.0.0"
|
slash "^2.0.0"
|
||||||
|
|
||||||
got@^11.7.0:
|
got@^11.7.0, got@^11.8.2:
|
||||||
version "11.8.2"
|
version "11.8.2"
|
||||||
resolved "https://registry.yarnpkg.com/got/-/got-11.8.2.tgz#7abb3959ea28c31f3576f1576c1effce23f33599"
|
resolved "https://registry.yarnpkg.com/got/-/got-11.8.2.tgz#7abb3959ea28c31f3576f1576c1effce23f33599"
|
||||||
integrity sha512-D0QywKgIe30ODs+fm8wMZiAcZjypcCodPNuMz5H9Mny7RJ+IjJ10BdmGW7OM7fHXP+O7r6ZwapQ/YQmMSvB0UQ==
|
integrity sha512-D0QywKgIe30ODs+fm8wMZiAcZjypcCodPNuMz5H9Mny7RJ+IjJ10BdmGW7OM7fHXP+O7r6ZwapQ/YQmMSvB0UQ==
|
||||||
|
|
Loading…
Reference in a new issue