- added own provider for drive methods

- renamed middleware Role and Can to role_middleware and can_middleware
- added some typing for inertia vue3 components
- npm updates
This commit is contained in:
Kaimbacher 2024-04-23 19:36:45 +02:00
parent cb51a4136f
commit 296c8fd46e
67 changed files with 2515 additions and 1913 deletions

View file

@ -1,9 +1,4 @@
// import { ModelQueryBuilderContract } from '@adonisjs/lucid/types/model';
// import { LucidModel } from '@adonisjs/lucid/types/model';
import { Request, Response } from '@adonisjs/core/http';
// import BaseModel from '#app/Models/BaseModel';
// import { LucidModel } from '@adonisjs/lucid/types/model';
// import BaseModel from '#app/Models/BaseModel';
Request.macro('wantsJSON', function (this: Request) {
const firstType = this.types()[0];
@ -22,11 +17,31 @@ declare module '@adonisjs/core/http' {
// By specifying this: Response in the function signature, you're explicitly stating
// that 'this' within the function should be of type 'Response', which resolves the TypeScript error.
Response.macro('flash', function (this: Response, key: string, message: any) {
// Response.macro('flash', function (this: Response, message: any) {
// if (!this.ctx) {
// throw new Error('Context is not available');
// }
// this.ctx!.session.flash(message);
// return this;
// });
// Response.macro('flash', function (this: Response, key: string, message: any) {
// if (!this.ctx) {
// throw new Error('Context is not available');
// }
// this.ctx!.session.flash(key, message);
// return this;
// });
Response.macro('flash', function (this: Response, message: any, key?: string,) {
if (!this.ctx) {
throw new Error('Context is not available');
}
this.ctx!.session.flash(key, message);
if (key !== undefined) {
this.ctx!.session.flash(key, message);
} else {
this.ctx!.session.flash(message);
}
return this;
});
Response.macro('toRoute', function (this: Response, route: string) {
@ -35,6 +50,7 @@ Response.macro('toRoute', function (this: Response, route: string) {
});
declare module '@adonisjs/core/http' {
interface Response {
flash(message: any): Response;
flash(key: string, message: any): Response;
toRoute(route: string): Response;
}