metamigo-common: build, fmt, lint
This commit is contained in:
parent
2a1ced5383
commit
75fb3f84c4
21 changed files with 95 additions and 156 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/* eslint-disable @typescript-eslint/ban-types,@typescript-eslint/no-explicit-any,max-params */
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any,max-params */
|
||||
import * as Boom from "@hapi/boom";
|
||||
import * as Hapi from "@hapi/hapi";
|
||||
import { CrudRepository } from "../records/crud-repository";
|
||||
|
|
@ -33,12 +33,8 @@ export abstract class AbstractCrudController<
|
|||
*/
|
||||
|
||||
abstract repoName: string;
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
abstract paramsIdField = "id";
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
abstract dbDecoration = "db";
|
||||
abstract paramsIdField;
|
||||
abstract dbDecoration;
|
||||
abstract recordType: PgRecordInfo<TUnsavedR, TSavedR, IdKeyT>;
|
||||
|
||||
repo(request: Hapi.Request): CrudRepository<TUnsavedR, TSavedR, IdKeyT> {
|
||||
|
|
@ -206,7 +202,6 @@ export abstract class AbstractCrudController<
|
|||
};
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
export function unboundCrudController<TRecordInfo extends PgRecordInfo>(
|
||||
aRecordType: TRecordInfo
|
||||
) {
|
||||
|
|
@ -229,7 +224,6 @@ export function unboundCrudController<TRecordInfo extends PgRecordInfo>(
|
|||
};
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
export function CrudControllerBase<Rec extends PgRecordInfo>(recordType: Rec) {
|
||||
return unboundCrudController<Rec>(recordType);
|
||||
}
|
||||
|
|
@ -241,53 +235,53 @@ export const crudRoutesFor = (
|
|||
idParam: string,
|
||||
validate: Record<string, Hapi.RouteOptionsValidate>
|
||||
): Hapi.ServerRoute[] => [
|
||||
{
|
||||
method: "POST",
|
||||
path: `${path}`,
|
||||
options: {
|
||||
handler: controller.create,
|
||||
validate: validate.create,
|
||||
description: `Method that creates a new ${name}.`,
|
||||
tags: ["api", name],
|
||||
},
|
||||
{
|
||||
method: "POST",
|
||||
path: `${path}`,
|
||||
options: {
|
||||
handler: controller.create,
|
||||
validate: validate.create,
|
||||
description: `Method that creates a new ${name}.`,
|
||||
tags: ["api", name],
|
||||
},
|
||||
{
|
||||
method: "PUT",
|
||||
path: `${path}/{${idParam}}`,
|
||||
options: {
|
||||
handler: controller.updateById,
|
||||
validate: validate.updateById,
|
||||
description: `Method that updates a ${name} by its id.`,
|
||||
tags: ["api", name],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: "PUT",
|
||||
path: `${path}/{${idParam}}`,
|
||||
options: {
|
||||
handler: controller.updateById,
|
||||
validate: validate.updateById,
|
||||
description: `Method that updates a ${name} by its id.`,
|
||||
tags: ["api", name],
|
||||
},
|
||||
{
|
||||
method: "GET",
|
||||
path: `${path}/{${idParam}}`,
|
||||
options: {
|
||||
handler: controller.getById,
|
||||
validate: validate.getById,
|
||||
description: `Method that gets a ${name} by its id.`,
|
||||
tags: ["api", name],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: "GET",
|
||||
path: `${path}/{${idParam}}`,
|
||||
options: {
|
||||
handler: controller.getById,
|
||||
validate: validate.getById,
|
||||
description: `Method that gets a ${name} by its id.`,
|
||||
tags: ["api", name],
|
||||
},
|
||||
{
|
||||
method: "GET",
|
||||
path: `${path}`,
|
||||
options: {
|
||||
handler: controller.getAll,
|
||||
description: `Method that gets all ${name}s.`,
|
||||
tags: ["api", name],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: "GET",
|
||||
path: `${path}`,
|
||||
options: {
|
||||
handler: controller.getAll,
|
||||
description: `Method that gets all ${name}s.`,
|
||||
tags: ["api", name],
|
||||
},
|
||||
{
|
||||
method: "DELETE",
|
||||
path: `${path}/{${idParam}}`,
|
||||
options: {
|
||||
handler: controller.deleteById,
|
||||
validate: validate.deleteById,
|
||||
description: `Method that deletes a ${name} by its id.`,
|
||||
tags: ["api", name],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: "DELETE",
|
||||
path: `${path}/{${idParam}}`,
|
||||
options: {
|
||||
handler: controller.deleteById,
|
||||
validate: validate.deleteById,
|
||||
description: `Method that deletes a ${name} by its id.`,
|
||||
tags: ["api", name],
|
||||
},
|
||||
];
|
||||
},
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue