import { SimplePool } from 'nostr-tools/pool'; import { startFeedCache } from './service.js'; import { snapshotResponse } from './cache.js'; import { NOTE_PATH, buildThread, createThreadCache, createIndexSource, notePageResponse } from './note-page.js'; import { PROFILE_PATH, buildProfile, createPrimal, createNameResolver, profilePageResponse } from './profile-page.js'; const cache = await startFeedCache(); // SimplePool verifies signatures and matches filters before accepting events. const pool = new SimplePool(); // Every relay's answer, or maxWait — but an ask by id is done the moment // every id has turned up, rather than waiting out the slowest relay. With // `idle`, the answer is also done once events have been arriving and then // stop for that long: one relay that never says EOSE no longer holds a // profile page for the whole maxWait. const query = (relays, filter, maxWait, { idle = 0 } = {}) => new Promise((resolve) => { const got = new Map(); let done = false, sub = null, quiet = null; const finish = () => { if (done) return; done = true; clearTimeout(quiet); try { sub && sub.close(); } catch {} resolve([...got.values()]); }; sub = pool.subscribeManyEose(relays, filter, { maxWait, onevent(e) { got.set(e.id, e); if (filter.ids && filter.ids.every((id) => got.has(id))) finish(); if (idle) { clearTimeout(quiet); quiet = setTimeout(finish, idle); } }, onclose: finish, }); if (done) try { sub.close(); } catch {} }); const threads = createThreadCache({ build: (ref) => buildThread(ref, query) }); const primal = createPrimal(); const profiles = createThreadCache({ build: (ref) => buildProfile(ref, { query, primal }) }); const resolveName = createNameResolver({ url: process.env.NAMES_URL || 'https://names.coinos.io' }); const index = createIndexSource(process.env.INDEX_URL || 'http://bitcoin-wallet/index.html'); const server = Bun.serve({ hostname: process.env.HOST || '127.0.0.1', port: Number(process.env.PORT || 8792), idleTimeout: 30, async fetch(req) { const path = new URL(req.url).pathname; if (path === '/api/feed') return snapshotResponse(cache, req); if (NOTE_PATH.test(path) && ['GET', 'HEAD'].includes(req.method)) { try { return await notePageResponse(req, { index, threads }); } catch { return new Response('Unavailable', { status: 502 }); } } if (PROFILE_PATH.test(path) && ['GET', 'HEAD'].includes(req.method)) { try { return await profilePageResponse(req, { index, profiles, resolveName }); } catch { return new Response('Unavailable', { status: 502 }); } } return new Response('Not found', { status: 404 }); }, }); console.log(`Public feed cache listening on ${server.url}`); rver.git/about/?h=prod'>aboutsummaryrefslogtreecommitdiffstats
path: root/views/setup.html
blob: 72fbd944549765f19a745d4cee36136817efa17f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
		<meta name="viewport" content="width=480, height=752, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
    <title>Bitcoin Payment Calculator</title>
    <link href="img/favicon.ico" rel="shortcut icon" />
    {{#css}}calculator{{/css}}
    {{#js}}setup{{/js}}
  </head>
  <body>
    <div class="container-fluid">
      <form action="users" method="post">
        <h1>Calculator Setup</h1>

        <label for="login">Username:</label>
        <input type="text" id="login" name="login" value="{{user}}" />

        <label for="password">Password:</label>
        <input type="password" id="password" name="password" value="" />

        <label for="name">Title:</label>
        <input type="text" id="name" name="name" />

        <label for="logo">Image:</label>
        <input type="text" id="logo" name="logo" />

        <label for="address">Bitcoin Address:</label>
        <input type="text" id="address" name="address" />

        <label for="symbol">Market Symbol:</label>
        <select id="symbol" name="symbol">
        </select>
        
        <label for="commission">Commission (%):</label>
        <input type="text" id="commission" name="commission" />

        <br />
        <input class="btn" type="submit" value="Go" />
      </form>
    </div>
  </body>
</html>