From 582ae88b90e29c2a5a91e94f1189bfb6a1055598 Mon Sep 17 00:00:00 2001 From: Mehrshad Date: Wed, 30 Aug 2023 14:46:35 +0330 Subject: [PATCH] pending_payment: convert js to ts Create a pending_payment.ts model from the pending_payment.js model. --- models/pending_payment.js | 26 ----------------------- models/pending_payment.ts | 43 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 26 deletions(-) delete mode 100644 models/pending_payment.js create mode 100644 models/pending_payment.ts diff --git a/models/pending_payment.js b/models/pending_payment.js deleted file mode 100644 index 871883e3..00000000 --- a/models/pending_payment.js +++ /dev/null @@ -1,26 +0,0 @@ -const mongoose = require('mongoose'); - -const PendingPaymentSchema = new mongoose.Schema({ - description: { type: String }, - amount: { - // amount in satoshis - type: Number, - min: [1, 'Minimum amount is 1 sat'], - validate: { - validator: Number.isInteger, - message: '{VALUE} is not an integer value', - }, - }, - attempts: { type: Number, min: 0, default: 0 }, - paid: { type: Boolean, default: false }, - is_invoice_expired: { type: Boolean, default: false }, - payment_request: { type: String }, - hash: { type: String }, - created_at: { type: Date, default: Date.now }, - paid_at: { type: Date }, - user_id: { type: String }, - order_id: { type: String }, - community_id: { type: String }, -}); - -module.exports = mongoose.model('PendingPayment', PendingPaymentSchema); diff --git a/models/pending_payment.ts b/models/pending_payment.ts new file mode 100644 index 00000000..f2a81f3b --- /dev/null +++ b/models/pending_payment.ts @@ -0,0 +1,43 @@ +import mongoose, { Document, Schema } from 'mongoose'; + +export interface IPendingPayment extends Document { + description: string; + amount: number; + attempts: number; + paid: boolean; + is_invoice_expired: boolean; + payment_request: string; + hash: string; + created_at: Date; + paid_at: Date; + user_id: string; + order_id: string; + community_id: string; +} + + +const PendingPaymentSchema = new Schema({ + description: { type: String }, + amount: { + // amount in satoshis + type: Number, + min: [1, 'Minimum amount is 1 sat'], + validate: { + validator: Number.isInteger, + message: '{VALUE} is not an integer value', + }, + }, + attempts: { type: Number, min: 0, default: 0 }, + paid: { type: Boolean, default: false }, + is_invoice_expired: { type: Boolean, default: false }, + payment_request: { type: String }, + hash: { type: String }, + created_at: { type: Date, default: Date.now }, + paid_at: { type: Date }, + user_id: { type: String }, + order_id: { type: String }, + community_id: { type: String }, +}); + + +module.exports = mongoose.model('PendingPayment', PendingPaymentSchema);