This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import express from "npm:express@4.17.1"; | |
const app = express(); | |
const getEndpoint = | |
<Tquery>( | |
schema: z.Schema<Tquery>, | |
callback: (req: Request<any, any, any, Tquery>, res: Response) => void | |
) => | |
(req: Request, res: Response) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface Create<I, O> { | |
createOne(input: I): Promise<O>; | |
} | |
export interface Update<I, K extends keyof I, O> { | |
updateOne(key: I[K], input: I): Promise<O>; | |
} | |
export interface Delete<I, K extends keyof I, O> { | |
deleteOne(key: I[K]): Promise<O>; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
public abstract class CRUDController <Entity, ID, DTO> { | |
private static final String ID_PATH_VARIABLE = "/{id}"; | |
@Autowired | |
private CRUDService<Entity, ID, DTO> crudService; | |
@PostMapping | |
public ResponseEntity<DTO> create(@RequestBody @Valid DTO dto) { |