32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
import express from 'express';
|
|
import { listAccounts } from './db.js';
|
|
|
|
const app = express();
|
|
const port = process.env.PORT || 3210;
|
|
|
|
app.get('/', async (req, res) => {
|
|
const rows = await listAccounts();
|
|
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
res.end(`<!doctype html>
|
|
<html><head><meta charset="utf-8"/>
|
|
<title>Verdent Accounts</title>
|
|
<style>body{font-family:system-ui,Arial;padding:20px;} table{border-collapse:collapse;width:100%} th,td{border:1px solid #ccc;padding:8px;text-align:left} .expired{color:#b00}</style>
|
|
</head><body>
|
|
<h2>Registered Accounts</h2>
|
|
<table>
|
|
<thead><tr><th>Email</th><th>Password</th><th>Status</th><th>Created</th><th>Expires</th></tr></thead>
|
|
<tbody>
|
|
${rows.map(r => `<tr class="${new Date(r.expires_at) < new Date() ? 'expired' : ''}"><td>${r.email}</td><td>${r.password}</td><td>${r.status}</td><td>${fmt(r.created_at)}</td><td>${fmt(r.expires_at)}</td></tr>`).join('')}
|
|
</tbody>
|
|
</table>
|
|
</body></html>`);
|
|
});
|
|
|
|
function fmt(d){
|
|
const dt=new Date(d);return dt.toISOString().replace('T',' ').slice(0,19);
|
|
}
|
|
|
|
app.listen(port, () => {
|
|
console.log(`[WEB] Query page running at http://localhost:${port}`);
|
|
});
|