# <p align="center">@hedhog/core</p>

<p align="center">
  <img src="https://avatars.githubusercontent.com/u/177489127?s=200&v=4" alt="Hedhog Avatar" />
</p>

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:

```bash
npm install @hedhog/core
```

Or using yarn:

```bash
yarn add @hedhog/core
```

---

## 📚 Usage

### Example: Using Decorators

```typescript
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

```typescript
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](https://github.com/hcodebr)
- **License**: MIT
- **Repository**: [GitHub](https://github.com/hed-hog/core)
- **Dependencies**:
  - `class-validator`
  - `@nestjs/common`
  - `typeorm`

---

## 🛠 Development

### Build

Run the following command to build the package:

```bash
npm run build
```

### Publish

To publish the package to npm:

```bash
npm run prod
```

---

## 🐛 Issues

Have a bug or a feature request? Please check the [issues page](https://github.com/hed-hog/core/issues) or [open a new issue](https://github.com/hed-hog/core/issues/new).

---

## ❤️ Contributing

Contributions are welcome! Please see the [contributing guide](https://github.com/hed-hog/core/blob/main/CONTRIBUTING.md) for more details.

---

## 📄 License

This project is licensed under the MIT License. See the [LICENSE](https://github.com/hed-hog/core/blob/main/LICENSE) file for details.

---
