tethys.backend/start/inertia.json
Arno Kaimbacher cb51a4136f
Some checks failed
CI Pipeline / japa-tests (push) Failing after 1m15s
- update to AdonisJS 6
2024-03-14 20:25:27 +01:00

48 lines
1.2 KiB
JSON

/*
|--------------------------------------------------------------------------
| Inertia Preloaded File
|--------------------------------------------------------------------------
|
| Any code written inside this file will be executed during the application
| boot.
|
*/
import Inertia from '@ioc:EidelLev/Inertia';
import type { HttpContext } from '@adonisjs/core/http';
Inertia.share({
errors: (ctx) => {
return ctx.session.flashMessages.get('errors');
},
user_id: (ctx) => {
return ctx.session.flashMessages.get('user_id');
},
flash: (ctx) => {
return {
message: ctx.session.flashMessages.get('message'),
warning: ctx.session.flashMessages.get('warning'),
};
},
// params: ({ params }) => params,
authUser: async ({ auth }: HttpContext) => {
if (auth.user) {
await auth.user.load('roles');
return auth.user;
// {
// 'id': auth.user.id,
// 'login': auth.user.login,
// };
} else {
return null;
}
},
}).version(() => Inertia.manifestFile('public/assets/manifest.json'));
// 'flash' => [
// 'message' => fn () => $request->session()->get('message'),
// ],