forked from geolba/tethys.backend
- npm added @japa/api-client, @japa/assert, @types/supertest
- webpack added opions['__VUE_PROD_HYDRATION_MISMATCH_DETAILS__'] = false; - bodyparser config replaced whitelistedMethods with allowedMethods - extended stardust_provider - adapted tests for adonisjs v6
This commit is contained in:
parent
296c8fd46e
commit
bee76f8d5b
23 changed files with 2014 additions and 165 deletions
|
@ -1,27 +1,47 @@
|
|||
import type { HttpContext } from '@adonisjs/core/http';
|
||||
import type { NextFn } from '@adonisjs/core/types/http';
|
||||
|
||||
|
||||
declare global {
|
||||
function myFunction(): boolean;
|
||||
var myVariable: number;
|
||||
|
||||
interface StardustData {
|
||||
pathname?: string;
|
||||
namedRoutes?: Record<string, string>;
|
||||
}
|
||||
var stardust: StardustData;
|
||||
}
|
||||
|
||||
declare global {}
|
||||
export default class StardustMiddleware {
|
||||
async handle(ctx: HttpContext, next: NextFn): Promise<void> {
|
||||
/**
|
||||
* Middleware logic goes here (before the next call)
|
||||
*/
|
||||
// console.log(ctx);
|
||||
const { pathname } = new URL(ctx.request.completeUrl());
|
||||
globalThis.stardust = {
|
||||
...globalThis.stardust,
|
||||
pathname,
|
||||
};
|
||||
|
||||
/**
|
||||
* Call next method in the pipeline and return its output
|
||||
*/
|
||||
const output = await next();
|
||||
return output;
|
||||
// Check if the request is an API request
|
||||
if (!ctx.request.url().startsWith('/api')) {
|
||||
// Middleware logic for non-API requests
|
||||
const { pathname } = new URL(ctx.request.completeUrl()); // '/', '/app/login'
|
||||
globalThis.myFunction = () => {
|
||||
return true;
|
||||
};
|
||||
globalThis.myVariable = 1;
|
||||
|
||||
globalThis.stardust = {
|
||||
...globalThis.stardust,
|
||||
pathname,
|
||||
};
|
||||
|
||||
/**
|
||||
* Call next method in the pipeline and return its output
|
||||
*/
|
||||
await next();
|
||||
} else {
|
||||
// Skip middleware for API requests
|
||||
await next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
|
||||
// export default class StardustMiddleware {
|
||||
// handle({ request }: HttpContextContract, next: () => Promise<void>): Promise<void>;
|
||||
// }
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue