- added @adonisjs/mail
Some checks failed
CI Pipeline / japa-tests (push) Failing after 1m2s

- mail_settings_controller for setting smtp settings
- added view ror rjecting dataset for editor
- added new model AppConfig for stroing appwide config values
- better validate_chesum.ts command with process chunking
- added vue3 apps 'BasicSettings' like email, profile settings
- started with 2 multilingual capabilities
- npm updates
This commit is contained in:
Kaimbacher 2024-09-16 17:59:46 +02:00
parent 010bead723
commit b06ccae603
67 changed files with 7820 additions and 1463 deletions

View file

@ -8,18 +8,18 @@ export default class AppProvider {
public register() {
// Register your own bindings
}
public async boot() {
// IoC container is ready
await import('../src/extensions.js');
// const hashInstance: typeof hash = this.app.container.make('@adonisjs/core/services/hash');
// hashInstance.extend('bcrypt', () => {
// return new LaravelHash();
// });
// this.app.container.resolving('validator', (validator) => {
// validator.rule('foo', () => {})
@ -45,7 +45,7 @@ export default class AppProvider {
}
public async ready() {
// App is ready
// App is ready
}
public async shutdown() {

108
providers/mail_provider.ts Normal file
View file

@ -0,0 +1,108 @@
/*
* @adonisjs/mail
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { configProvider } from '@adonisjs/core';
import { RuntimeException } from '@poppinss/utils';
import type { ApplicationService } from '@adonisjs/core/types';
// import { MailManager, Mailer, Message } from '../index.js'
import { MailManager, Mailer, Message } from '@adonisjs/mail';
// import type { MailEvents, MailService } from '../src/types.js'
import type { MailEvents, MailService } from '@adonisjs/mail/types';
import env from '#start/env';
// import { mailPluginEdge } from '@adonisjs/mail';
/**
* Extended types
*/
declare module '@adonisjs/core/types' {
export interface ContainerBindings {
'mail.manager': MailService;
}
export interface EventsList extends MailEvents {}
}
/**
* Mail provider to register mail manager with the container
*/
export default class MailProvider {
constructor(protected app: ApplicationService) {}
/**
* Defines the template engine on the message class to
* render templates
*/
protected async defineTemplateEngine() {
if (this.app.usingEdgeJS) {
const edge = await import('edge.js');
Message.templateEngine = {
render(templatePath, helpers, data) {
return edge.default.share(helpers).render(templatePath, data);
},
};
const { mailPluginEdge } = await import('@adonisjs/mail/plugins/edge');
edge.default.use(mailPluginEdge);
}
}
/**
* Registering bindings to container
*/
register() {
// process.env.SMTP_HOST = 'xhost';
env.set("SMTP_HOST", 'xhost');
// this.app.config.set('mail.mailers.smtp.host', 'xhost');
this.app.container.singleton('mail.manager', async (resolver) => {
const emitter = await resolver.make('emitter');
this.app.config.set('mail.mailers.smtp.host', 'xhost');
// env.set("SMTP_HOST", 'xhost');
// env.set("SMTP_PORT", '333');
// Reset or modify environment variables here
const mailConfigProvider = this.app.config.get('mail');
const config = await configProvider.resolve<any>(this.app, mailConfigProvider);
const iwas = await config.mailers.smtp();
// iwas.config.host = 'hhhost';
// this.app.config.set('mail.mailers.smtp.host', 'xhost');
// const iwas = await config.mailers.smtp();
// const smtpConfigProvider = await this.app.config.get('mail.mailers.smtp');
// const smtpConfig = await configProvider.resolve<any>(this.app, smtpConfigProvider);
// let test = config.get('mailers.smtp');
if (!config) {
throw new RuntimeException('Invalid "config/mail.ts" file. Make sure you are using the "defineConfig" method');
}
return new MailManager(emitter, config);
});
this.app.container.bind(Mailer, async (resolver) => {
const mailManager = await resolver.make('mail.manager');
return mailManager.use();
});
}
/**
* Invoked automatically when the app is booting
*/
async boot() {
await this.defineTemplateEngine();
}
/**
* Cleanup hook
*/
async shutdown() {
const mail = await this.app.container.make('mail.manager');
await mail.closeAll();
}
}