OCUS Job Hunter is a web application with a serverless backend built on Cloudflare. The backend provides APIs for features like feature toggles and Stripe integration.
Current Priority: Resolve a persistent HTTP 500 error in the Admin Dashboard's feature toggles API (/api/admin/dashboard-features).
This project relies heavily on the Cloudflare ecosystem. Here’s a guide to the key services used.
Cloudflare Pages is a platform for deploying and hosting web projects. It integrates directly with GitHub for a seamless CI/CD workflow.
git push to the main branch automatically triggers a new deployment.The backend logic is built using Cloudflare Functions, which are serverless functions that run on Cloudflare's edge network. In this project, they are deployed as part of the Pages application.
/functions directory determines the API endpoint URL. For example, /functions/api/hello.ts becomes the endpoint /api/hello.D1 is Cloudflare's serverless SQL database, built on SQLite. It's used to persist application data.
ocus-ticketscc9216e4-8167-486a-b174-89087493b2eaocus-tickets database contains the following tables:
activation_codesauth_settingscountdown_bannerscustomersdashboard_featuresextension_downloadsinvoicesordersproductssettingssqlite_sequenceticket_messagesticketsuser_downloadsusersDB. This binding must be configured in Settings > Functions > D1 database bindings for the Pages project.The Wrangler CLI allows you to develop and test the entire application locally.
# 1. Clone the repository
git clone https://github.com/Houman6460/OCUS-jub-hunter.git
cd OCUS-jub-hunter
# 2. Install dependencies
npm install
# 3. Run local server with D1 binding
npx wrangler pages dev --d1=DB
This command starts a local server and creates a local SQLite file to simulate the D1 database.
PUT /api/admin/dashboard-features.env.DB) is missing or misconfigured in the production environment.8244d8ba (This commit added logging to check the binding).onRequestPut: env.DB binding:. If it says MISSING, the binding needs to be created in the Cloudflare dashboard.
The premium extension download endpoint (/api/download-premium) did not correctly validate
user eligibility due to mismatches with the actual D1 schema and Stripe webhook behavior. Symptoms included
rejecting valid premium users and failing to log extension downloads.
customers.is_premium (actual: customers.subscription_status).orders.customer_id which does not exist (actual linkage: orders.customer_email and/or orders.user_id).activation_codes.is_active.extension_downloads.customer_id referencing customers.id.customers.subscription_status === "active". Users still keep users.is_premium for user-centric checks.status = 'completed' and positive final_amount, matching either orders.customer_email to the customer email or orders.user_id to the authenticated user.activation_codes.is_active when validating activation keys.extension_downloads with a valid customer_id from the customers table, capturing IP, user agent, and download token.subscription_status and user premium flags post-purchase.functions/api/download-premium.ts — endpoint logic updated.shared/schema.ts — authoritative D1 schema used to correct field names.functions/api/stripe-webhook.ts — purchase completion logic informing premium state.These annotated screenshots walk through the Cloudflare UI for deployments and D1. If images do not load, ensure the files exist under public/docs/screenshots/ (served at /docs/screenshots/ in production) with the filenames used below.
ocus-jub-hunter. Each commit to main triggers a deployment./documentation and /api routes).ocus-tickets with UUID cc9216e4-8167-486a-b174-89087493b2ea.dashboard_features.feature_key, is_enabled).PRAGMA table_info('dashboard_features'); for schema.feature_key, is_enabled, and timestamps.