errors, results or more for galatajs framework and you.
It contains some core packages for the galatajs framework to work in certain standards. Although it was developed for the galatajs framework, you can use it if you want.
You don't have to use galatajs framework, @galatajs/core is a nodejs package.
npm install @galatajs/coreor with yarn
yarn add @galatajs/core
import { SuccessDataResult } from "@galatajs/core";
export type Product = {
id: number;
name: string;
price: number;
}
const product : Product = {
id: 1,
name: "Product 1",
price: 10
}
const result = new SuccessDataResult<Product>("Product created successfully", product);
console.log(result);
/**
success: true,
message: "Product created successfully",
data: { id: 1, name: "Product 1", price: 10 }
* */import {BadRequestError} from "@galatajs/core";
const error = new BadRequestError("Product name is required");
console.log(error);
/**
success: false,
message: "Product name is required",
code: 400
* */When the framework is completed, the document will be made more detailed.