forked from geolba/tethys.backend
- update to AdonisJS 6
This commit is contained in:
parent
f828ca4491
commit
cb51a4136f
167 changed files with 21485 additions and 21212 deletions
|
|
@ -1,11 +1,10 @@
|
|||
import type { ApplicationContract } from '@ioc:Adonis/Core/Application';
|
||||
import type Hash from '@ioc:Adonis/Core/Hash';
|
||||
// import HttpContextContract from '@ioc:Adonis/Core/HttpContext';
|
||||
import type Response from '@ioc:Adonis/Core/Response';
|
||||
import { LaravelHash } from './HashDriver';
|
||||
// // import HttpContextContract from '@ioc:Adonis/Core/HttpContext';
|
||||
// import { LaravelHash } from './HashDriver/index.js';
|
||||
import { ApplicationService } from '@adonisjs/core/types';
|
||||
// import { validator } from '@adonisjs/validator';
|
||||
|
||||
export default class AppProvider {
|
||||
constructor(protected app: ApplicationContract) {}
|
||||
constructor(protected app: ApplicationService) {}
|
||||
|
||||
public register() {
|
||||
// Register your own bindings
|
||||
|
|
@ -13,26 +12,36 @@ export default class AppProvider {
|
|||
|
||||
public async boot() {
|
||||
// IoC container is ready
|
||||
const hashInstance: typeof Hash = this.app.container.use('Adonis/Core/Hash');
|
||||
hashInstance.extend('bcrypt', () => {
|
||||
return new LaravelHash();
|
||||
});
|
||||
|
||||
const responseInstance: typeof Response = this.app.container.use('Adonis/Core/Response');
|
||||
responseInstance.macro('flash', function (key: string, message: any) {
|
||||
this.ctx!.session.flash(key, message);
|
||||
return this;
|
||||
});
|
||||
responseInstance.macro('toRoute', function (route: string) {
|
||||
this.redirect().toRoute(route);
|
||||
return this;
|
||||
});
|
||||
// this.app.container.singleton('Adonis/Core/Response', () => {
|
||||
// return FlashResponse;
|
||||
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.singleton('Adonis/Core/HttpContext', () => {
|
||||
// });
|
||||
|
||||
|
||||
// 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,
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
public async ready() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue