mirror of
https://github.com/xtr-dev/rondevu-server.git
synced 2025-12-10 10:53:24 +00:00
Fix Cloudflare Worker compatibility for version endpoint
- Add version parameter to AppConfig interface - Pass version from environment config instead of using process.env - Update worker.ts to pass VERSION environment variable - Update wrangler.toml with VERSION variable - Update deploy script to automatically set VERSION to git commit hash This fixes the 'process is not defined' error in Cloudflare Workers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
"dev": "ts-node src/index.ts",
|
"dev": "ts-node src/index.ts",
|
||||||
"start": "node dist/index.js",
|
"start": "node dist/index.js",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"deploy": "npx wrangler deploy src/worker.ts"
|
"deploy": "npx wrangler deploy src/worker.ts --var VERSION:$(git rev-parse --short HEAD)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@cloudflare/workers-types": "^4.20251014.0",
|
"@cloudflare/workers-types": "^4.20251014.0",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import type { Context } from 'hono';
|
|||||||
export interface AppConfig {
|
export interface AppConfig {
|
||||||
sessionTimeout: number;
|
sessionTimeout: number;
|
||||||
corsOrigins: string[];
|
corsOrigins: string[];
|
||||||
|
version?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,7 +55,7 @@ export function createApp(storage: Storage, config: AppConfig) {
|
|||||||
*/
|
*/
|
||||||
app.get('/', (c) => {
|
app.get('/', (c) => {
|
||||||
return c.json({
|
return c.json({
|
||||||
version: process.env.RONDEVU_VERSION || 'unknown'
|
version: config.version || 'unknown'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ async function main() {
|
|||||||
const app = createApp(storage, {
|
const app = createApp(storage, {
|
||||||
sessionTimeout: config.sessionTimeout,
|
sessionTimeout: config.sessionTimeout,
|
||||||
corsOrigins: config.corsOrigins,
|
corsOrigins: config.corsOrigins,
|
||||||
|
version: process.env.RONDEVU_VERSION || 'unknown',
|
||||||
});
|
});
|
||||||
|
|
||||||
const server = serve({
|
const server = serve({
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export interface Env {
|
|||||||
DB: D1Database;
|
DB: D1Database;
|
||||||
SESSION_TIMEOUT?: string;
|
SESSION_TIMEOUT?: string;
|
||||||
CORS_ORIGINS?: string;
|
CORS_ORIGINS?: string;
|
||||||
|
VERSION?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,6 +32,7 @@ export default {
|
|||||||
const app = createApp(storage, {
|
const app = createApp(storage, {
|
||||||
sessionTimeout,
|
sessionTimeout,
|
||||||
corsOrigins,
|
corsOrigins,
|
||||||
|
version: env.VERSION || 'unknown',
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle request
|
// Handle request
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ database_id = "b94e3f71-816d-455b-a89d-927fa49532d0"
|
|||||||
[vars]
|
[vars]
|
||||||
SESSION_TIMEOUT = "300000" # 5 minutes in milliseconds
|
SESSION_TIMEOUT = "300000" # 5 minutes in milliseconds
|
||||||
CORS_ORIGINS = "*" # Comma-separated list of allowed origins
|
CORS_ORIGINS = "*" # Comma-separated list of allowed origins
|
||||||
|
VERSION = "unknown" # Set to git commit hash before deploying
|
||||||
|
|
||||||
# Build configuration
|
# Build configuration
|
||||||
[build]
|
[build]
|
||||||
|
|||||||
Reference in New Issue
Block a user