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

Commit 4c0a9ee

Browse files
authored
Merge pull request #72 from Tolfix/dev
v2.1
2 parents b189944 + f7fbaca commit 4c0a9ee

24 files changed

Lines changed: 294 additions & 63 deletions

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cpg-api",
3-
"version": "v2.0",
3+
"version": "v2.1",
44
"description": "Central Payment Gateway",
55
"main": "./build/Main.js",
66
"dependencies": {
@@ -19,7 +19,7 @@
1919
"apollo-server-express": "^3.6.1",
2020
"aws-sdk": "^2.1018.0",
2121
"bcryptjs": "^2.4.3",
22-
"colors": "^1.4.0",
22+
"colors": "github:Tolfix/colors.js",
2323
"common-tags": "^1.8.0",
2424
"cors": "^2.8.5",
2525
"cron": "^1.8.2",

src/Cache/reCache.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,6 @@ export async function reCache_Configs()
162162
});
163163
}
164164

165-
/**
166-
* @deprecated
167-
*/
168165
export async function reCache_Images()
169166
{
170167
Logger.info(`Starting caching on images..`);
@@ -173,8 +170,8 @@ export async function reCache_Images()
173170
const image = await ImageModel.find();
174171
for (const o of image)
175172
{
176-
Logger.cache(`Caching image ${o.uid}`);
177-
CacheImages.set(o.uid, o);
173+
Logger.cache(`Caching image ${o.id}`);
174+
CacheImages.set(o.id, o);
178175
}
179176
return resolve(true);
180177
});
@@ -205,12 +202,12 @@ export async function reCache_Images()
205202
export async function reCache()
206203
{
207204
await reCache_Configs();
208-
await reCache_Categories();
205+
// await reCache_Categories();
209206
await reCache_Admin();
210-
await reCache_Customers();
211-
await reCache_Product();
212-
await reCache_Transactions();
213-
await reCache_Orders();
207+
// await reCache_Customers();
208+
// await reCache_Product();
209+
// await reCache_Transactions();
210+
// await reCache_Orders();
214211
await reCache_Images();
215-
await reCache_Invoices();
212+
// await reCache_Invoices();
216213
}

src/Config.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,55 +45,55 @@ export const Company_Name = async (): Promise<IConfigs["company"]["name"]> =>
4545
{
4646
const configs = await ConfigModel.findOne();
4747
if(!configs) throw new Error("No configs found");
48-
return configs.company?.name ?? process.env.COMPANY_NAME ?? "";
48+
return (configs.company?.name === "" ? undefined : configs.company?.name) ?? process.env.COMPANY_NAME ?? "";
4949
};
5050
export const Company_Address = async (): Promise<IConfigs["company"]["address"]> =>
5151
{
5252
const configs = await ConfigModel.findOne();
5353
if(!configs) throw new Error("No configs found");
54-
return configs.company?.address ?? process.env.COMPANY_ADDRESS ?? "";
54+
return (configs.company?.address === "" ? undefined : configs.company?.address) ?? process.env.COMPANY_ADDRESS ?? "";
5555
}
5656
export const Company_Zip = async (): Promise<IConfigs["company"]["zip"]> =>
5757
{
5858
const configs = await ConfigModel.findOne();
5959
if(!configs) throw new Error("No configs found");
60-
return configs.company?.zip ?? process.env.COMPANY_ZIP ?? "";
60+
return (configs.company?.zip === "" ? undefined : configs.company?.zip) ?? process.env.COMPANY_ZIP ?? "";
6161
}
6262
export const Company_City = async (): Promise<IConfigs["company"]["city"]> =>
6363
{
6464
const configs = await ConfigModel.findOne();
6565
if(!configs) throw new Error("No configs found");
66-
return configs.company?.city ?? process.env.COMPANY_CITY ?? "";
66+
return (configs.company?.city === "" ? undefined : configs.company?.city) ?? process.env.COMPANY_CITY ?? "";
6767
}
6868
export const Company_Country = async (): Promise<IConfigs["company"]["country"]> =>
6969
{
7070
const configs = await ConfigModel.findOne();
7171
if(!configs) throw new Error("No configs found");
72-
return configs.company?.country ?? process.env.COMPANY_COUNTRY ?? "";
72+
return (configs.company?.country === "" ? undefined : configs.company?.country) ?? process.env.COMPANY_COUNTRY ?? "";
7373
}
7474
export const Company_Phone = async (): Promise<IConfigs["company"]["phone"]> =>
7575
{
7676
const configs = await ConfigModel.findOne();
7777
if(!configs) throw new Error("No configs found");
78-
return configs.company?.phone ?? process.env.COMPANY_PHONE ?? "";
78+
return (configs.company?.phone === "" ? undefined : configs.company?.phone) ?? process.env.COMPANY_PHONE ?? "";
7979
}
8080
export const Company_Email = async (): Promise<IConfigs["company"]["email"]> =>
8181
{
8282
const configs = await ConfigModel.findOne();
8383
if(!configs) throw new Error("No configs found");
84-
return configs.company?.email ?? process.env.COMPANY_EMAIL ?? "";
84+
return (configs.company?.email === "" ? undefined : configs.company?.email) ?? process.env.COMPANY_EMAIL ?? "";
8585
}
8686
export const Company_Vat = async (): Promise<IConfigs["company"]["vat"]> =>
8787
{
8888
const configs = await ConfigModel.findOne();
8989
if(!configs) throw new Error("No configs found");
90-
return configs.company?.vat ?? process.env.COMPANY_VAT ?? "";
90+
return (configs.company?.vat === "" ? undefined : configs.company?.vat) ?? process.env.COMPANY_VAT ?? "";
9191
}
9292
export const Company_Currency = async (): Promise<IConfigs["company"]["currency"]> =>
9393
{
9494
const configs = await ConfigModel.findOne();
9595
if(!configs) throw new Error("No configs found");
96-
return configs.company?.currency ?? process.env.COMPANY_CURRENCY ?? "";
96+
return (configs.company?.currency === "" ? undefined : configs.company?.currency) ?? process.env.COMPANY_CURRENCY ?? "";
9797
}
9898
export const Company_Tax_Registered = async (): Promise<IConfigs["company"]["tax_registered"]> =>
9999
{
@@ -105,13 +105,13 @@ export const Company_Logo_Url = async (): Promise<IConfigs["company"]["logo_url"
105105
{
106106
const configs = await ConfigModel.findOne();
107107
if(!configs) throw new Error("No configs found");
108-
return configs.company?.logo_url ?? process.env.COMPANY_LOGO_URL ?? "";
108+
return (configs.company?.logo_url === "" ? undefined : configs.company?.logo_url) ?? process.env.COMPANY_LOGO_URL ?? "";
109109
}
110110
export const Company_Website = async (): Promise<IConfigs["company"]["website"]> =>
111111
{
112112
const configs = await ConfigModel.findOne();
113113
if(!configs) throw new Error("No configs found");
114-
return configs.company?.website ?? process.env.COMPANY_WEBSITE ?? "";
114+
return (configs.company?.website === "" ? undefined : configs.company?.website) ?? process.env.COMPANY_WEBSITE ?? "";
115115
}
116116

117117
export const Default_Language: keyof IAllLanguages = (

src/Cron/Invoices.cron.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ export = function Cron_Invoices()
8282
},
8383
paid: false,
8484
extra: {
85-
stripe_setup_intent: {
86-
$exists: true
87-
}
85+
stripe_setup_intent: true
8886
}
8987
}).then(async (invoices) =>
9088
{

src/Database/Models/Customers/Customer.model.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ const CustomerSchema = new Schema
8080
default: Date.now,
8181
},
8282

83+
profile_picture: {
84+
type: Number,
85+
ref: "images",
86+
required: false,
87+
default: null,
88+
},
89+
8390
password: {
8491
type: String,
8592
required: true,

src/Database/Models/Subscriptions.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { IQuotes } from "../../Interfaces/Quotes.interface";
66
import { ISubscription } from "../../Interfaces/Subscriptions.interface";
77
import Logger from "../../Lib/Logger";
88
import GetText from "../../Translation/GetText";
9-
import { A_CC_Payments, A_RecurringMethod } from "../../Types/PaymentMethod";
9+
import { A_RecurringMethod } from "../../Types/PaymentMethod";
1010

1111
const SubscriptionSchema = new Schema
1212
(
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { stripIndents } from "common-tags";
2+
import { Company_Email } from "../../../Config";
3+
import { ICustomer } from "../../../Interfaces/Customer.interface";
4+
import getFullName from "../../../Lib/Customers/getFullName";
5+
import UseStyles from "../General/UseStyles";
6+
7+
export = async (c: ICustomer) => UseStyles(stripIndents`
8+
<div>
9+
<h1>
10+
Login attempts on your account.
11+
</h1>
12+
<p>
13+
Hello ${getFullName(c)}!
14+
</p>
15+
<p>
16+
Someone has been trying to login to your account. <br />
17+
If this was not you, please contact us immediately${await Company_Email() === "" ? '' : ` at ${await Company_Email()}`}.
18+
</p>
19+
</div>
20+
`);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { stripIndents } from "common-tags";
2+
import { Company_Email } from "../../../Config";
3+
import { ICustomer } from "../../../Interfaces/Customer.interface";
4+
import { IOrder } from "../../../Interfaces/Orders.interface";
5+
import getFullName from "../../../Lib/Customers/getFullName";
6+
import UseStyles from "../General/UseStyles";
7+
8+
export = async (c: ICustomer, order: IOrder) => UseStyles(stripIndents`
9+
<div>
10+
<h1>
11+
Order #${order.id}
12+
</h1>
13+
<p>
14+
Hello ${getFullName(c)}!
15+
</p>
16+
<p>
17+
Your order has been cancelled.
18+
</p>
19+
<p>
20+
If there has been a mistake, please contact us immediately${await Company_Email() === "" ? '' : ` at ${await Company_Email()}`}..
21+
</p>
22+
</div>
23+
`);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { stripIndents } from "common-tags";
2+
import { Full_Domain } from "../../../Config";
3+
import { ICustomer } from "../../../Interfaces/Customer.interface";
4+
import getFullName from "../../../Lib/Customers/getFullName";
5+
import UseStyles from "../General/UseStyles";
6+
7+
export = async (c: ICustomer, v: string, token: string) => UseStyles(stripIndents`
8+
<div>
9+
<p>
10+
Hello ${getFullName(c)}!
11+
<p>
12+
<p>
13+
You have requested to reset your password.
14+
</p>
15+
<p>
16+
To reset your password, please click the link below.
17+
<p>
18+
Link: <a href="${Full_Domain}/${v}/customers/my/reset-password/${token}">Reset password</a>
19+
</p>
20+
</p>
21+
</div>
22+
`);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { stripIndents } from "common-tags";
2+
import { Company_Name } from "../../../Config";
3+
import { ICustomer } from "../../../Interfaces/Customer.interface";
4+
import getFullName from "../../../Lib/Customers/getFullName";
5+
import UseStyles from "../General/UseStyles";
6+
7+
export = async (c: ICustomer) => UseStyles(stripIndents`
8+
<div>
9+
<h1>
10+
Welcome ${getFullName(c)} to ${await Company_Name()}!
11+
</h1>
12+
<p>
13+
Your account has been created.
14+
</p>
15+
<p>
16+
With email: ${c.personal.email}
17+
</p>
18+
</div>
19+
`);

0 commit comments

Comments
 (0)