Skip to content

Commit

Permalink
fix tsx usage
Browse files Browse the repository at this point in the history
  • Loading branch information
huumn committed Nov 7, 2024
1 parent 4cc3780 commit 89a25ba
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 64 deletions.
3 changes: 0 additions & 3 deletions api/package.json

This file was deleted.

3 changes: 0 additions & 3 deletions lib/package.json

This file was deleted.

7 changes: 2 additions & 5 deletions lib/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ import {
import { SUPPORTED_CURRENCIES } from './currency'
import { NOSTR_MAX_RELAY_NUM, NOSTR_PUBKEY_BECH32, NOSTR_PUBKEY_HEX } from './nostr'
import { msatsToSats, numWithUnits, abbrNum } from './format'
import * as usersFragments from '@/fragments/users'
import * as subsFragments from '@/fragments/subs'
import { SUB } from '@/fragments/subs'
import { NAME_QUERY } from '@/fragments/users'
import { datePivot } from './time'
import bip39Words from './bip39-words'

const { SUB } = subsFragments
const { NAME_QUERY } = usersFragments

export async function validateSchema (schema, data, args) {
try {
if (typeof schema === 'function') {
Expand Down
4 changes: 1 addition & 3 deletions wallets/graphql.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import gql from 'graphql-tag'
import { isServerField } from './common'
// for some reason, this is needed to make the import work from worker
import * as walletFragments from '@/fragments/wallet'
const { WALLET_FIELDS } = walletFragments
import { WALLET_FIELDS } from '@/fragments/wallet'

export function fieldToGqlArg (field) {
let arg = `${field.name}: String`
Expand Down
3 changes: 0 additions & 3 deletions wallets/package.json

This file was deleted.

8 changes: 4 additions & 4 deletions worker/earn.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { notifyEarner } from '@/lib/webPush.js'
import createPrisma from '@/lib/create-prisma.js'
import { proportions } from '@/lib/madness.js'
import { SN_NO_REWARDS_IDS } from '@/lib/constants.js'
import { notifyEarner } from '@/lib/webPush'
import createPrisma from '@/lib/create-prisma'
import { proportions } from '@/lib/madness'
import { SN_NO_REWARDS_IDS } from '@/lib/constants'

const TOTAL_UPPER_BOUND_MSATS = 1_000_000_000

Expand Down
2 changes: 1 addition & 1 deletion worker/ephemeralItems.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deleteItemByAuthor } from '@/lib/item.js'
import { deleteItemByAuthor } from '@/lib/item'

export async function deleteItem ({ data: { id }, models }) {
await deleteItemByAuthor({ models, id })
Expand Down
4 changes: 2 additions & 2 deletions worker/imgproxy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createHmac } from 'node:crypto'
import { extractUrls } from '@/lib/md.js'
import { isJob } from '@/lib/item.js'
import { extractUrls } from '@/lib/md'
import { isJob } from '@/lib/item'
import path from 'node:path'
import { decodeProxyUrl } from '@/lib/url'
import { fetchWithTimeout } from '@/lib/fetch'
Expand Down
52 changes: 25 additions & 27 deletions worker/index.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
// environment variables are loaded from files and imports run before the rest of the code
import './loadenv.js'
import './loadenv'
import PgBoss from 'pg-boss'
import createPrisma from '@/lib/create-prisma.js'
import createPrisma from '@/lib/create-prisma'
import {
autoDropBolt11s, checkInvoice, checkPendingDeposits, checkPendingWithdrawals,
checkWithdrawal,
finalizeHodlInvoice, subscribeToWallet
} from './wallet.js'
import { repin } from './repin.js'
import { trust } from './trust.js'
import { earn } from './earn.js'
import apolloClient from '@apollo/client'
import { indexItem, indexAllItems } from './search.js'
import { timestampItem } from './ots.js'
import { computeStreaks, checkStreak } from './streak.js'
import { nip57 } from './nostr.js'
} from './wallet'
import { repin } from './repin'
import { trust } from './trust'
import { earn } from './earn'
import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client'
import { indexItem, indexAllItems } from './search'
import { timestampItem } from './ots'
import { computeStreaks, checkStreak } from './streak'
import { nip57 } from './nostr'
import fetch from 'cross-fetch'
import { authenticatedLndGrpc } from 'ln-service'
import { views, rankViews } from './views.js'
import { imgproxy } from './imgproxy.js'
import { deleteItem } from './ephemeralItems.js'
import { deleteUnusedImages } from './deleteUnusedImages.js'
import { territoryBilling, territoryRevenue } from './territory.js'
import { ofac } from './ofac.js'
import { autoWithdraw } from './autowithdraw.js'
import { saltAndHashEmails } from './saltAndHashEmails.js'
import { remindUser } from './reminder.js'
import { views, rankViews } from './views'
import { imgproxy } from './imgproxy'
import { deleteItem } from './ephemeralItems'
import { deleteUnusedImages } from './deleteUnusedImages'
import { territoryBilling, territoryRevenue } from './territory'
import { ofac } from './ofac'
import { autoWithdraw } from './autowithdraw'
import { saltAndHashEmails } from './saltAndHashEmails'
import { remindUser } from './reminder'
import {
paidActionPaid, paidActionForwarding, paidActionForwarded,
paidActionFailedForward, paidActionHeld, paidActionFailed,
paidActionCanceling
} from './paidAction.js'
import { thisDay } from './thisDay.js'
import { isServiceEnabled } from '@/lib/sndev.js'
import { payWeeklyPostBounty, weeklyPost } from './weeklyPosts.js'
import { expireBoost } from './expireBoost.js'

const { ApolloClient, HttpLink, InMemoryCache } = apolloClient
} from './paidAction'
import { thisDay } from './thisDay'
import { isServiceEnabled } from '@/lib/sndev'
import { payWeeklyPostBounty, weeklyPost } from './weeklyPosts'
import { expireBoost } from './expireBoost'

async function work () {
const boss = new PgBoss(process.env.DATABASE_URL)
Expand Down
3 changes: 1 addition & 2 deletions worker/loadenv.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
import nextEnv from '@next/env'
const { loadEnvConfig } = nextEnv
import { loadEnvConfig } from '@next/env'
loadEnvConfig('.', process.env.NODE_ENV === 'development')
2 changes: 1 addition & 1 deletion worker/ofac.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createReadStream, createWriteStream, unlinkSync } from 'fs'
import unzipper from 'unzipper'
import csvParser from 'csv-parser'
import stream from 'stream'
import { SANCTIONED_COUNTRY_CODES } from '@/lib/constants.js'
import { SANCTIONED_COUNTRY_CODES } from '@/lib/constants'

const IPV4_URL = 'https://ipapi.is/data/geolocationDatabaseIPv4.csv.zip'
const IPV6_URL = 'https://ipapi.is/data/geolocationDatabaseIPv6.csv.zip'
Expand Down
3 changes: 0 additions & 3 deletions worker/package.json

This file was deleted.

2 changes: 1 addition & 1 deletion worker/search.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { gql } from 'graphql-tag'
import search from '@/api/search/index.js'
import search from '@/api/search/index'
import removeMd from 'remove-markdown'

const ITEM_SEARCH_FIELDS = gql`
Expand Down
2 changes: 1 addition & 1 deletion worker/trust.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as math from 'mathjs'
import { USER_ID, SN_ADMIN_IDS } from '@/lib/constants.js'
import { USER_ID, SN_ADMIN_IDS } from '@/lib/constants'

export async function trust ({ boss, models }) {
try {
Expand Down
2 changes: 1 addition & 1 deletion worker/views.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import createPrisma from '@/lib/create-prisma.js'
import createPrisma from '@/lib/create-prisma'

const viewPrefixes = ['reg_growth', 'spender_growth', 'item_growth', 'spending_growth',
'stackers_growth', 'stacking_growth', 'user_stats', 'sub_stats']
Expand Down
8 changes: 4 additions & 4 deletions worker/wallet.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import serialize from '@/api/resolvers/serial.js'
import serialize from '@/api/resolvers/serial'
import {
getInvoice, getPayment, cancelHodlInvoice, deletePayment,
subscribeToInvoices, subscribeToPayments, subscribeToInvoice
} from 'ln-service'
import { notifyDeposit, notifyWithdrawal } from '@/lib/webPush'
import { INVOICE_RETENTION_DAYS, LND_PATHFINDING_TIMEOUT_MS } from '@/lib/constants'
import { datePivot, sleep } from '@/lib/time.js'
import { datePivot, sleep } from '@/lib/time'
import retry from 'async-retry'
import { addWalletLog } from '@/api/resolvers/wallet'
import { msatsToSats, numWithUnits } from '@/lib/format'
Expand All @@ -14,8 +14,8 @@ import {
paidActionFailedForward, paidActionHeld, paidActionFailed,
paidActionForwarding,
paidActionCanceling
} from './paidAction.js'
import { getPaymentFailureStatus } from '@/api/lnd/index.js'
} from './paidAction'
import { getPaymentFailureStatus } from '@/api/lnd/index'

export async function subscribeToWallet (args) {
await subscribeToDeposits(args)
Expand Down

0 comments on commit 89a25ba

Please sign in to comment.