RAVEN is a shared library of TypeScript Data Transfer Objects (DTOs) designed for use in Boom Games' Node.js repositories. This library ensures consistency, reusability, and type safety across projects, enhancing code quality and maintainability.
To maintain uniformity and clarity in our codebase, please adhere to the following naming conventions:
-
Use Typebox to create schemas and generate types.
-
All type definitions should start with a capital "T", while file names should start with a lowercase "t". Example:
tHomeResponse.ts
, Exported Type:export type THomeResponse
-
All Typebox schemas should start with a capital "S". Schemas will reside within the type files and will not have separate files. Example:
// tHomeResponse.ts
export const SRouteResponse = <T extends TSchema>(T: T) =>
Type.Object({
status: Type.Number(),
message: Type.Optional(Type.String()),
data: Type.Optional(T),
});
export type TRouteResponse<T extends TSchema> = Static<
ReturnType<typeof SRouteResponse<T>>
>;
- All enums should start with a capital "E", while file names should start with a lowercase "e". Example:
// eHttpMethod.ts
export enum EHttpMethod {
GET = 'GET',
POST = 'POST',
PUT = 'PUT',
PATCH = 'PATCH',
DELETE = 'DELETE',
}
-
Create Your DTO: Develop your DTO in the appropriate folder corresponding to its function.
-
Update the Index File: If the DTO file is new, reference it in the corresponding folder's
index.ts
file.
// index.ts
export * from './tHomeResponse';
-
Top-Level Index Update: If you created a new folder, add the reference in the top-level
index.ts
file.
export * from './response/index';
-
Version Increment: Update the version number in the
package.json
file according to semantic versioning practices. -
Generate Build: Run
npm run build
to generate dist files. -
Publish the Package: Run
npm publish --access public
to publish your changes. If you are not logged in, you need to runnpm adduser
and login with usernamervboomgames
. -
Install or Update the Package: In relevant repositories, install or update the package to reflect your changes.
npm i @rvboomgames/raven
or
npm u @rvboomgames/raven