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
|
2024-09-16 15:59:46 +00:00
|
|
|
|
2023-03-03 15:54:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public async boot() {
|
|
|
|
// IoC container is ready
|
2024-03-14 19:25:27 +00:00
|
|
|
await import('../src/extensions.js');
|
2024-09-16 15:59:46 +00:00
|
|
|
|
2024-03-14 19:25:27 +00:00
|
|
|
// const hashInstance: typeof hash = this.app.container.make('@adonisjs/core/services/hash');
|
|
|
|
// hashInstance.extend('bcrypt', () => {
|
|
|
|
// return new LaravelHash();
|
2023-06-27 16:23:18 +00:00
|
|
|
// });
|
|
|
|
|
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() {
|
2024-09-16 15:59:46 +00:00
|
|
|
// App is ready
|
2023-03-03 15:54:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public async shutdown() {
|
|
|
|
// Cleanup, since app is going down
|
|
|
|
}
|
|
|
|
}
|