tethys.backend/app/Middleware/stardust_middleware.ts

28 lines
874 B
TypeScript

import type { HttpContext } from '@adonisjs/core/http';
import type { NextFn } from '@adonisjs/core/types/http';
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;
}
}
// import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
// export default class StardustMiddleware {
// handle({ request }: HttpContextContract, next: () => Promise<void>): Promise<void>;
// }