fix(core): update
This commit is contained in:
parent
2adcc249de
commit
01dcdebda5
@ -25,6 +25,7 @@
|
|||||||
"@api.global/typedserver": "^3.0.20",
|
"@api.global/typedserver": "^3.0.20",
|
||||||
"@api.global/typedsocket": "^3.0.0",
|
"@api.global/typedsocket": "^3.0.0",
|
||||||
"@apiclient.xyz/cloudflare": "^6.0.3",
|
"@apiclient.xyz/cloudflare": "^6.0.3",
|
||||||
|
"@apiclient.xyz/letterxpress": "^1.0.16",
|
||||||
"@push.rocks/projectinfo": "^5.0.1",
|
"@push.rocks/projectinfo": "^5.0.1",
|
||||||
"@push.rocks/qenv": "^6.0.5",
|
"@push.rocks/qenv": "^6.0.5",
|
||||||
"@push.rocks/smartdata": "^5.0.7",
|
"@push.rocks/smartdata": "^5.0.7",
|
||||||
|
1145
pnpm-lock.yaml
1145
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@serve.zone/platformservice',
|
name: '@serve.zone/platformservice',
|
||||||
version: '1.0.4',
|
version: '1.0.5',
|
||||||
description: 'contains the platformservice container with mail, sms, letter, ai services.'
|
description: 'contains the platformservice container with mail, sms, letter, ai services.'
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
import * as plugins from './plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
import * as paths from './paths.js';
|
import * as paths from './paths.js';
|
||||||
import { PlatformServiceDb } from './classes.platformservicedb.js'
|
import { PlatformServiceDb } from './classes.platformservicedb.js'
|
||||||
|
import { EmailService } from './email/email.classes.emailservice.js';
|
||||||
|
import { SmsService } from './sms/smsservice.js';
|
||||||
|
import { LetterService } from './letter/classes.letterservice.js';
|
||||||
|
import { MtaService } from './mta/mta.classes.mta.js';
|
||||||
|
|
||||||
export class SzPlatformService {
|
export class SzPlatformService {
|
||||||
public projectinfo: plugins.projectinfo.ProjectInfo;
|
public projectinfo: plugins.projectinfo.ProjectInfo;
|
||||||
@ -10,9 +14,28 @@ export class SzPlatformService {
|
|||||||
public typedserver: plugins.typedserver.TypedServer;
|
public typedserver: plugins.typedserver.TypedServer;
|
||||||
public typedrouter = new plugins.typedrequest.TypedRouter();
|
public typedrouter = new plugins.typedrequest.TypedRouter();
|
||||||
|
|
||||||
|
// SubServices
|
||||||
|
public emailService: EmailService;
|
||||||
|
public letterService: LetterService;
|
||||||
|
public mtaService: MtaService;
|
||||||
|
public smsService: SmsService;
|
||||||
|
|
||||||
public async start() {
|
public async start() {
|
||||||
this.platformserviceDb = new PlatformServiceDb(this);
|
this.platformserviceDb = new PlatformServiceDb(this);
|
||||||
this.projectinfo = new plugins.projectinfo.ProjectInfo(paths.packageDir);
|
this.projectinfo = new plugins.projectinfo.ProjectInfo(paths.packageDir);
|
||||||
|
|
||||||
|
// lets start the sub services
|
||||||
|
this.emailService = new EmailService(this);
|
||||||
|
this.letterService = new LetterService(this, {
|
||||||
|
letterxpressUser: await this.serviceQenv.getEnvVarOnDemand('LETTER_API_USER'),
|
||||||
|
letterxpressToken: await this.serviceQenv.getEnvVarOnDemand('LETTER_API_TOKEN')
|
||||||
|
});
|
||||||
|
this.mtaService = new MtaService(this);
|
||||||
|
this.smsService = new SmsService(this, {
|
||||||
|
apiGatewayApiToken: await this.serviceQenv.getEnvVarOnDemand('SMS_API_TOKEN'),
|
||||||
|
});
|
||||||
|
|
||||||
|
// lets start the server finally
|
||||||
this.typedserver = new plugins.typedserver.TypedServer({
|
this.typedserver = new plugins.typedserver.TypedServer({
|
||||||
cors: true,
|
cors: true,
|
||||||
});
|
});
|
||||||
|
@ -6,6 +6,11 @@ import { ApiManager } from './email.classes.apimanager.js';
|
|||||||
import { logger } from '../logger.js';
|
import { logger } from '../logger.js';
|
||||||
import type { SzPlatformService } from '../classes.platformservice.js';
|
import type { SzPlatformService } from '../classes.platformservice.js';
|
||||||
|
|
||||||
|
|
||||||
|
export interface IEmailConstructorOptions {
|
||||||
|
mailgunApiKey: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class EmailService {
|
export class EmailService {
|
||||||
public platformServiceRef: SzPlatformService;
|
public platformServiceRef: SzPlatformService;
|
||||||
|
|
||||||
|
17
ts/letter/classes.letterservice.ts
Normal file
17
ts/letter/classes.letterservice.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import type { SzPlatformService } from '../classes.platformservice.js';
|
||||||
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
|
export interface ILetterConstructorOptions {
|
||||||
|
letterxpressUser: string;
|
||||||
|
letterxpressToken: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class LetterService {
|
||||||
|
public platformServiceRef: SzPlatformService;
|
||||||
|
public options: ILetterConstructorOptions;
|
||||||
|
|
||||||
|
constructor(platformServiceRefArg: SzPlatformService, optionsArg: ILetterConstructorOptions) {
|
||||||
|
this.platformServiceRef = platformServiceRefArg;
|
||||||
|
this.options = optionsArg;
|
||||||
|
}
|
||||||
|
}
|
0
ts/letter/index.ts
Normal file
0
ts/letter/index.ts
Normal file
@ -2,7 +2,7 @@ import * as plugins from '../plugins.js';
|
|||||||
import * as paths from '../paths.js';
|
import * as paths from '../paths.js';
|
||||||
|
|
||||||
import { Email } from './mta.classes.email.js';
|
import { Email } from './mta.classes.email.js';
|
||||||
import type { MTA } from './mta.classes.mta.js';
|
import type { MtaService } from './mta.classes.mta.js';
|
||||||
|
|
||||||
const readFile = plugins.util.promisify(plugins.fs.readFile);
|
const readFile = plugins.util.promisify(plugins.fs.readFile);
|
||||||
const writeFile = plugins.util.promisify(plugins.fs.writeFile);
|
const writeFile = plugins.util.promisify(plugins.fs.writeFile);
|
||||||
@ -16,7 +16,7 @@ export interface IKeyPaths {
|
|||||||
export class DKIMCreator {
|
export class DKIMCreator {
|
||||||
private keysDir: string;
|
private keysDir: string;
|
||||||
|
|
||||||
constructor(metaRef: MTA, keysDir = paths.keysDir) {
|
constructor(metaRef: MtaService, keysDir = paths.keysDir) {
|
||||||
this.keysDir = keysDir;
|
this.keysDir = keysDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import * as plugins from '../plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
import { MTA } from './mta.classes.mta.js';
|
import { MtaService } from './mta.classes.mta.js';
|
||||||
|
|
||||||
class DKIMVerifier {
|
class DKIMVerifier {
|
||||||
public mtaRef: MTA;
|
public mtaRef: MtaService;
|
||||||
|
|
||||||
constructor(mtaRefArg: MTA) {
|
constructor(mtaRefArg: MtaService) {
|
||||||
this.mtaRef = mtaRefArg;
|
this.mtaRef = mtaRefArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import type { MTA } from './mta.classes.mta.js';
|
import type { MtaService } from './mta.classes.mta.js';
|
||||||
import * as plugins from '../plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
export class DNSManager {
|
export class DNSManager {
|
||||||
public mtaRef: MTA;
|
public mtaRef: MtaService;
|
||||||
|
|
||||||
constructor(mtaRefArg: MTA) {
|
constructor(mtaRefArg: MtaService) {
|
||||||
this.mtaRef = mtaRefArg;
|
this.mtaRef = mtaRefArg;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,15 +2,15 @@ import * as plugins from '../plugins.js';
|
|||||||
import * as paths from '../paths.js';
|
import * as paths from '../paths.js';
|
||||||
import { Email } from './mta.classes.email.js';
|
import { Email } from './mta.classes.email.js';
|
||||||
import { EmailSignJob } from './mta.classes.emailsignjob.js';
|
import { EmailSignJob } from './mta.classes.emailsignjob.js';
|
||||||
import type { MTA } from './mta.classes.mta.js';
|
import type { MtaService } from './mta.classes.mta.js';
|
||||||
|
|
||||||
export class EmailSendJob {
|
export class EmailSendJob {
|
||||||
mtaRef: MTA;
|
mtaRef: MtaService;
|
||||||
private email: Email;
|
private email: Email;
|
||||||
private socket: plugins.net.Socket | plugins.tls.TLSSocket = null;
|
private socket: plugins.net.Socket | plugins.tls.TLSSocket = null;
|
||||||
private mxRecord: string = null;
|
private mxRecord: string = null;
|
||||||
|
|
||||||
constructor(mtaRef: MTA, emailArg: Email) {
|
constructor(mtaRef: MtaService, emailArg: Email) {
|
||||||
this.email = emailArg;
|
this.email = emailArg;
|
||||||
this.mtaRef = mtaRef;
|
this.mtaRef = mtaRef;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from '../plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
import type { MTA } from './mta.classes.mta.js';
|
import type { MtaService } from './mta.classes.mta.js';
|
||||||
|
|
||||||
interface Headers {
|
interface Headers {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
@ -13,10 +13,10 @@ interface IEmailSignJobOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class EmailSignJob {
|
export class EmailSignJob {
|
||||||
mtaRef: MTA;
|
mtaRef: MtaService;
|
||||||
jobOptions: IEmailSignJobOptions;
|
jobOptions: IEmailSignJobOptions;
|
||||||
|
|
||||||
constructor(mtaRefArg: MTA, options: IEmailSignJobOptions) {
|
constructor(mtaRefArg: MtaService, options: IEmailSignJobOptions) {
|
||||||
this.mtaRef = mtaRefArg;
|
this.mtaRef = mtaRefArg;
|
||||||
this.jobOptions = options;
|
this.jobOptions = options;
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,17 @@ import { DKIMCreator } from './mta.classes.dkimcreator.js';
|
|||||||
import { DKIMVerifier } from './mta.classes.dkimverifier.js';
|
import { DKIMVerifier } from './mta.classes.dkimverifier.js';
|
||||||
import { SMTPServer } from './mta.classes.smtpserver.js';
|
import { SMTPServer } from './mta.classes.smtpserver.js';
|
||||||
import { DNSManager } from './mta.classes.dnsmanager.js';
|
import { DNSManager } from './mta.classes.dnsmanager.js';
|
||||||
|
import type { SzPlatformService } from '../classes.platformservice.js';
|
||||||
|
|
||||||
export class MTA {
|
export class MtaService {
|
||||||
|
public platformServiceRef: SzPlatformService;
|
||||||
public server: SMTPServer;
|
public server: SMTPServer;
|
||||||
public dkimCreator: DKIMCreator;
|
public dkimCreator: DKIMCreator;
|
||||||
public dkimVerifier: DKIMVerifier;
|
public dkimVerifier: DKIMVerifier;
|
||||||
public dnsManager: DNSManager;
|
public dnsManager: DNSManager;
|
||||||
|
|
||||||
constructor() {
|
constructor(platformServiceRefArg: SzPlatformService) {
|
||||||
|
this.platformServiceRef = platformServiceRefArg;
|
||||||
this.dkimCreator = new DKIMCreator(this);
|
this.dkimCreator = new DKIMCreator(this);
|
||||||
this.dkimVerifier = new DKIMVerifier(this);
|
this.dkimVerifier = new DKIMVerifier(this);
|
||||||
this.dnsManager = new DNSManager(this);
|
this.dnsManager = new DNSManager(this);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import * as plugins from '../plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
import * as paths from '../paths.js';
|
import * as paths from '../paths.js';
|
||||||
import { Email } from './mta.classes.email.js';
|
import { Email } from './mta.classes.email.js';
|
||||||
import type { MTA } from './mta.classes.mta.js';
|
import type { MtaService } from './mta.classes.mta.js';
|
||||||
|
|
||||||
export interface ISmtpServerOptions {
|
export interface ISmtpServerOptions {
|
||||||
port: number;
|
port: number;
|
||||||
@ -10,12 +10,12 @@ export interface ISmtpServerOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class SMTPServer {
|
export class SMTPServer {
|
||||||
public mtaRef: MTA;
|
public mtaRef: MtaService;
|
||||||
private smtpServerOptions: ISmtpServerOptions;
|
private smtpServerOptions: ISmtpServerOptions;
|
||||||
private server: plugins.net.Server;
|
private server: plugins.net.Server;
|
||||||
private emailBufferStringMap: Map<plugins.net.Socket, string>;
|
private emailBufferStringMap: Map<plugins.net.Socket, string>;
|
||||||
|
|
||||||
constructor(mtaRefArg: MTA, optionsArg: ISmtpServerOptions) {
|
constructor(mtaRefArg: MtaService, optionsArg: ISmtpServerOptions) {
|
||||||
console.log('SMTPServer instance is being created...');
|
console.log('SMTPServer instance is being created...');
|
||||||
|
|
||||||
this.mtaRef = mtaRefArg;
|
this.mtaRef = mtaRefArg;
|
||||||
|
@ -49,6 +49,13 @@ import * as smartrx from '@push.rocks/smartrx';
|
|||||||
|
|
||||||
export { projectinfo, qenv, smartdata, smartfile, smartlog, smartmail, smartpath, smartpromise, smartrequest, smartrx };
|
export { projectinfo, qenv, smartdata, smartfile, smartlog, smartmail, smartpath, smartpromise, smartrequest, smartrx };
|
||||||
|
|
||||||
|
// apiclient.xyz scope
|
||||||
|
import * as letterxpress from '@apiclient.xyz/letterxpress';
|
||||||
|
|
||||||
|
export {
|
||||||
|
letterxpress,
|
||||||
|
}
|
||||||
|
|
||||||
// tsclass scope
|
// tsclass scope
|
||||||
import * as tsclass from '@tsclass/tsclass';
|
import * as tsclass from '@tsclass/tsclass';
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import { logger } from '../logger.js';
|
|||||||
import type { SzPlatformService } from '../classes.platformservice.js';
|
import type { SzPlatformService } from '../classes.platformservice.js';
|
||||||
|
|
||||||
export interface ISmsConstructorOptions {
|
export interface ISmsConstructorOptions {
|
||||||
apiToken: string;
|
apiGatewayApiToken: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SmsService {
|
export class SmsService {
|
||||||
@ -63,7 +63,7 @@ export class SmsService {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
requestBody: JSON.stringify(payload),
|
requestBody: JSON.stringify(payload),
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Basic ${Buffer.from(`${this.options.apiToken}:`).toString('base64')}`,
|
Authorization: `Basic ${Buffer.from(`${this.options.apiGatewayApiToken}:`).toString('base64')}`,
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user