chore: update start script in package.json and adjust Svelte adapter configuration for improved deployment flexibility
This commit is contained in:
+7
-1
@@ -54,7 +54,13 @@ export const app = new Hono()
|
||||
)
|
||||
.use('*', rateLimiter)
|
||||
.use('*', async (c, next) => {
|
||||
const session = await auth.api.getSession({ headers: c.req.raw.headers });
|
||||
let session: Awaited<ReturnType<typeof auth.api.getSession>> | null = null;
|
||||
|
||||
try {
|
||||
session = await auth.api.getSession({ headers: c.req.raw.headers });
|
||||
} catch (error) {
|
||||
console.error('auth.api.getSession error:', error);
|
||||
}
|
||||
|
||||
if (!session) {
|
||||
c.set('user', null);
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dotenv/config';
|
||||
|
||||
import { API_PORT } from '@api/constants';
|
||||
import { app } from '@api/app';
|
||||
import { env } from '@api/config/env';
|
||||
import { configureOpenAPI } from '@api/utils/openapi';
|
||||
import { connectRedis } from '@api/utils/redis/redis';
|
||||
import { serve } from '@hono/node-server';
|
||||
@@ -16,12 +17,17 @@ async function startServer() {
|
||||
|
||||
serve({ fetch: app.fetch, port: API_PORT });
|
||||
|
||||
showRoutes(app, { colorize: true });
|
||||
if (env.NODE_ENV !== 'production') {
|
||||
showRoutes(app, { colorize: true });
|
||||
}
|
||||
}
|
||||
|
||||
configureOpenAPI(app);
|
||||
|
||||
startServer().catch((error) => {
|
||||
console.error('Failed to start server:', error);
|
||||
if (error instanceof Error && error.stack) {
|
||||
console.error(error.stack);
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
@@ -28,8 +28,8 @@ export function mountQueueDashboard(app: Hono<any, any, any>): void {
|
||||
|
||||
const isProduction = env.NODE_ENV === 'production';
|
||||
if (isProduction && !canEnforceProdAuth()) {
|
||||
console.warn(
|
||||
'Queue dashboard not mounted: NODE_ENV=production requires QUEUE_DASHBOARD_ADMIN_EMAILS or QUEUE_DASHBOARD_TOKEN.'
|
||||
console.info(
|
||||
'BullMQ dashboard (/admin/queues) not mounted in production. Set QUEUE_DASHBOARD_ADMIN_EMAILS or QUEUE_DASHBOARD_TOKEN to enable it.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"lint:fix": "eslint ./src --fix",
|
||||
"clean": "rm -rf node_modules",
|
||||
"format": "prettier --write .",
|
||||
"start": "node build",
|
||||
"start": "node build/index.js",
|
||||
"prepare": "svelte-kit sync",
|
||||
"test": "jest",
|
||||
"test:watch": "pnpm run test --watch",
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import 'dotenv/config';
|
||||
|
||||
import adapterAuto from '@sveltejs/adapter-auto';
|
||||
import adapterNode from '@sveltejs/adapter-node';
|
||||
import { getCspDomains } from './src/lib/utils/csp-domains.js';
|
||||
import path from 'path';
|
||||
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
||||
|
||||
const isSelfHosted = process.env.PUBLIC_IS_SELFHOSTED === 'true';
|
||||
const IS_CLOUDFLARE = process.env.CI_ENVIRONMENT === 'cloudflare';
|
||||
|
||||
const adapterCloudflare = IS_CLOUDFLARE ? (await import('@sveltejs/adapter-cloudflare')).default : null;
|
||||
const isSelfHosted = process.env.PUBLIC_IS_SELFHOSTED === 'true';
|
||||
const csp = getCspDomains(isSelfHosted, process.env.PUBLIC_SERVER_URL);
|
||||
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
const config = {
|
||||
preprocess: [vitePreprocess({})],
|
||||
kit: {
|
||||
adapter: IS_CLOUDFLARE ? adapterCloudflare() : isSelfHosted ? adapterNode() : adapterAuto(),
|
||||
// Default: Node server (Render, Docker). Opt into Cloudflare Pages only when CI_ENVIRONMENT=cloudflare.
|
||||
adapter: IS_CLOUDFLARE ? adapterCloudflare() : adapterNode(),
|
||||
alias: {
|
||||
$lib: path.resolve('./src/lib'),
|
||||
$features: path.resolve('./src/lib/features'),
|
||||
|
||||
@@ -49,7 +49,13 @@ function resolveUrl(override?: string): string {
|
||||
export function createRedisConnection(options: RedisConnectionOptions = {}): Redis {
|
||||
const { url, ...rest } = options;
|
||||
const resolved = resolveUrl(url);
|
||||
return new IORedis(resolved, { ...DEFAULT_OPTIONS, ...rest });
|
||||
const connection = new IORedis(resolved, { ...DEFAULT_OPTIONS, ...rest });
|
||||
|
||||
connection.on('error', (error) => {
|
||||
console.error('BullMQ Redis connection error:', error);
|
||||
});
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
let sharedConnection: Redis | undefined;
|
||||
|
||||
Reference in New Issue
Block a user