-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
722195d
commit 4df79d0
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Decimal from 'decimal.js' | ||
import { createHouseUserGiftTransaction } from '@play-money/finance/lib/createHouseUserGiftTransaction' | ||
import { getUserById } from '@play-money/users/lib/getUserById' | ||
import db from '../prisma' | ||
|
||
const userId = 'cm0ioq1nl0000v2k9p427yejq' | ||
const amount = new Decimal(0) | ||
|
||
async function main() { | ||
try { | ||
const user = await getUserById({ id: userId }) | ||
|
||
if (user.primaryAccountId) { | ||
await createHouseUserGiftTransaction({ userId: user.id, amount, initiatorId: '' }) | ||
|
||
console.log(`Gifted user ${userId} ${amount}`) | ||
} | ||
} catch (fetchError) { | ||
const error = fetchError as Error | ||
console.error(`An error occurred while sending user gift: ${error.message}`) | ||
} finally { | ||
await db.$disconnect() | ||
console.log('Database connection closed.') | ||
} | ||
} | ||
|
||
main().catch((e) => { | ||
const error = e as Error | ||
console.error(`Unexpected error: ${error.message}`) | ||
process.exit(1) | ||
}) |