mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-10-07 18:22:04 +00:00
refactor: upgrade project to Typescript 5.9
This commit is contained in:
@@ -53,7 +53,7 @@
|
||||
"@types/geojson": "1.0.6",
|
||||
"@types/node": "22.15.31",
|
||||
"@types/node-cron": "3.0.7",
|
||||
"@types/nodemailer": "6.4.7",
|
||||
"@types/nodemailer": "8.0.2",
|
||||
"@types/promise-queue": "2.2.0",
|
||||
"@types/uuid": "8.3.4",
|
||||
"body-parser": "1.20.3",
|
||||
@@ -69,7 +69,7 @@
|
||||
"nock": "13.3.1",
|
||||
"node-cache": "5.1.2",
|
||||
"node-cron": "3.0.2",
|
||||
"nodemailer": "6.9.9",
|
||||
"nodemailer": "8.0.11",
|
||||
"prom-client": "14.1.1",
|
||||
"promise-queue": "2.2.5",
|
||||
"uuid": "8.3.2"
|
||||
@@ -100,7 +100,7 @@
|
||||
"supertest": "6.3.3",
|
||||
"ts-node": "10.9.2",
|
||||
"tsup": "8.5.0",
|
||||
"typescript": "5.5.4"
|
||||
"typescript": "5.9.3"
|
||||
},
|
||||
"tsup": {
|
||||
"entry": [
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Logger, SMTP} from '@openstapps/logger';
|
||||
import {MailOptions} from 'nodemailer/lib/sendmail-transport';
|
||||
import {SendMailOptions} from 'nodemailer';
|
||||
import Queue from 'promise-queue';
|
||||
/**
|
||||
* A queue that can send mails in serial
|
||||
@@ -36,7 +36,7 @@ export class MailQueue {
|
||||
* the transport gets ready this mails are getting pushed in to
|
||||
* the normal queue.
|
||||
*/
|
||||
dryQueue: MailOptions[];
|
||||
dryQueue: SendMailOptions[];
|
||||
|
||||
/**
|
||||
* A queue that saves mails, that are being sent in series
|
||||
@@ -68,7 +68,7 @@ export class MailQueue {
|
||||
* Adds a mail into the queue so it gets send when the queue is ready
|
||||
* @param mail Information required for sending a mail
|
||||
*/
|
||||
private async addToQueue(mail: MailOptions) {
|
||||
private async addToQueue(mail: SendMailOptions) {
|
||||
return this.queue.add<string>(() => this.transport.sendMail(mail));
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ export class MailQueue {
|
||||
* Push a mail into the queue so it gets send when the queue is ready
|
||||
* @param mail Information required for sending a mail
|
||||
*/
|
||||
public async push(mail: MailOptions) {
|
||||
public async push(mail: SendMailOptions) {
|
||||
if (this.transport.isVerified()) {
|
||||
await this.addToQueue(mail);
|
||||
} else {
|
||||
|
||||
@@ -19,7 +19,7 @@ import sinon from 'sinon';
|
||||
import {MailQueue} from '../../src/notification/mail-queue.js';
|
||||
import {expect} from 'chai';
|
||||
import Queue from 'promise-queue';
|
||||
import {MailOptions} from 'nodemailer/lib/sendmail-transport';
|
||||
import {SendMailOptions} from 'nodemailer';
|
||||
import {getTransport, TRANSPORT_SEND_RESPONSE} from '../common.js';
|
||||
|
||||
describe('MailQueue', async function () {
|
||||
@@ -54,7 +54,7 @@ describe('MailQueue', async function () {
|
||||
const transport = getTransport(false);
|
||||
// @ts-expect-error not assignable
|
||||
const mailQueue = new MailQueue(transport);
|
||||
const mail: MailOptions = {from: 'Foo', subject: 'Foo Subject'};
|
||||
const mail: SendMailOptions = {from: 'Foo', subject: 'Foo Subject'};
|
||||
for (let i = 0; i < numberOfMails; i++) {
|
||||
await mailQueue.push(mail);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ describe('MailQueue', async function () {
|
||||
const queueAddStub = sandbox.stub(Queue.prototype, 'add');
|
||||
// @ts-expect-error not assignable
|
||||
const mailQueue = new MailQueue(getTransport(false));
|
||||
const mail: MailOptions = {};
|
||||
const mail: SendMailOptions = {};
|
||||
mailQueue.push(mail);
|
||||
|
||||
expect(queueAddStub.called).to.be.false;
|
||||
@@ -81,7 +81,7 @@ describe('MailQueue', async function () {
|
||||
const transport = getTransport(false);
|
||||
// @ts-expect-error not assignable
|
||||
const mailQueue = new MailQueue(transport);
|
||||
const mail: MailOptions = {from: 'Foo', subject: 'Foo Subject'};
|
||||
const mail: SendMailOptions = {from: 'Foo', subject: 'Foo Subject'};
|
||||
// fake that transport is verified
|
||||
transport.isVerified = () => true;
|
||||
mailQueue.push(mail);
|
||||
@@ -97,7 +97,7 @@ describe('MailQueue', async function () {
|
||||
const transport = getTransport(false);
|
||||
// @ts-expect-error not assignable
|
||||
const mailQueue = new MailQueue(transport);
|
||||
const mail: MailOptions = {from: 'Foo', subject: 'Foo Subject'};
|
||||
const mail: SendMailOptions = {from: 'Foo', subject: 'Foo Subject'};
|
||||
// fake that transport is verified
|
||||
transport.isVerified = () => true;
|
||||
await mailQueue.push(mail);
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
"is-cidr": "4.0.2",
|
||||
"mustache": "4.2.0",
|
||||
"semver": "7.6.0",
|
||||
"typescript": "5.5.4"
|
||||
"typescript": "5.9.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openstapps/api-cli": "workspace:*",
|
||||
|
||||
Reference in New Issue
Block a user