Skip to content

Commit

Permalink
order: convert js to ts
Browse files Browse the repository at this point in the history
Create a order.ts model from the order.js model.
  • Loading branch information
Mersho committed Sep 6, 2023
1 parent b3ae810 commit e7e7144
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions models/order.js → models/order.ts
Original file line number Diff line number Diff line change
@@ -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<IOrder>({
description: { type: String, required: true },
amount: {
// amount in satoshis
Expand Down Expand Up @@ -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 }

This comment has been minimized.

Copy link
@knocte

knocte Sep 6, 2023

@Mersho this line doesn't need to change, I think

});

module.exports = mongoose.model('Order', OrderSchema);
module.exports = mongoose.model<IOrder>('Order', orderSchema);

0 comments on commit e7e7144

Please sign in to comment.