tethys.backend/start/inertia.json

48 lines
1.2 KiB
JSON
Raw Normal View History

2023-03-03 15:54:28 +00:00
/*
|--------------------------------------------------------------------------
| Inertia Preloaded File
|--------------------------------------------------------------------------
|
| Any code written inside this file will be executed during the application
| boot.
|
*/
import Inertia from '@ioc:EidelLev/Inertia';
2024-03-14 19:25:27 +00:00
import type { HttpContext } from '@adonisjs/core/http';
2023-03-03 15:54:28 +00:00
Inertia.share({
errors: (ctx) => {
return ctx.session.flashMessages.get('errors');
},
user_id: (ctx) => {
return ctx.session.flashMessages.get('user_id');
},
2023-03-03 15:54:28 +00:00
flash: (ctx) => {
return {
message: ctx.session.flashMessages.get('message'),
warning: ctx.session.flashMessages.get('warning'),
2023-03-03 15:54:28 +00:00
};
},
// params: ({ params }) => params,
2024-03-14 19:25:27 +00:00
authUser: async ({ auth }: HttpContext) => {
2023-03-03 15:54:28 +00:00
if (auth.user) {
await auth.user.load('roles');
2023-03-03 15:54:28 +00:00
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'),
// ],