Skip to content

Instantly share code, notes, and snippets.

View GabrielL915's full-sized avatar
🐢
Estilo Kame

Gabriel Luiz Bruneli GabrielL915

🐢
Estilo Kame
  • Maringá
  • 21:14 (UTC -12:00)
View GitHub Profile
@GabrielL915
GabrielL915 / express-example.ts
Last active January 10, 2025 19:00
zod and generics
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) => {
@GabrielL915
GabrielL915 / repository.ts
Last active September 13, 2024 01:02
Respository interface
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>;
}
@GabrielL915
GabrielL915 / CRUDController.java
Last active September 11, 2024 20:01
Abstraction Java
@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) {