From e7e7144701be2b6ce143972d0e6b00b11a70a280 Mon Sep 17 00:00:00 2001 From: Mehrshad Date: Wed, 30 Aug 2023 14:45:07 +0330 Subject: [PATCH] order: convert js to ts Create a order.ts model from the order.js model. --- models/{order.js => order.ts} | 49 ++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 4 deletions(-) rename models/{order.js => order.ts} (71%) diff --git a/models/order.js b/models/order.ts similarity index 71% rename from models/order.js rename to models/order.ts index 77519d8f..173087ed 100644 --- a/models/order.js +++ b/models/order.ts @@ -1,6 +1,47 @@ -const mongoose = require('mongoose'); +import mongoose, { Document, Schema } from 'mongoose'; -const OrderSchema = new mongoose.Schema({ +export interface IOrder extends Document { + description?: string; + amount: number; + max_amount: number; + min_amount: number; + fee: number; + bot_fee: number; + community_fee: number; + routing_fee: number; + hash: string; + secret: string; + creator_id: string; + seller_id: string; + buyer_id: string; + buyer_invoice: string; + buyer_dispute: boolean + seller_dispute: boolean + buyer_cooperativecancel: boolean; + seller_cooperativecancel: boolean; + canceled_by: string + status: string; + type: string; + fiat_amount: number; + fiat_code: string; + payment_method: string; + created_at: Date; + invoice_held_at: Date; + taken_at: Date; + tg_chat_id: string; + tg_order_message: string; + tg_channel_message1: string | null; + range_parent_id: string; + price_from_api: boolean; + price_margin: number; + calculated: boolean; + admin_warned: boolean; + paid_hold_buyer_invoice_updated: boolean; + community_id: string; + is_public: boolean; +} + +const orderSchema = new Schema({ description: { type: String, required: true }, amount: { // amount in satoshis @@ -79,7 +120,7 @@ const OrderSchema = new mongoose.Schema({ admin_warned: { type: Boolean, default: false }, // We set this to true when the bot warns admins the order is about to expire paid_hold_buyer_invoice_updated: { type: Boolean, default: false }, // We set this to true when buyer executes /setinvoice on a order PAID_HOLD_INVOICE community_id: { type: String }, - is_public: { type: Boolean, default: true }, + is_public: { type: Boolean, default: true } }); -module.exports = mongoose.model('Order', OrderSchema); +module.exports = mongoose.model('Order', orderSchema);