From 00a3e9ade635d12111445faa4e66cdd81b09d0f5 Mon Sep 17 00:00:00 2001 From: Pringgo Radianto Date: Mon, 12 Aug 2024 15:42:30 +0700 Subject: [PATCH] feat: add proxy console info --- src/module.ts | 2 +- src/runtime/server/plugin.ts | 4 +++- src/{ => runtime}/utils/path-rewrite.ts | 0 3 files changed, 4 insertions(+), 2 deletions(-) rename src/{ => runtime}/utils/path-rewrite.ts (100%) diff --git a/src/module.ts b/src/module.ts index 5efc926..aada2d8 100644 --- a/src/module.ts +++ b/src/module.ts @@ -29,7 +29,7 @@ export default defineNuxtModule({ let serverConfig = `export default []` - consola.info('Nuxt Proxy Party: Load server.config') + consola.start('Nuxt Proxy Party: Started') try { serverConfig = await readFile(serverConfigPath, 'utf8') } diff --git a/src/runtime/server/plugin.ts b/src/runtime/server/plugin.ts index 727b251..734df83 100644 --- a/src/runtime/server/plugin.ts +++ b/src/runtime/server/plugin.ts @@ -2,7 +2,7 @@ import { consola } from 'consola' import { defineEventHandler, getQuery, proxyRequest } from 'h3' import { withQuery, joinURL } from 'ufo' import type { ProxyParty } from '../../core' -import { rewritePath } from '../../utils/path-rewrite' +import { rewritePath } from '../utils/path-rewrite' import { defineNitroPlugin } from '#imports' // @ts-expect-error virtual file @@ -33,6 +33,8 @@ export default defineNitroPlugin(async ({ router }) => { const handler = proxyHandler(config) router.use(config.baseUrl, handler) router.use(`${config.baseUrl}/**`, handler) + + consola.success(`[Nuxt Proxy Party] Proxy created: ${config.baseUrl} -> ${config.target}`) }) } } diff --git a/src/utils/path-rewrite.ts b/src/runtime/utils/path-rewrite.ts similarity index 100% rename from src/utils/path-rewrite.ts rename to src/runtime/utils/path-rewrite.ts