fix(core): update
This commit is contained in:
@ -1,17 +1,16 @@
|
||||
import * as plugins from './email.plugins.js';
|
||||
import { Email } from './email.classes.email.js';
|
||||
import { request } from 'http';
|
||||
import { logger } from './email.logging.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import { EmailService } from './email.classes.emailservice.js';
|
||||
import { logger } from '../logger.js';
|
||||
|
||||
export class ApiManager {
|
||||
public emailRef: Email;
|
||||
public emailRef: EmailService;
|
||||
|
||||
public typedRouter = new plugins.typedrequest.TypedRouter();
|
||||
|
||||
constructor(emailRefArg: Email) {
|
||||
constructor(emailRefArg: EmailService) {
|
||||
this.emailRef = emailRefArg;
|
||||
this.emailRef.mainTypedRouter.addTypedRouter(this.typedRouter);
|
||||
this.typedRouter.addTypedHandler<plugins.lointEmail.IRequestSendEmail>(
|
||||
this.emailRef.typedrouter.addTypedRouter(this.typedRouter);
|
||||
this.typedRouter.addTypedHandler<plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail>(
|
||||
new plugins.typedrequest.TypedHandler('sendEmail', async (requestData) => {
|
||||
const mailToSend = new plugins.smartmail.Smartmail({
|
||||
body: requestData.body,
|
||||
@ -22,7 +21,7 @@ export class ApiManager {
|
||||
if (requestData.attachments) {
|
||||
for (const attachment of requestData.attachments) {
|
||||
mailToSend.addAttachment(
|
||||
await plugins.smartfile.Smartfile.fromString(
|
||||
await plugins.smartfile.SmartFile.fromString(
|
||||
attachment.name,
|
||||
attachment.binaryAttachmentString,
|
||||
'binary'
|
||||
|
@ -1,11 +1,11 @@
|
||||
import * as plugins from './email.plugins.js';
|
||||
import { Email } from './email.classes.email.js';
|
||||
import { EmailService } from './email.classes.emailservice.js';
|
||||
|
||||
export class MailgunConnector {
|
||||
public emailRef: Email;
|
||||
public emailRef: EmailService;
|
||||
public mailgunAccount: plugins.mailgun.MailgunAccount;
|
||||
|
||||
constructor(emailRefArg: Email) {
|
||||
constructor(emailRefArg: EmailService) {
|
||||
this.emailRef = emailRefArg;
|
||||
this.mailgunAccount = new plugins.mailgun.MailgunAccount({
|
||||
apiToken: this.emailRef.qenv.getEnvVarOnDemand('MAILGUN_API_TOKEN'),
|
||||
|
@ -1,16 +1,16 @@
|
||||
import * as plugins from './email.plugins.js';
|
||||
import * as paths from './email.paths.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import * as paths from '../paths.js';
|
||||
import { MailgunConnector } from './email.classes.connector.mailgun.js';
|
||||
import { RuleManager } from './email.classes.rulemanager.js';
|
||||
import { ApiManager } from './email.classes.apimanager.js';
|
||||
import { logger } from './email.logging.js';
|
||||
import { logger } from '../logger.js';
|
||||
import type { SzPlatformService } from '../classes.platformservice.js';
|
||||
|
||||
export class Email {
|
||||
export class EmailService {
|
||||
public platformServiceRef: SzPlatformService;
|
||||
|
||||
// typedrouter
|
||||
public mainTypedRouter = new plugins.typedrequest.TypedRouter();
|
||||
public typedrouter = new plugins.typedrequest.TypedRouter();
|
||||
|
||||
// connectors
|
||||
public mailgunConnector: MailgunConnector;
|
||||
@ -22,11 +22,12 @@ export class Email {
|
||||
|
||||
constructor(platformServiceRefArg: SzPlatformService) {
|
||||
this.platformServiceRef = platformServiceRefArg;
|
||||
this.platformServiceRef.typedrouter.addTypedRouter(this.typedrouter);
|
||||
this.mailgunConnector = new MailgunConnector(this);
|
||||
this.ruleManager = new RuleManager(this);
|
||||
this.platformServiceRef.typedserver.server.addRoute(
|
||||
'/mailgun-notify',
|
||||
new plugins.loleServiceserver.Handler('POST', async (req, res) => {
|
||||
new plugins.typedserver.servertools.Handler('POST', async (req, res) => {
|
||||
console.log('Got a mailgun email notification');
|
||||
res.status(200);
|
||||
res.end();
|
@ -1,14 +1,14 @@
|
||||
import * as plugins from './email.plugins.js';
|
||||
import { Email } from './email.classes.email.js';
|
||||
import { EmailService } from './email.classes.emailservice.js';
|
||||
import { logger } from './email.logging.js';
|
||||
|
||||
export class RuleManager {
|
||||
public emailRef: Email;
|
||||
public emailRef: EmailService;
|
||||
public smartruleInstance = new plugins.smartrule.SmartRule<
|
||||
plugins.smartmail.Smartmail<plugins.mailgun.IMailgunMessage>
|
||||
>();
|
||||
|
||||
constructor(emailRefArg: Email) {
|
||||
constructor(emailRefArg: EmailService) {
|
||||
this.emailRef = emailRefArg;
|
||||
}
|
||||
|
||||
|
@ -1,13 +0,0 @@
|
||||
import * as plugins from './email.plugins.js';
|
||||
import * as paths from './email.paths.js';
|
||||
|
||||
const projectInfoNpm = new plugins.projectinfo.ProjectinfoNpm(paths.packageDir);
|
||||
|
||||
export const logger = plugins.loleLog.createLoleLogger({
|
||||
companyUnit: 'lossless.cloud',
|
||||
containerName: 'email',
|
||||
containerVersion: projectInfoNpm.version,
|
||||
sentryAppName: 'email',
|
||||
sentryDsn: 'https://7037e86f36134ced85ae56a57daa1e5e@o169278.ingest.sentry.io/5280282',
|
||||
zone: 'servezone',
|
||||
});
|
@ -1,6 +0,0 @@
|
||||
import * as plugins from './email.plugins.js';
|
||||
|
||||
export const packageDir = plugins.path.join(
|
||||
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||
'../'
|
||||
);
|
@ -1,43 +0,0 @@
|
||||
// native scope
|
||||
import * as path from 'path';
|
||||
|
||||
export { path };
|
||||
|
||||
// @losslessone_private scope
|
||||
import * as loleLog from '@losslessone_private/lole-log';
|
||||
import * as loleServiceserver from '@losslessone_private/lole-serviceserver';
|
||||
|
||||
import * as lointEmail from '@losslessone_private/loint-email';
|
||||
|
||||
export { loleLog, loleServiceserver, lointEmail };
|
||||
|
||||
// @apiglobal scope
|
||||
import * as typedrequest from '@apiglobal/typedrequest';
|
||||
|
||||
export { typedrequest };
|
||||
|
||||
// @mojoio scope
|
||||
import * as mailgun from '@mojoio/mailgun';
|
||||
|
||||
export { mailgun };
|
||||
|
||||
// @pushrocks scope
|
||||
import * as projectinfo from '@pushrocks/projectinfo';
|
||||
import * as qenv from '@pushrocks/qenv';
|
||||
import * as smartfile from '@pushrocks/smartfile';
|
||||
import * as smartmail from '@pushrocks/smartmail';
|
||||
import * as smartpath from '@pushrocks/smartpath';
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
import * as smartrule from '@pushrocks/smartrule';
|
||||
import * as smartvalidator from '@pushrocks/smartvalidator';
|
||||
|
||||
export {
|
||||
projectinfo,
|
||||
qenv,
|
||||
smartfile,
|
||||
smartmail,
|
||||
smartpath,
|
||||
smartrequest,
|
||||
smartrule,
|
||||
smartvalidator,
|
||||
};
|
@ -1,3 +1,3 @@
|
||||
import { Email } from './email.classes.email.js';
|
||||
import { EmailService } from './email.classes.emailservice.js';
|
||||
|
||||
export { Email };
|
||||
export { EmailService as Email };
|
Reference in New Issue
Block a user