TASKS-1823 WebManager module

This commit is contained in:
Igor Martyniuk
2026-08-28 08:35:58 +00:00
parent fdb2cf3837
commit c93d8c025b
654 changed files with 26232 additions and 6075 deletions
@@ -0,0 +1,8 @@
import { Exception } from '@adonisjs/core/exceptions'
import type { HttpContext } from '@adonisjs/core/http'
export default class ApiException extends Exception {
async handle(error: this, ctx: HttpContext) {
ctx.response.status(error.status).send({ message: error.message, code: error.code })
}
}
@@ -1,6 +1,6 @@
import { Exception } from '@adonisjs/core/exceptions'
import ApiException from '#exceptions/api_exception'
export class FilenameMissingExtensionException extends Exception {
export class FilenameMissingExtensionException extends ApiException {
static status = 400
static code = 'E_FILE_NAME_MISSING_EXTENSION'
@@ -9,7 +9,7 @@ export class FilenameMissingExtensionException extends Exception {
}
}
export class EntryNameNotChangedException extends Exception {
export class EntryNameNotChangedException extends ApiException {
static status = 400
static code = 'E_ENTRY_NAME_NOT_CHANGED'
@@ -18,7 +18,7 @@ export class EntryNameNotChangedException extends Exception {
}
}
export class EntryExistsException extends Exception {
export class EntryExistsException extends ApiException {
static status = 400
static code = 'E_ENTRY_ALREADY_EXISTS'
@@ -27,7 +27,7 @@ export class EntryExistsException extends Exception {
}
}
export class DirExistsException extends Exception {
export class DirExistsException extends ApiException {
static status = 400
static code = 'E_DIRECTORY_ALREADY_EXISTS'
@@ -36,7 +36,7 @@ export class DirExistsException extends Exception {
}
}
export class FileNotFoundException extends Exception {
export class FileNotFoundException extends ApiException {
static status = 404
static code = 'E_FILE_NOT_FOUND'
@@ -45,7 +45,7 @@ export class FileNotFoundException extends Exception {
}
}
export class DirNotFoundException extends Exception {
export class DirNotFoundException extends ApiException {
static status = 404
static code = 'E_DIR_NOT_FOUND'
-38
View File
@@ -1,6 +1,5 @@
import app from '@adonisjs/core/services/app'
import { HttpContext, ExceptionHandler } from '@adonisjs/core/http'
import { Exception } from '@adonisjs/core/exceptions'
export default class HttpExceptionHandler extends ExceptionHandler {
/**
@@ -14,43 +13,6 @@ export default class HttpExceptionHandler extends ExceptionHandler {
* response to the client
*/
async handle(error: unknown, ctx: HttpContext) {
if (error instanceof Exception && error.code === 'E_FILE_NAME_MISSING_EXTENSION') {
return ctx.response.status(error.status).send({
message: error.message,
code: error.code,
})
}
if (error instanceof Exception && error.code === 'E_ENTRY_NAME_NOT_CHANGED') {
return ctx.response.status(error.status).send({
message: error.message,
code: error.code,
})
}
if (error instanceof Exception && error.code === 'E_ENTRY_ALREADY_EXISTS') {
return ctx.response.status(error.status).send({
message: error.message,
code: error.code,
})
}
if (error instanceof Exception && error.code === 'E_DIRECTORY_ALREADY_EXISTS') {
return ctx.response.status(error.status).send({
message: error.message,
code: error.code,
})
}
if (error instanceof Exception && error.code === 'E_FILE_NOT_FOUND') {
return ctx.response.status(error.status).send({
message: error.message,
code: error.code,
})
}
if (error instanceof Exception && error.code === 'E_DIR_NOT_FOUND') {
return ctx.response.status(error.status).send({
message: error.message,
code: error.code,
})
}
return super.handle(error, ctx)
}
@@ -0,0 +1,55 @@
import ApiException from '#exceptions/api_exception'
export class PageNotFoundException extends ApiException {
static status = 404
static code = 'E_PAGE_NOT_FOUND'
constructor(resource: string = 'Page') {
super(`${resource} not found`)
}
}
export class PageRouteConflictException extends ApiException {
static status = 409
static code = 'E_PAGE_ROUTE_CONFLICT'
constructor(locale: string, path: string) {
super(`A page already uses /${locale}/${path}`)
}
}
export class PageNotPublishedException extends ApiException {
static status = 409
static code = 'E_PAGE_NOT_PUBLISHED'
constructor() {
super('Only a published page can be unpublished')
}
}
export class InvalidPagePayloadException extends ApiException {
static status = 422
static code = 'E_INVALID_PAGE_PAYLOAD'
constructor(message: string = 'Invalid page payload') {
super(message)
}
}
export class PageMediaFileMissingException extends ApiException {
static status = 422
static code = 'E_PAGE_MEDIA_FILE_MISSING'
constructor(fileKey: string) {
super(`Missing uploaded file for key "${fileKey}"`)
}
}
export class PageMediaFileInvalidException extends ApiException {
static status = 422
static code = 'E_PAGE_MEDIA_FILE_INVALID'
constructor(fileKey: string, message?: string) {
super(message || `Invalid uploaded file for key "${fileKey}"`)
}
}