Onboarding / Deployment Scripts / Marketing updates
This commit is contained in:
+28
-11
@@ -1,6 +1,7 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { connect } from 'node:net';
|
||||
import type { AddressInfo } from 'node:net';
|
||||
import { enhancedImages } from '@sveltejs/enhanced-img';
|
||||
import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import { svelteTesting } from '@testing-library/svelte/vite';
|
||||
import { defineConfig } from 'vitest/config';
|
||||
@@ -16,9 +17,14 @@ const appName = packageJson.name;
|
||||
const appVersion = packageJson.version;
|
||||
const viteVersion = packageJson.devDependencies?.vite ?? 'unknown';
|
||||
const svelteKitVersion = packageJson.devDependencies?.['@sveltejs/kit'] ?? 'unknown';
|
||||
const submitProxyPath = '/api/submit';
|
||||
const submitProxyTarget = 'http://localhost:8000';
|
||||
const submitProxyDestination = `${submitProxyTarget}/submit`;
|
||||
const proxyRoutes = {
|
||||
'/api/submit': '/submit',
|
||||
'/api/onboarding-submit': '/onboarding-submit',
|
||||
'/api/contract-submit': '/contract-submit',
|
||||
} as const;
|
||||
const submitProxyPath = '/api/submit';
|
||||
const submitProxyDestination = `${submitProxyTarget}${proxyRoutes[submitProxyPath]}`;
|
||||
|
||||
function resolvePort(target: URL) {
|
||||
if (target.port) {
|
||||
@@ -83,7 +89,7 @@ function createGoodwalkLogger() {
|
||||
if (
|
||||
typeof msg === 'string' &&
|
||||
msg.includes('[vite] http proxy error') &&
|
||||
(msg.includes('/submit') || msg.includes(submitProxyPath))
|
||||
(msg.includes('/submit') || msg.includes('/onboarding-submit') || msg.includes('/contract-submit'))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -161,21 +167,22 @@ function goodwalkDevServerPlugin(logger: ReturnType<typeof createLogger>): Plugi
|
||||
export default defineConfig(() => {
|
||||
const logger = createGoodwalkLogger();
|
||||
|
||||
const submitProxy: ProxyOptions = {
|
||||
const createMailProxy = (apiPath: keyof typeof proxyRoutes): ProxyOptions => ({
|
||||
target: submitProxyTarget,
|
||||
rewrite: (path) => path.replace(/^\/api\/submit/, '/submit'),
|
||||
rewrite: (path) => path.replace(apiPath, proxyRoutes[apiPath]),
|
||||
configure(proxy) {
|
||||
proxy.on('error', (error: NodeJS.ErrnoException, req, res) => {
|
||||
const { code, hint } = formatProxyError(error);
|
||||
const requestPath = req.url ?? submitProxyPath;
|
||||
const requestPath = req.url ?? apiPath;
|
||||
const requestMethod = req.method ?? 'POST';
|
||||
const targetPath = `${submitProxyTarget}${proxyRoutes[apiPath]}`;
|
||||
|
||||
logger.error(
|
||||
[
|
||||
'',
|
||||
'[goodwalk] Booking proxy failed',
|
||||
'[goodwalk] Mail proxy failed',
|
||||
`[goodwalk] Request: ${requestMethod} ${requestPath}`,
|
||||
`[goodwalk] Target: ${submitProxyDestination}`,
|
||||
`[goodwalk] Target: ${targetPath}`,
|
||||
`[goodwalk] Code: ${code}`,
|
||||
`[goodwalk] Message: ${error.message}`,
|
||||
`[goodwalk] Hint: ${hint}`,
|
||||
@@ -194,14 +201,24 @@ export default defineConfig(() => {
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
customLogger: logger,
|
||||
plugins: [goodwalkDevServerPlugin(logger), svelteTesting({ autoCleanup: false }), sveltekit()],
|
||||
plugins: [goodwalkDevServerPlugin(logger), enhancedImages(), svelteTesting({ autoCleanup: false }), sveltekit()],
|
||||
server: {
|
||||
proxy: {
|
||||
[submitProxyPath]: submitProxy
|
||||
'/api/submit': createMailProxy('/api/submit'),
|
||||
'/api/onboarding-submit': createMailProxy('/api/onboarding-submit'),
|
||||
'/api/contract-submit': createMailProxy('/api/contract-submit'),
|
||||
'/api/auth': {
|
||||
target: submitProxyTarget,
|
||||
rewrite: (path) => path.replace('/api/auth', '/auth'),
|
||||
},
|
||||
'/api/save-draft': {
|
||||
target: submitProxyTarget,
|
||||
rewrite: (path) => path.replace('/api/save-draft', '/auth/save-draft'),
|
||||
},
|
||||
}
|
||||
},
|
||||
test: {
|
||||
|
||||
Reference in New Issue
Block a user