Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
Merge pull request #58 from Tolfix/dev
Browse files Browse the repository at this point in the history
Fixed mongoose
  • Loading branch information
Tolfx authored Dec 27, 2021
2 parents 4d281a6 + 08268a0 commit c021ae9
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ WORKDIR /usr/src

COPY package*.json ./

RUN npm install
RUN npm install --force

COPY . ./

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"express-session": "^1.17.2",
"express-swagger-generator": "github:Tolfix/express-swagger-generator",
"jsonwebtoken": "^8.5.1",
"mongoose": "^6.0.12",
"mongoose": "^6.1.4",
"mongoose-auto-increment": "^5.0.1",
"node-fetch": "^2.6.6",
"nodemailer": "^6.7.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/AdminHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export default class AdminHandler
const username = result.username as string;
Logger.info(`Deleting administrator..`);

AdminModel.findOneAndDelete({ username: username }, (err: any) => {
AdminModel.findOneAndUpdate({ username: username }, (err: any) => {
if(err)
Logger.error(err);

Expand Down
2 changes: 1 addition & 1 deletion src/Database/Schemas/Category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const CategorySchema = new Schema
);

// Log when creation
CategorySchema.post('save', function(doc: IDCategory)
CategorySchema.post('save', function(doc: IDCategory & Document)
{
Logger.db(`Created category ${doc.id}`);
});
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Schemas/ConfigurableOptions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mongoose, { model, Schema } from "mongoose"
import mongoose, { model, Schema, Document } from "mongoose"
import increment from "mongoose-auto-increment";
import { MongoDB_URI } from "../../Config";
import { IConfigurableOptions } from "../../Interfaces/ConfigurableOptions";
Expand Down Expand Up @@ -27,7 +27,7 @@ const ConfigurableOptionsSchema = new Schema
);

// Log when creation
ConfigurableOptionsSchema.post('save', function(doc: IConfigurableOptions)
ConfigurableOptionsSchema.post('save', function(doc: IConfigurableOptions & Document)
{
Logger.db(`Created configurable_options ${doc.id}`);
});
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Schemas/Customers/Customer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const CustomerSchema = new Schema
);

// Log when creation
CustomerSchema.post('save', function(doc: ICustomer)
CustomerSchema.post('save', function(doc: ICustomer & Document)
{
Logger.db(`Created customer ${doc.id}`);
});
Expand Down
7 changes: 5 additions & 2 deletions src/Database/Schemas/Customers/PasswordReset.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { model, Schema } from "mongoose"
import { Document, model, Schema } from "mongoose"
import Logger from "../../../Lib/Logger";

const PasswordResetSchema = new Schema
Expand Down Expand Up @@ -29,6 +29,9 @@ PasswordResetSchema.post('save', function(doc: any)
Logger.db(`Created password reset for ${doc.email}`);
});

const PasswordResetModel = model("password_reset", PasswordResetSchema);
const PasswordResetModel = model<{
email: string,
token: string,
} & Document>("password_reset", PasswordResetSchema);

export default PasswordResetModel;
2 changes: 1 addition & 1 deletion src/Database/Schemas/Images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const ImageSchema = new Schema
);

// Log when creation
ImageSchema.post('save', function(doc: IImage)
ImageSchema.post('save', function(doc: IImage & Document)
{
Logger.db(`Created image ${doc.id}`);
});
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Schemas/Invoices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const InvoiceSchema = new Schema
);

// Log when creation
InvoiceSchema.post('save', function(doc: IInvoice)
InvoiceSchema.post('save', function(doc: IInvoice & Document)
{
Logger.db(`Created invoice ${doc.id}`);
});
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Schemas/Orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const OrderSchema = new Schema
);

// Log when creation
OrderSchema.post('save', function(doc: IOrder)
OrderSchema.post('save', function(doc: IOrder & Document)
{
Logger.db(`Created order ${doc.id}`);
});
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Schemas/Products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const ProductSchema = new Schema
);

// Log when creation
ProductSchema.post('save', function(doc: IProduct)
ProductSchema.post('save', function(doc: IProduct & Document)
{
Logger.db(`Created product ${doc.name} (${doc.id})`);
});
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Schemas/PromotionsCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const PromotionCodeSchema = new Schema
);

// Log when creation
PromotionCodeSchema.post('save', function(doc: IPromotionsCodes)
PromotionCodeSchema.post('save', function(doc: IPromotionsCodes & Document)
{
Logger.db(`Created promotion code ${doc.name}`);
});
Expand Down
3 changes: 1 addition & 2 deletions src/Database/Schemas/Quotes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import mongoose, { Document, model, Schema } from "mongoose"
import increment from "mongoose-auto-increment";
import { MongoDB_URI } from "../../Config";
import { IInvoice } from "../../Interfaces/Invoice";
import { IQuotes } from "../../Interfaces/Quotes";
import Logger from "../../Lib/Logger";

Expand Down Expand Up @@ -40,7 +39,7 @@ const QuotesSchema = new Schema
);

// Log when creation
QuotesSchema.post('save', function(doc: IInvoice)
QuotesSchema.post('save', function(doc: IQuotes & Document)
{
Logger.db(`Created Quotes ${doc.id}`);
});
Expand Down
7 changes: 3 additions & 4 deletions src/Routes/v2/Orders/Orders.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CustomerModel from "../../../Database/Schemas/Customers/Customer";
import OrderModel from "../../../Database/Schemas/Orders";
import ProductModel from "../../../Database/Schemas/Products";
import { IPayments } from "../../../Interfaces/Payments";
import { IProduct, IRecurringMethod } from "../../../Interfaces/Products";
import { IPaymentType, IProduct, IRecurringMethod } from "../../../Interfaces/Products";
import { APIError, APISuccess } from "../../../Lib/Response";
import EnsureAdmin from "../../../Middlewares/EnsureAdmin";
import OrderController from "./Orders.controller";
Expand Down Expand Up @@ -42,11 +42,10 @@ async function createOrder(customer: ICustomer, products: Array<{
quantity: product.quantity,
}
}),
payment_method: payment_method,
payment_method: payment_method as keyof IPayments,
order_status: "active",
billing_type: billing_type,
billing_type: billing_type as IPaymentType,
billing_cycle: billing_cycle,
quantity: 1,
dates: {
createdAt: new Date(),
next_recycle: dateFormat.format(nextRecycleDate(
Expand Down

0 comments on commit c021ae9

Please sign in to comment.