v0.4.0: Remove free tier, add public demo endpoint with watermark
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 12m31s
Promote to Production / Deploy to Production (push) Successful in 2m26s

- Remove free account signup flow entirely
- Add POST /v1/demo/html and /v1/demo/markdown (public, no auth)
- Demo: 5 requests/hour per IP, 50KB body limit, watermarked PDFs
- Landing page: interactive playground replaces 'Get Free API Key'
- Pricing: Demo (free) + Pro (€9/mo), no more Free tier
- /v1/signup returns 410 Gone with redirect to demo/pro
- Keep /v1/recover for existing Pro users
- Update JSON-LD, API discovery, verify page text
This commit is contained in:
DocFast Bot 2026-02-20 07:32:45 +00:00
parent 9095175141
commit 53755d6093
6 changed files with 299 additions and 240 deletions

View file

@ -1,14 +1,5 @@
var signupEmail = '';
var recoverEmail = '';
function showState(state) {
['signupInitial', 'signupLoading', 'signupVerify', 'signupResult'].forEach(function(id) {
var el = document.getElementById(id);
if (el) el.classList.remove('active');
});
document.getElementById(state).classList.add('active');
}
function showRecoverState(state) {
['recoverInitial', 'recoverLoading', 'recoverVerify', 'recoverResult'].forEach(function(id) {
var el = document.getElementById(id);
@ -17,23 +8,7 @@ function showRecoverState(state) {
document.getElementById(state).classList.add('active');
}
function openSignup() {
document.getElementById('signupModal').classList.add('active');
showState('signupInitial');
document.getElementById('signupError').style.display = 'none';
document.getElementById('verifyError').style.display = 'none';
document.getElementById('signupEmail').value = '';
document.getElementById('verifyCode').value = '';
signupEmail = '';
setTimeout(function() { document.getElementById('signupEmail').focus(); }, 100);
}
function closeSignup() {
document.getElementById('signupModal').classList.remove('active');
}
function openRecover() {
closeSignup();
document.getElementById('recoverModal').classList.add('active');
showRecoverState('recoverInitial');
var errEl = document.getElementById('recoverError');
@ -50,92 +25,6 @@ function closeRecover() {
document.getElementById('recoverModal').classList.remove('active');
}
async function submitSignup() {
var errEl = document.getElementById('signupError');
var btn = document.getElementById('signupBtn');
var emailInput = document.getElementById('signupEmail');
var email = emailInput.value.trim();
if (!email || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
errEl.textContent = 'Please enter a valid email address.';
errEl.style.display = 'block';
return;
}
errEl.style.display = 'none';
btn.disabled = true;
showState('signupLoading');
try {
var res = await fetch('/v1/signup/free', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: email })
});
var data = await res.json();
if (!res.ok) {
showState('signupInitial');
errEl.textContent = data.error || 'Something went wrong. Please try again.';
errEl.style.display = 'block';
btn.disabled = false;
return;
}
signupEmail = email;
document.getElementById('verifyEmailDisplay').textContent = email;
showState('signupVerify');
document.getElementById('verifyCode').focus();
btn.disabled = false;
} catch (err) {
showState('signupInitial');
errEl.textContent = 'Network error. Please try again.';
errEl.style.display = 'block';
btn.disabled = false;
}
}
async function submitVerify() {
var errEl = document.getElementById('verifyError');
var btn = document.getElementById('verifyBtn');
var codeInput = document.getElementById('verifyCode');
var code = codeInput.value.trim();
if (!code || !/^\d{6}$/.test(code)) {
errEl.textContent = 'Please enter a 6-digit code.';
errEl.style.display = 'block';
return;
}
errEl.style.display = 'none';
btn.disabled = true;
try {
var res = await fetch('/v1/signup/verify', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: signupEmail, code: code })
});
var data = await res.json();
if (!res.ok) {
errEl.textContent = data.error || 'Verification failed.';
errEl.style.display = 'block';
btn.disabled = false;
return;
}
document.getElementById('apiKeyText').textContent = data.apiKey;
showState('signupResult');
var resultH2 = document.querySelector('#signupResult h2');
if (resultH2) { resultH2.setAttribute('tabindex', '-1'); resultH2.focus(); }
} catch (err) {
errEl.textContent = 'Network error. Please try again.';
errEl.style.display = 'block';
btn.disabled = false;
}
}
async function submitRecover() {
var errEl = document.getElementById('recoverError');
var btn = document.getElementById('recoverBtn');
@ -228,12 +117,6 @@ async function submitRecoverVerify() {
}
}
function copyKey() {
var key = document.getElementById('apiKeyText').textContent;
var btn = document.getElementById('copyBtn');
doCopy(key, btn);
}
function copyRecoveredKey() {
var key = document.getElementById('recoveredKeyText').textContent;
var btn = document.getElementById('copyRecoveredBtn');
@ -252,52 +135,32 @@ function doCopy(text, btn) {
try {
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(text).then(showCopied).catch(function() {
// Fallback to execCommand
try {
var ta = document.createElement('textarea');
ta.value = text;
ta.style.position = 'fixed';
ta.style.opacity = '0';
ta.style.top = '-9999px';
ta.style.left = '-9999px';
document.body.appendChild(ta);
ta.focus();
ta.select();
var success = document.execCommand('copy');
document.body.removeChild(ta);
if (success) {
showCopied();
} else {
showFailed();
}
} catch (err) {
showFailed();
}
fallbackCopy(text, showCopied, showFailed);
});
} else {
// Direct fallback for non-secure contexts
var ta = document.createElement('textarea');
ta.value = text;
ta.style.position = 'fixed';
ta.style.opacity = '0';
ta.style.top = '-9999px';
ta.style.left = '-9999px';
document.body.appendChild(ta);
ta.focus();
ta.select();
var success = document.execCommand('copy');
document.body.removeChild(ta);
if (success) {
showCopied();
} else {
showFailed();
}
fallbackCopy(text, showCopied, showFailed);
}
} catch(e) {
showFailed();
}
}
function fallbackCopy(text, onSuccess, onFail) {
try {
var ta = document.createElement('textarea');
ta.value = text;
ta.style.position = 'fixed';
ta.style.opacity = '0';
ta.style.top = '-9999px';
document.body.appendChild(ta);
ta.focus();
ta.select();
var success = document.execCommand('copy');
document.body.removeChild(ta);
success ? onSuccess() : onFail();
} catch(e) { onFail(); }
}
async function checkout() {
try {
var res = await fetch('/v1/billing/checkout', { method: 'POST' });
@ -309,19 +172,71 @@ async function checkout() {
}
}
// === Demo Playground ===
async function generateDemo() {
var btn = document.getElementById('demoGenerateBtn');
var status = document.getElementById('demoStatus');
var result = document.getElementById('demoResult');
var errorEl = document.getElementById('demoError');
var html = document.getElementById('demoHtml').value.trim();
if (!html) {
errorEl.textContent = 'Please enter some HTML.';
errorEl.style.display = 'block';
result.style.display = 'none';
return;
}
errorEl.style.display = 'none';
result.style.display = 'none';
btn.disabled = true;
status.textContent = 'Generating PDF…';
try {
var res = await fetch('/v1/demo/html', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ html: html })
});
if (!res.ok) {
var data = await res.json();
errorEl.textContent = data.error || 'Something went wrong.';
errorEl.style.display = 'block';
btn.disabled = false;
status.textContent = '';
return;
}
var blob = await res.blob();
var url = URL.createObjectURL(blob);
var dl = document.getElementById('demoDownload');
dl.href = url;
result.style.display = 'block';
status.textContent = '';
btn.disabled = false;
} catch (err) {
errorEl.textContent = 'Network error. Please try again.';
errorEl.style.display = 'block';
btn.disabled = false;
status.textContent = '';
}
}
// === Init ===
document.addEventListener('DOMContentLoaded', function() {
// BUG-068: Open change email modal if navigated via #change-email hash
// BUG-068: Open change email modal if navigated via hash
if (window.location.hash === '#change-email') {
openEmailChange();
}
document.getElementById('btn-signup').addEventListener('click', openSignup);
document.getElementById('btn-signup-2').addEventListener('click', openSignup);
// Demo playground
document.getElementById('demoGenerateBtn').addEventListener('click', generateDemo);
// Checkout buttons
document.getElementById('btn-checkout').addEventListener('click', checkout);
document.getElementById('btn-close-signup').addEventListener('click', closeSignup);
document.getElementById('signupBtn').addEventListener('click', submitSignup);
document.getElementById('verifyBtn').addEventListener('click', submitVerify);
document.getElementById('copyBtn').addEventListener('click', copyKey);
var heroCheckout = document.getElementById('btn-checkout-hero');
if (heroCheckout) heroCheckout.addEventListener('click', checkout);
// Recovery modal
document.getElementById('btn-close-recover').addEventListener('click', closeRecover);
@ -337,13 +252,13 @@ document.addEventListener('DOMContentLoaded', function() {
el.addEventListener('click', function(e) { e.preventDefault(); openRecover(); });
});
document.getElementById('signupModal').addEventListener('click', function(e) {
if (e.target === this) closeSignup();
});
// Smooth scroll for hash links
document.querySelectorAll('a[href^="#"]').forEach(function(a) {
a.addEventListener('click', function(e) {
var target = this.getAttribute('href');
if (target === '#') return;
e.preventDefault();
var el = document.querySelector(this.getAttribute('href'));
var el = document.querySelector(target);
if (el) el.scrollIntoView({ behavior: 'smooth' });
});
});
@ -362,7 +277,6 @@ function showEmailChangeState(state) {
}
function openEmailChange() {
closeSignup();
closeRecover();
document.getElementById('emailChangeModal').classList.add('active');
showEmailChangeState('emailChangeInitial');
@ -472,7 +386,7 @@ async function submitEmailChangeVerify() {
}
}
// Add event listeners for email change (append to DOMContentLoaded)
// Email change event listeners
document.addEventListener('DOMContentLoaded', function() {
var closeBtn = document.getElementById('btn-close-email-change');
if (closeBtn) closeBtn.addEventListener('click', closeEmailChange);
@ -494,7 +408,7 @@ document.addEventListener('DOMContentLoaded', function() {
// === Accessibility: Escape key closes modals, focus trapping ===
(function() {
function getActiveModal() {
var modals = ['signupModal', 'recoverModal', 'emailChangeModal'];
var modals = ['recoverModal', 'emailChangeModal'];
for (var i = 0; i < modals.length; i++) {
var m = document.getElementById(modals[i]);
if (m && m.classList.contains('active')) return m;
@ -511,7 +425,6 @@ document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') closeActiveModal();
// Focus trap inside active modal
if (e.key === 'Tab') {
var modal = getActiveModal();
if (!modal) return;