1.0.7 • Published 7 months ago

@hedhog/core v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

@hedhog/core

A lightweight and robust library for managing database entities and relationships in TypeScript. The Hedhog Core simplifies defining database columns, foreign keys, timestamps, and decorators while maintaining clean and maintainable code.


🌟 Features

  • TypeScript First: Built for TypeScript with robust type definitions.
  • NestJS Integration: Seamlessly integrates with NestJS for decorator and pipe support.
  • Database Schema Utilities: Simplify ORM tasks with utilities for common schema definitions like primary keys, foreign keys, and timestamps.
  • DTO Support: Predefined DTOs for consistent data validation.
  • Localization Helper: Easy-to-use functions for managing translations.
  • Modular Design: Import only what you need to keep your application lightweight.

🚀 Getting Started

Installation

Install the package via npm:

npm install @hedhog/core

Or using yarn:

yarn add @hedhog/core

📚 Usage

Example: Using Decorators

import { Public, Role, User } from '@hedhog/core';

@Controller('example')
export class ExampleController {
  @Public()
  @Get('public')
  getPublicData() {
    return { message: 'This route is public!' };
  }

  @Role()
  @Get('private')
  getPrivateData(@User() user: any) {
    return { message: `Hello ${user.name}, this route is private!` };
  }
}

Example: Database Column Utilities

import { idColumn, foreignColumn, timestampColumn } from '@hedhog/core';

const id = idColumn();
const foreignKey = foreignColumn({ name: 'userId' });
const timestamp = timestampColumn('createdAt');

console.log(id, foreignKey, timestamp);

📦 Package Details

  • Name: @hedhog/core
  • Version: 1.0.4
  • Author: Hcodebr
  • License: MIT
  • Repository: GitHub
  • Dependencies:
    • class-validator
    • @nestjs/common
    • typeorm

🛠 Development

Build

Run the following command to build the package:

npm run build

Publish

To publish the package to npm:

npm run prod

🐛 Issues

Have a bug or a feature request? Please check the issues page or open a new issue.


❤️ Contributing

Contributions are welcome! Please see the contributing guide for more details.


📄 License

This project is licensed under the MIT License. See the LICENSE file for details.