mirror of
https://github.com/kamask-dev/pchelpmaster.git
synced 2026-11-11 05:49:38 +00:00
refactor(proxy): export ProxyRules type from proxy.conf.mjs
This commit is contained in:
+3
-1
@@ -1,7 +1,9 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
// Повторяет `location /pb/` из docs/architecture.md (раздел 7): только пути с префиксом `/pb/`, префикс срезается.
|
// Повторяет `location /pb/` из docs/architecture.md (раздел 7): только пути с префиксом `/pb/`, префикс срезается.
|
||||||
// Формат — `server.proxy` dev-сервера Vite (@angular/build).
|
// Формат — `server.proxy` dev-сервера Vite (@angular/build).
|
||||||
/** @type {Record<string, { target: string; changeOrigin?: boolean; rewrite?: (path: string) => string }>} */
|
/** @typedef {Record<string, { target: string; changeOrigin?: boolean; rewrite?: (path: string) => string }>} ProxyRules */
|
||||||
|
|
||||||
|
/** @type {ProxyRules} */
|
||||||
export default {
|
export default {
|
||||||
'/pb/': {
|
'/pb/': {
|
||||||
target: process.env['PB_URL'] || 'http://127.0.0.1:8090',
|
target: process.env['PB_URL'] || 'http://127.0.0.1:8090',
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
// Проверяет правило `/pb/` в proxy.conf.mjs: оно должно повторять `location /pb/` из nginx и серверный `PB_URL`.
|
// Проверяет правило `/pb/` в proxy.conf.mjs: оно должно повторять `location /pb/` из nginx и серверный `PB_URL`.
|
||||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||||
|
import type { ProxyRules } from '../../proxy.conf.mjs';
|
||||||
|
|
||||||
type Rules = typeof import('../../proxy.conf.mjs').default;
|
async function loadRules(pbUrl: string | undefined): Promise<ProxyRules> {
|
||||||
|
|
||||||
async function loadRules(pbUrl: string | undefined): Promise<Rules> {
|
|
||||||
vi.stubEnv('PB_URL', pbUrl);
|
vi.stubEnv('PB_URL', pbUrl);
|
||||||
vi.resetModules();
|
vi.resetModules();
|
||||||
return (await import('../../proxy.conf.mjs')).default;
|
return (await import('../../proxy.conf.mjs')).default;
|
||||||
|
|||||||
Reference in New Issue
Block a user