diff options
| author | Adam Soltys <[email protected]> | 2023-12-01 11:36:35 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-12-01 11:36:35 -0800 |
| commit | 7709c1efde9a1f3078171ee56985cd25511d6f7b (patch) | |
| tree | cd996eaaa860cdb3d7da688e0ad4c5ec7bae1a0c | |
| parent | 826c7b361c93905c4725755038d398221530051d (diff) | |
| download | coinos-server-7709c1efde9a1f3078171ee56985cd25511d6f7b.tar.gz coinos-server-7709c1efde9a1f3078171ee56985cd25511d6f7b.zip | |
biome formatter
| -rw-r--r-- | biome.json | 12 | ||||
| -rw-r--r-- | index.js | 2 | ||||
| -rw-r--r-- | lib/app.js | 5 | ||||
| -rw-r--r-- | lib/auth.js | 4 | ||||
| -rw-r--r-- | lib/db.js | 11 | ||||
| -rw-r--r-- | lib/locations.js | 2 | ||||
| -rw-r--r-- | lib/nostr.js | 16 | ||||
| -rw-r--r-- | lib/payments.js | 8 | ||||
| -rw-r--r-- | lib/rates.js | 6 | ||||
| -rw-r--r-- | lib/register.js | 4 | ||||
| -rw-r--r-- | lib/rpc.js | 38 | ||||
| -rw-r--r-- | lib/sockets.js | 12 | ||||
| -rw-r--r-- | lib/upload.js | 14 | ||||
| -rw-r--r-- | lib/utils.js | 12 | ||||
| -rw-r--r-- | lib/whitelist.js | 2 | ||||
| -rw-r--r-- | package.json | 4 | ||||
| -rw-r--r-- | pnpm-lock.yaml | 82 | ||||
| -rw-r--r-- | routes/nostr.js | 10 | ||||
| -rw-r--r-- | routes/payments.js | 30 | ||||
| -rw-r--r-- | routes/requests.js | 10 | ||||
| -rw-r--r-- | routes/shopify.js | 6 | ||||
| -rw-r--r-- | routes/users.js | 9 |
22 files changed, 179 insertions, 120 deletions
diff --git a/biome.json b/biome.json new file mode 100644 index 00000000..2a94b5b1 --- /dev/null +++ b/biome.json @@ -0,0 +1,12 @@ +{ + "formatter": { + "enabled": true, + "indentStyle": "space", + "indentWidth": 2 + }, + "javascript": { + "formatter": { + "trailingComma": "none" + } + } +} @@ -111,4 +111,4 @@ let port = process.env.PORT || 3119; app.listen({ host, port }); - process.on("unhandledRejection", () => err("Unhandled error")); +process.on("unhandledRejection", () => err("Unhandled error")); @@ -57,10 +57,7 @@ app.setErrorHandler((error, request, reply) => { }); app.setNotFoundHandler((request, reply) => { - reply - .code(404) - .type("text/html") - .send("Not Found"); + reply.code(404).type("text/html").send("Not Found"); }); export default app; diff --git a/lib/auth.js b/lib/auth.js index 55de6df0..0e96218a 100644 --- a/lib/auth.js +++ b/lib/auth.js @@ -7,7 +7,7 @@ export const optional = { preValidation: fastifyPassport.authenticate( "jwt", { session: false }, - function(req, res, err, user, info) { + function (req, res, err, user, info) { req.user = user; } ) @@ -29,7 +29,7 @@ export const jwtStrategy = new jwt.Strategy( { jwtFromRequest: jwt.ExtractJwt.fromExtractors([ jwt.ExtractJwt.fromAuthHeaderAsBearerToken(), - req => (req.cookies ? req.cookies.token : null) + (req) => (req.cookies ? req.cookies.token : null) ]), secretOrKey: config.jwt }, @@ -30,30 +30,29 @@ return {ok = 'ok'} let debit = defineScript({ NUMBER_OF_KEYS: 2, SCRIPT, - transformArguments: (...args) => args.map(a => a.toString()) + transformArguments: (...args) => args.map((a) => a.toString()) }); export let db = createClient({ url: config.db, scripts: { debit }, socket: { - reconnectStrategy: retries => Math.min(retries * 50, 5000) + reconnectStrategy: (retries) => Math.min(retries * 50, 5000) } }); - async function connectWithRetry() { try { await db.connect(); } catch (err) { - console.error('Failed to connect to Redis, retrying...', err); + console.error("Failed to connect to Redis, retrying...", err); setTimeout(connectWithRetry, 5000); // Retry after 5 seconds } } connectWithRetry(); -db.on("error", e => { +db.on("error", (e) => { if (e.message.startsWith("getaddr")) return; err("Redis error", e.message); }); @@ -64,7 +63,7 @@ db.on("end", () => { export default db; -export let g = async k => { +export let g = async (k) => { let v = await db.get(k); try { return JSON.parse(v); diff --git a/lib/locations.js b/lib/locations.js index 5cf43733..dc2c9d54 100644 --- a/lib/locations.js +++ b/lib/locations.js @@ -11,7 +11,7 @@ export let getLocations = async () => { ).json(); locations = locations.filter( - l => + (l) => l["osm_json"].tags && l["osm_json"].tags["payment:coinos"] === "yes" && l["osm_json"]["type"] === "node" diff --git a/lib/nostr.js b/lib/nostr.js index f352c020..f75da37c 100644 --- a/lib/nostr.js +++ b/lib/nostr.js @@ -11,7 +11,7 @@ export let pool; export let fillPool = () => { pool = RelayPool(config.relays); - pool.on("open", relay => { + pool.on("open", (relay) => { if (relay.url.includes(config.nostr)) coinos = relay; relay.subscribe("live", { limit: 1 }); }); @@ -113,7 +113,7 @@ export let q = async ( let done = { [sub]: [] }; - let check = s => { + let check = (s) => { let elapsed = Date.now() - start; if (rejected) return true; if ( @@ -168,7 +168,7 @@ export let q = async ( let seen = []; -let getUser = async pubkey => { +let getUser = async (pubkey) => { let id = await g(`user:${pubkey}`); let user = await g(`user:${id}`); return ( @@ -218,7 +218,7 @@ export async function handleZap(invoice) { } let ptags = zapreq.tags.filter( - t => t && t.length && t.length >= 2 && t[0] === "p" + (t) => t && t.length && t.length >= 2 && t[0] === "p" ); if (ptags.length !== 1) { @@ -226,7 +226,7 @@ export async function handleZap(invoice) { } let etags = zapreq.tags.filter( - t => t && t.length && t.length >= 2 && t[0] === "e" + (t) => t && t.length && t.length >= 2 && t[0] === "e" ); if (!(etags.length === 0 || etags.length === 1)) { @@ -234,14 +234,14 @@ export async function handleZap(invoice) { } let relays_tag = zapreq.tags.find( - t => t && t.length && t.length >= 2 && t[0] === "relays" + (t) => t && t.length && t.length >= 2 && t[0] === "relays" ); if (!relays_tag) { fail(`No relays tag found`); } - let relays = relays_tag.slice(1).filter(r => r && r.startsWith("ws")); + let relays = relays_tag.slice(1).filter((r) => r && r.startsWith("ws")); let etag = etags.length > 0 && etags[0]; let ptag = ptags[0]; @@ -260,5 +260,5 @@ export async function handleZap(invoice) { ev.id = await calculateId(ev); ev.sig = await signId(privkey, ev.id); - await Promise.all(relays.map(r => send(ev, r))); + await Promise.all(relays.map((r) => send(ev, r))); } diff --git a/lib/payments.js b/lib/payments.js index f2fab1ba..5152806a 100644 --- a/lib/payments.js +++ b/lib/payments.js @@ -118,7 +118,7 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { return; } - let { tip } = invoice; + let { tip } = invoice; tip = parseInt(tip) || 0; if (!memo) ({ memo } = invoice); @@ -243,10 +243,10 @@ export let payLightning = async (user, payreq, amount, maxfee, memo) => { let r; let { pays } = await ln.listpays(payreq); - if (pays.find(p => p.status === "complete")) + if (pays.find((p) => p.status === "complete")) fail("Invoice has already been paid"); - if (pays.find(p => p.status === "pending")) + if (pays.find((p) => p.status === "pending")) fail("Payment is already underway"); p = await debit(payreq, total, maxfee, memo, user, types.lightning); @@ -257,7 +257,7 @@ export let payLightning = async (user, payreq, amount, maxfee, memo) => { let recordExists = !!(await g(`payment:${p.id}`)); let paymentFailed = - !pays.length || pays.every(p => p.status === "failed"); + !pays.length || pays.every((p) => p.status === "failed"); l("checking", payreq, recordExists, paymentFailed); diff --git a/lib/rates.js b/lib/rates.js index bbb5418f..2fce4f42 100644 --- a/lib/rates.js +++ b/lib/rates.js @@ -15,11 +15,11 @@ let connect = async () => { ws = new WebSocket("wss://stream.binance.com:9443/ws/btcusdt@ticker"); - ws.onmessage = async function(event) { + ws.onmessage = async function (event) { try { let msg = JSON.parse(event.data); - Object.keys(store.fx).map(symbol => { + Object.keys(store.fx).map((symbol) => { store.rates[symbol] = msg.c * store.fx[symbol]; }); @@ -31,7 +31,7 @@ let connect = async () => { } }; - ws.onerror = async function(error) { + ws.onerror = async function (error) { err("binance socket error", error.message); }; diff --git a/lib/register.js b/lib/register.js index c52dad03..2459d3a8 100644 --- a/lib/register.js +++ b/lib/register.js @@ -28,9 +28,7 @@ export default async (user, ip, requireChallenge) => { if (config.ipregistry) { try { let { - location: { - country: { code } - } + location: { country: { code } } } = await got( `https://api.ipregistry.co/${ip}?key=${config.ipregistry}&fields=location.country.code` ).json(); @@ -4,23 +4,25 @@ export default ({ host, port, wallet, username, password }) => new Proxy( {}, { - get: (target, prop) => (...params) => - ((method, ...params) => { - let url = `http://${host}:${port}/wallet/${wallet}`; - return got - .post(url, { - json: { - method, - params - }, - headers: { - authorization: `Basic ${Buffer.from( - `${username}:${password}` - ).toString("base64")}` - } - }) - .json() - .then(({ result }) => result); - })(prop.toLowerCase(), ...params) + get: + (target, prop) => + (...params) => + ((method, ...params) => { + let url = `http://${host}:${port}/wallet/${wallet}`; + return got + .post(url, { + json: { + method, + params + }, + headers: { + authorization: `Basic ${Buffer.from( + `${username}:${password}` + ).toString("base64")}` + } + }) + .json() + .then(({ result }) => result); + })(prop.toLowerCase(), ...params) } ); diff --git a/lib/sockets.js b/lib/sockets.js index 03ad6752..46fda67c 100644 --- a/lib/sockets.js +++ b/lib/sockets.js @@ -41,7 +41,7 @@ export const broadcast = (type, data) => { } } - Object.values(all).map(ws => { + Object.values(all).map((ws) => { if (!sent.includes(ws.id)) ws.send(JSON.stringify({ type, data })); }); }; @@ -58,7 +58,7 @@ let track = async (ws, token) => { const existing = Object.keys(store.sockets[uid]); if (existing.length > 4) { - const p = existing.find(sid => sid !== uid); + const p = existing.find((sid) => sid !== uid); store.sockets[uid][p].close(code, "too many sockets"); } @@ -72,7 +72,7 @@ export async function socketServer(app) { app.get("/ws", { websocket: true }, (connection, req) => { let { socket: ws } = connection; - connection.on("error", e => err(e.message)); + connection.on("error", (e) => err(e.message)); const id = v4(); ws.id = id; @@ -80,7 +80,7 @@ export async function socketServer(app) { ws.send(JSON.stringify({ type: "connected", data: id })); all[id] = ws; - ws.on("message", async message => { + ws.on("message", async (message) => { let type, data; try { @@ -126,9 +126,9 @@ export async function socketServer(app) { } }); - ws.on("error", e => {}); + ws.on("error", (e) => {}); - ws.on("close", function(code, reason) { + ws.on("close", function (code, reason) { try { const uid = users[id]; if (store.sockets[uid] && store.sockets[uid][id]) { diff --git a/lib/upload.js b/lib/upload.js index e07b9b1a..39c4a07f 100644 --- a/lib/upload.js +++ b/lib/upload.js @@ -14,7 +14,7 @@ async function getSha256Hash(stream) { stream.pipe(hash); let hashValue; - hash.on("data", data => { + hash.on("data", (data) => { hashValue = data.toString("hex"); }); @@ -42,16 +42,10 @@ export default async (req, res) => { if (format !== "image" && !["jpg", "jpeg", "png"].includes(ext)) throw new Error("unsupported file type"); - let t = sharp() - .rotate() - .resize(width) - .webp(); + let t = sharp().rotate().resize(width).webp(); let processedBuffer = await streamToBuffer(s2.pipe(t)); - let hash = crypto - .createHash("sha256") - .update(processedBuffer) - .digest("hex"); + let hash = crypto.createHash("sha256").update(processedBuffer).digest("hex"); let filePath = `/app/data/uploads/${hash}.webp`; fs.writeFileSync(filePath, processedBuffer); @@ -62,7 +56,7 @@ export default async (req, res) => { function streamToBuffer(stream) { return new Promise((resolve, reject) => { const chunks = []; - stream.on("data", chunk => chunks.push(chunk)); + stream.on("data", (chunk) => chunks.push(chunk)); stream.on("end", () => resolve(Buffer.concat(chunks))); stream.on("error", reject); }); diff --git a/lib/utils.js b/lib/utils.js index 2eac0054..a1612483 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -4,7 +4,7 @@ import config from "$config"; export const nada = () => {}; -export const sleep = n => new Promise(r => setTimeout(r, n)); +export const sleep = (n) => new Promise((r) => setTimeout(r, n)); export const wait = async (f, s = 300, n = 50) => { let i = 0; while (!(await f()) && i < s) (await sleep(n)) && i++; @@ -13,17 +13,17 @@ export const wait = async (f, s = 300, n = 50) => { }; export const prod = process.env.NODE_ENV === "production"; -export const fail = msg => { +export const fail = (msg) => { throw new Error(msg); }; export const bail = (res, msg) => res.code(500).send(msg); export const SATS = 100000000; -export const sats = n => Math.round(n * SATS); -export const btc = n => parseFloat((n / SATS).toFixed(8)); +export const sats = (n) => Math.round(n * SATS); +export const btc = (n) => parseFloat((n / SATS).toFixed(8)); -export const uniq = (a, k) => [...new Map(a.map(x => [k(x), x])).values()]; +export const uniq = (a, k) => [...new Map(a.map((x) => [k(x), x])).values()]; export const pick = (O, K) => K.reduce((o, k) => (typeof O[k] !== "undefined" && (o[k] = O[k]), o), {}); @@ -56,7 +56,7 @@ export const fields = [ "banner" ]; -export const getUser = async username => { +export const getUser = async (username) => { username = username.replace(/\s/g, "").toLowerCase(); let uid = await g(`user:${username}`); return g(`user:${uid}`); diff --git a/lib/whitelist.js b/lib/whitelist.js index 1d722683..8c988ab5 100644 --- a/lib/whitelist.js +++ b/lib/whitelist.js @@ -32,5 +32,5 @@ export default [ "username", "verified", "shopifyStore", - "shopifyToken", + "shopifyToken" ]; diff --git a/package.json b/package.json index e99ef1e6..2e7468a3 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ }, "dependencies": { "@aws-sdk/client-ses": "^3.449.0", + "@biomejs/biome": "^1.4.1", "@fastify/cors": "^8.3.0", "@fastify/multipart": "^8.0.0", "@fastify/passport": "^2.4.0", @@ -44,9 +45,6 @@ "web-push": "^3.4.4", "ws": "^7.4.6" }, - "devDependencies": { - "prettier": "^1.19.1" - }, "apidoc": { "title": "CoinOS Server API Documentation", "url": "https://coinos.io/api" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 54e6e02b..3e092913 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ dependencies: '@aws-sdk/client-ses': specifier: ^3.449.0 version: 3.449.0 + '@biomejs/biome': + specifier: ^1.4.1 + version: 1.4.1 '@fastify/cors': specifier: ^8.3.0 version: 8.3.0 @@ -114,11 +117,6 @@ dependencies: specifier: ^7.4.6 version: 7.5.9 -devDependencies: - prettier: - specifier: ^1.19.1 - version: 1.19.1 - packages: /@aws-crypto/[email protected]: @@ -575,6 +573,74 @@ packages: tslib: 2.5.0 dev: false + /@biomejs/[email protected]: + resolution: {integrity: sha512-JccVAwPbhi37pdxbAGmaOBjUTKEwEjWAhl7rKkVVuXHo4MLASXJ5HR8BTgrImi4/7rTBsGz1tgVD1Kwv1CHGRg==} + engines: {node: '>=14.*'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@biomejs/cli-darwin-arm64': 1.4.1 + '@biomejs/cli-darwin-x64': 1.4.1 + '@biomejs/cli-linux-arm64': 1.4.1 + '@biomejs/cli-linux-x64': 1.4.1 + '@biomejs/cli-win32-arm64': 1.4.1 + '@biomejs/cli-win32-x64': 1.4.1 + dev: false + + /@biomejs/[email protected]: + resolution: {integrity: sha512-PZWy2Idndqux38p6AXSDQM2ldRAWi32bvb7bMbTN0ALzpWYMYnxd71ornatumSSJYoNhKmxzDLq+jct7nZJ79w==} + engines: {node: '>=14.*'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: false + optional: true + + /@biomejs/[email protected]: + resolution: {integrity: sha512-soj3BWhnsM1M2JlzR09cibUzG1owJqetwj/Oo7yg0foijo9lNH9XWXZfJBYDKgW/6Fomn+CC2EcUS+hisQzt9g==} + engines: {node: '>=14.*'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: false + optional: true + + /@biomejs/[email protected]: + resolution: {integrity: sha512-YIZqfJUg4F+fPsBTXxgD7EU2E5OAYbmYSl/snf4PevwfQCWE/omOFZv+NnIQmjYj9I7ParDgcJvanoA3/kO0JQ==} + engines: {node: '>=14.*'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@biomejs/[email protected]: + resolution: {integrity: sha512-9YOZw3qBd/KUj63A6Hn2zZgzGb2nbESM0qNmeMXgmqinVKM//uc4OgY5TuKITuGjMSvcVxxd4dX1IzYjV9qvNQ==} + engines: {node: '>=14.*'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@biomejs/[email protected]: + resolution: {integrity: sha512-nWQbvkNKxYn/kCQ0yVF8kCaS3VzaGvtFSmItXiMknU4521LDjJ7tNWH12Gol+pIslrCbd4E1LhJa0a3ThRsBVg==} + engines: {node: '>=14.*'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: false + optional: true + + /@biomejs/[email protected]: + resolution: {integrity: sha512-88fR2CQxQ4YLs2BUDuywWYQpUKgU3A3sTezANFc/4LGKQFFLV2yX+F7QAdZVkMHfA+RD9Xg178HomM/6mnTNPA==} + engines: {node: '>=14.*'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: false + optional: true + /@bleskomat/[email protected]: resolution: {integrity: sha512-xAMj1zfYWydo2K2U30Tn1R8p2hOEdRF9o0d/QPYHjGNQkgx6rHv4lgf6/UXOptjUvPKEIRtxXJBl7fYZ8nnRzA==} dependencies: @@ -3120,12 +3186,6 @@ packages: tunnel-agent: 0.6.0 dev: false - resolution: {integrity: sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==} - engines: {node: '>=4'} - hasBin: true - dev: true - resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} dev: false diff --git a/routes/nostr.js b/routes/nostr.js index 4a92f0ef..5c22fa7b 100644 --- a/routes/nostr.js +++ b/routes/nostr.js @@ -45,10 +45,10 @@ export default { let ids = await db.sMembers(pubkey); let events = ids.length - ? (await db.mGet(ids.map(k => "ev:" + k))).map(JSON.parse) + ? (await db.mGet(ids.map((k) => "ev:" + k))).map(JSON.parse) : []; - res.send(events.map(e => ({ ...e, user }))); + res.send(events.map((e) => ({ ...e, user }))); }, async messages({ params: { pubkey, since = 0 } }, res) { @@ -71,7 +71,7 @@ export default { let messages = await db.sMembers(`${pubkey}:messages`); messages = await Promise.all( - messages.map(async id => { + messages.map(async (id) => { let m = await g(`ev:${id}`); let aid = await g(`user:${m.pubkey}`); @@ -130,7 +130,7 @@ export default { follows.push(user); } - follows = uniq(follows, e => e.pubkey); + follows = uniq(follows, (e) => e.pubkey); follows.sort((a, b) => a.username.localeCompare(b.username)); res.send(follows); @@ -174,7 +174,7 @@ export default { followers.push(user); } - followers = uniq(followers, e => e.pubkey); + followers = uniq(followers, (e) => e.pubkey); followers.sort((a, b) => a.username.localeCompare(b.username)); res.send(followers); diff --git a/routes/payments.js b/routes/payments.js index 84fe4e61..9df9abb6 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -21,7 +21,7 @@ let catchUp = async () => { try { if (seen.includes(txid)) continue; await got.post(`http://localhost:${process.env.PORT || 3119}/bitcoin`, { - json: { txid, wallet: config.bitcoin.wallet }, + json: { txid, wallet: config.bitcoin.wallet } }); seen.push(txid); @@ -57,7 +57,7 @@ export default { await got .post(`${config.classic}/admin/credit`, { json: { username, amount, source }, - headers: { authorization: `Bearer ${config.admin}` }, + headers: { authorization: `Bearer ${config.admin}` } }) .json(); } else if (payreq) { @@ -119,8 +119,8 @@ export default { (((b.amount || 0) + (b.tip || 0) - (b.fee || 0) - (b.ourfee || 0)) * b.rate) / SATS - ).toFixed(2), - }, + ).toFixed(2) + } }), {} ); @@ -181,7 +181,7 @@ export default { k1: name, defaultDescription: `Withdraw from coinos fund ${name}`, minWithdrawable: 0, - maxWithdrawable, + maxWithdrawable }); }, @@ -204,7 +204,7 @@ export default { hash: iid, rate: store.rates[currency], uid: user.id, - received: 0, + received: 0 }); } @@ -272,7 +272,7 @@ export default { let tx = await bc.fundRawTransaction(raw, { feeRate, subtractFeeFromOutputs, - replaceable, + replaceable }); let fee = sats(tx.fee); @@ -315,7 +315,7 @@ export default { for (let { scriptPubKey: { address }, - value, + value } of tx.vout) { total += sats(value); let iid = await g(`invoice:${address}`); @@ -348,13 +348,13 @@ export default { "card[number]": number, "card[exp_month]": month, "card[exp_year]": year, - "card[cvc]": cvc, + "card[cvc]": cvc }; let { id: source } = await got .post(`${stripe}/tokens`, { form, - username, + username }) .json(); @@ -363,13 +363,13 @@ export default { amount, currency, source, - description: "starter coupon", + description: "starter coupon" }; let r = await got .post(`${stripe}/charges`, { form, - username, + username }) .json(); @@ -382,7 +382,7 @@ export default { id, hash: id, uid: user.id, - received: 0, + received: 0 }); amount = sats(amount / store.rates[currency]); let uid = await g("user:coinos"); @@ -402,7 +402,7 @@ export default { "estimatesmartfee", "echo", "getblockchaininfo", - "getnetworkinfo", + "getnetworkinfo" ]; if (!whitelist.includes(method)) fail("unsupported method"); @@ -535,5 +535,5 @@ export default { console.log(e); bail(res, e.message); } - }, + } }; diff --git a/routes/requests.js b/routes/requests.js index 11bf9a36..ccc7d739 100644 --- a/routes/requests.js +++ b/routes/requests.js @@ -19,21 +19,21 @@ export default { let requests = await db.lRange(`${id}:requests`, 0, -1); - requests = await Promise.all(requests.map(id => g(`request:${id}`))); + requests = await Promise.all(requests.map((id) => g(`request:${id}`))); requests = await Promise.all( - requests.map(async r => { + requests.map(async (r) => { r.requester = await g(`user:${r.requester_id}`); r.recipient = await g(`user:${r.recipient_id}`); return r; }) ); - let sent = requests.filter(r => r.requester_id === id); + let sent = requests.filter((r) => r.requester_id === id); let received = requests - .filter(r => r.recipient_id === id) - .filter(r => !r.invoice_id); + .filter((r) => r.recipient_id === id) + .filter((r) => !r.invoice_id); let invoices = []; for (let r of sent) { diff --git a/routes/shopify.js b/routes/shopify.js index 5d972372..cdfbedba 100644 --- a/routes/shopify.js +++ b/routes/shopify.js @@ -24,12 +24,12 @@ export default async ({ body: { hash }, params: { id } }, res) => { { headers: { "Content-Type": "application/json", - "X-Shopify-Access-Token": user.shopifyToken, + "X-Shopify-Access-Token": user.shopifyToken }, json: { query, - variables: { input: { id: `gid://shopify/Order/${id}` } }, - }, + variables: { input: { id: `gid://shopify/Order/${id}` } } + } } ) .json(); diff --git a/routes/users.js b/routes/users.js index 41c3bfd5..d3dff28b 100644 --- a/routes/users.js +++ b/routes/users.js @@ -315,7 +315,7 @@ export default { if (!subscriptions) subscriptions = []; if ( !subscriptions.find( - s => JSON.stringify(s) === JSON.stringify(subscription) + (s) => JSON.stringify(s) === JSON.stringify(subscription) ) ) subscriptions.push(subscription); @@ -360,10 +360,10 @@ export default { for (let { ref } of ( await Promise.all( - payments.reverse().map(async id => await g(`payment:${id}`)) + payments.reverse().map(async (id) => await g(`payment:${id}`)) ) - ).filter(p => p.type === types.internal && p.ref)) { - let i = contacts.findIndex(c => c && c.id === ref); + ).filter((p) => p.type === types.internal && p.ref)) { + let i = contacts.findIndex((c) => c && c.id === ref); if (~i) contacts.splice(i, 1); let u = await g(`user:${ref}`); if (typeof u === "string") u = await g(`user:${ref}`); @@ -437,5 +437,4 @@ export default { console.log("test", test); res.send(test); } - }; |
