2024-03-14 19:25:27 +00:00
|
|
|
import { defineConfig } from '@adonisjs/inertia';
|
|
|
|
import type { HttpContext } from '@adonisjs/core/http';
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
/**
|
|
|
|
* Path to the Edge view that will be used as the root view for Inertia responses
|
|
|
|
*/
|
|
|
|
rootView: 'app',
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data that should be shared with all rendered pages
|
|
|
|
*/
|
|
|
|
sharedData: {
|
2024-04-29 09:25:50 +00:00
|
|
|
//This will be available in all views
|
|
|
|
appName: 'Tethys Cloud',
|
|
|
|
|
2024-04-23 17:36:45 +00:00
|
|
|
errors: (ctx) => ctx.session?.flashMessages.get('errors'),
|
2024-03-14 19:25:27 +00:00
|
|
|
|
|
|
|
user_id: (ctx) => {
|
2024-04-23 17:36:45 +00:00
|
|
|
return ctx.session?.flashMessages.get('user_id');
|
2024-03-14 19:25:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
flash: (ctx) => {
|
|
|
|
return {
|
2024-04-23 17:36:45 +00:00
|
|
|
message: ctx.session?.flashMessages.get('message'),
|
|
|
|
warning: ctx.session?.flashMessages.get('warning'),
|
2024-09-26 11:51:35 +00:00
|
|
|
error: ctx.session?.flashMessages.get('error'),
|
2024-03-14 19:25:27 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
// params: ({ params }) => params,
|
|
|
|
authUser: async ({ auth }: HttpContext) => {
|
2024-04-23 17:36:45 +00:00
|
|
|
if (auth?.user) {
|
2024-03-14 19:25:27 +00:00
|
|
|
await auth.user.load('roles');
|
|
|
|
return auth.user;
|
|
|
|
// {
|
|
|
|
// 'id': auth.user.id,
|
|
|
|
// 'login': auth.user.login,
|
|
|
|
// };
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2024-04-23 17:36:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Options for the server-side rendering
|
|
|
|
*/
|
|
|
|
ssr: {
|
|
|
|
enabled: false,
|
|
|
|
entrypoint: 'inertia/app/ssr.ts',
|
|
|
|
},
|
2024-03-14 19:25:27 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// import { InertiaConfig } from '@ioc:EidelLev/Inertia';
|
|
|
|
|
|
|
|
// /*
|
|
|
|
// |--------------------------------------------------------------------------
|
|
|
|
// | Inertia-AdonisJS config
|
|
|
|
// |--------------------------------------------------------------------------
|
|
|
|
// |
|
|
|
|
// */
|
|
|
|
|
|
|
|
// export const inertia: InertiaConfig = {
|
|
|
|
// view: 'app',
|
|
|
|
// // ssr: {
|
|
|
|
// // enabled: false,
|
|
|
|
// // },
|
|
|
|
// };
|