tethys.backend/providers/app_provider.ts

55 lines
1.8 KiB
TypeScript
Raw Normal View History

2024-03-14 19:25:27 +00:00
// // import HttpContextContract from '@ioc:Adonis/Core/HttpContext';
// import { LaravelHash } from './HashDriver/index.js';
import { ApplicationService } from '@adonisjs/core/types';
// import { validator } from '@adonisjs/validator';
2023-03-03 15:54:28 +00:00
export default class AppProvider {
2024-03-14 19:25:27 +00:00
constructor(protected app: ApplicationService) {}
2023-03-03 15:54:28 +00:00
public register() {
// Register your own bindings
}
public async boot() {
// IoC container is ready
2024-03-14 19:25:27 +00:00
await import('../src/extensions.js');
// const hashInstance: typeof hash = this.app.container.make('@adonisjs/core/services/hash');
// hashInstance.extend('bcrypt', () => {
// return new LaravelHash();
// });
2024-03-14 19:25:27 +00:00
// this.app.container.resolving('validator', (validator) => {
// validator.rule('foo', () => {})
// validator.rule('fileExtension', async (value, [extensions], { pointer, arrayExpressionPointer, errorReporter }) => {
// const allowedExtensions = extensions.map((ext: string) => ext.toLowerCase());
// const uploadedFile = value;
// if (!uploadedFile) {
// return;
// }
// const extension = uploadedFile.extname.toLowerCase().replace('.', '');
// if (!allowedExtensions.includes(extension)) {
// errorReporter.report(
// pointer,
// 'fileExtension',
// 'Invalid file extension. Only {{ extensions }} files are allowed.',
// arrayExpressionPointer,
// );
// }
// });
2023-03-03 15:54:28 +00:00
}
public async ready() {
// App is ready
}
public async shutdown() {
// Cleanup, since app is going down
}
}