first commit

This commit is contained in:
ANU8151
2021-01-07 21:37:31 +04:00
commit 80bf1ba1d1
39 changed files with 33333 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
export default class WelcomesController {
public async index({ inertia }: HttpContextContract) {
const Text = 'InertiaJS + Vue3 + Tailwind CSS + AdonisJS';
return inertia.render('welcome', { Text });
}
public async about({ inertia }: HttpContextContract) {
const Text = 'This is About Page';
return inertia.render('About/About', { Text });
}
}

42
app/Exceptions/Handler.ts Normal file
View File

@@ -0,0 +1,42 @@
/*
|--------------------------------------------------------------------------
| Http Exception Handler
|--------------------------------------------------------------------------
|
| AdonisJs will forward all exceptions occurred during an HTTP request to
| the following class. You can learn more about exception handling by
| reading docs.
|
| The exception handler extends a base `HttpExceptionHandler` which is not
| mandatory, however it can do lot of heavy lifting to handle the errors
| properly.
|
*/
import Logger from '@ioc:Adonis/Core/Logger';
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
import HttpExceptionHandler from '@ioc:Adonis/Core/HttpExceptionHandler';
export default class ExceptionHandler extends HttpExceptionHandler {
protected statusPages = {
'404': 'errors.not-found',
'500..599': 'errors.server-error',
};
public async handle(error: any, ctx: HttpContextContract) {
const { inertia, session } = ctx;
this.logger.error(error);
if (error.code === 'E_VALIDATION_FAILURE' && inertia.isInertia()) {
session.flash('errors', error);
return inertia.redirectBack(); // This ensures that the response has the correct HTTP code
}
return super.handle(error, ctx);
}
constructor() {
super(Logger);
}
}