Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/DISCUSSION_TEMPLATE.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
title: "[DISCUSSION] "
labels: ["discussion"]
body:
- type: markdown
attributes:
value: |
## Discussion Guidelines
- Be respectful
- Stay on topic
- Reference existing issues
- type: textarea
attributes:
label: "Discussion Topic"
description: "What would you like to discuss?"
54 changes: 54 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Bug Report
description: File a bug report
labels: ["bug", "triage"]
projects: ["hono-routing-controller"]
assignees:
- hasib-devs
body:
- type: textarea
id: what-happened
attributes:
label: Bug Description
description: In a few sentences or paragraphs, describe the bug in detail. Include information such as what the bug does, what was expected, steps to reproduce the bug, any error messages, and the impact of the bug on the application.
validations:
required: true
- type: textarea
id: logs
attributes:
label: Step To Reproduce
description: List step-by-step instructions to reproduce the bug. This helps the assigned team member understand and replicate the issue.
value: |
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
- type: textarea
id: logs2
attributes:
label: Expected Behaviour
description: Describe what you expected to happen when performing the steps listed above.
validations:
required: true
- type: textarea
id: logs3
attributes:
label: Actual Behaviour
description: Describe what actually happened when performing the steps, highlighting the bug's behavior.
validations:
required: true
- type: textarea
id: logs4
attributes:
label: Additional Information or Expected Working Example
description: Include any other relevant information or expected example, any images or videos, such as related issues, links to documentation, or any workarounds if they exist.
- type: dropdown
id: browsers
attributes:
label: What browsers are you seeing the problem on?
multiple: true
options:
- Firefox
- Chrome
- Brave
- Safari
- Microsoft Edge
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: weekly
time: "10:00"
timezone: "Asia/Dhaka"
open-pull-requests-limit: 5
versioning-strategy: increase
commit-message:
prefix: "chore(deps)"
18 changes: 18 additions & 0 deletions .github/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
titleAndCommits: true
allowMergeCommits: false
scopes:
- deps
- deps-dev
types:
- feat
- fix
- docs
- style
- refactor
- perf
- test
- build
- ci
- chore
- revert
- merge
18 changes: 18 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CodeQL
on: [pull_request]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: typescript

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@hasib-devs:registry=https://registry.npmjs.org
registry=https://registry.npmjs.org
59 changes: 59 additions & 0 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Hono Routing Controller - Architecture

## 📌 Overview
This package provides a **NestJS-like controller architecture** for the [Hono](https://hono.dev/) framework. It enables **decorator-based routing, middleware support, and dependency injection**, making it easier to organize and manage routes in Hono.

---

## 🏗️ Design Principles
- **Decorator-Based Routing** → Define routes using class decorators.
- **Middleware Integration** → Use middleware with controllers.
- **Dependency Injection (DI)** → Inject dependencies into controllers.
- **TypeScript First** → Fully typed API with TypeScript.
- **Lightweight & Fast** → Minimal runtime overhead.

---

## 📂 Directory Structure

```
hono-routing-controller/
│── src/
│ ├── decorators/ # Custom decorators for routes and middleware
│ │ ├── Controller.ts
│ │ ├── HttpMethods.ts
│ │
│ ├── core/ # Core logic for routing and DI
│ │ ├── DIContainer.ts
| |
│ ├── types/ # Type definitions
│ │ ├── index.ts
│ │
│ ├── constants.ts # Constants used in the package
│ ├── index.ts # Entry point for package exports
├── tests/ # Unit and integration tests
├── package.json
├── tsup.config.ts
└── tsconfig.json
```
---

## 🛠️ Components

### **1️⃣ Decorators**
These are used to define controllers, routes, and middleware.

- `@Controller(path: string)`: Defines a controller with a base path.
- `@Get(path: string)`: Defines a `GET` route.
- `@Post(path: string)`: Defines a `POST` route.
- `@Middleware(middlewareFn)`: Attaches middleware to a route.

## 🚀 How It Works
1. Define Controllers & Routes → Use decorators.
2. Register Controllers → The package scans and registers controllers.
3. Handle Requests → Routes are automatically wired in Hono.
4. Use Dependency Injection → Inject services into controllers.

## 🙌 Contributing
We welcome contributions! Please check the CONTRIBUTING.md for guidelines.
137 changes: 137 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Contributing to hono-routing-controller

We are excited that you're interested in contributing to the `hono-routing-controller` project! This guide will help you get started with contributing to the project. Whether you're submitting a bug fix, a new feature, or an improvement, we appreciate your help!

## Table of Contents

- [How to Contribute](#how-to-contribute)
- [Code of Conduct](#code-of-conduct)
- [Issue Reporting](#issue-reporting)
- [Pull Request Process](#pull-request-process)
- [Development Setup](#development-setup)

## How to Contribute

We welcome contributions from the community! To contribute, follow these steps:

1. **Fork the Repository**

First, fork the repository by clicking the "Fork" button at the top right of the repo page.

2. **Clone Your Fork**

Clone your fork to your local machine:
```bash
git clone https://github.com/hasib-devs/hono-routing-controller.git
cd hono-routing-controller
```
3. **Create a New Branch**

Always create a new branch for your feature or fix:
```
git checkout -b feat/your-feature-name
```

always use semantic branch name.
- feat
- fix
- docs
- style
- refactor
- perf
- test
- build
- ci
- chore
- revert
- merge

4. **Commit Your Changes**

Write clear and concise commit messages:
```bash
git commit -m "Add feature/bugfix description"
```
5. **Push to Your Fork**

Push your changes to your fork:
```bash
git push origin feature/your-feature-name
```

6. **Create a Pull Request**

After pushing your changes, go to the original repository and create a pull request (PR) from your fork.

## Code of Conduct
We follow a Code of Conduct in this project. By participating, you are expected to honor the code of conduct and engage with the community respectfully.

## Issue Reporting
If you encounter a bug or have an idea for a new feature, feel free to open an issue. Please include:

A clear description of the problem or feature request.
Steps to reproduce the issue, if applicable.
Any relevant log or error messages.
Information about your environment (e.g., Node.js version, operating system).

## Pull Request Process
We use the following steps for accepting pull requests:

1. **Ensure Tests Pass**

All tests must pass before we can merge your PR.

2. **Code Review**

Once you submit your PR, a maintainer will review it and may suggest changes.

3. **Merge**

Once your PR is approved, it will be merged into the main branch.

**Please ensure your PR follows these guidelines:**

- Write clear and concise commit messages.
- Keep the changes focused on a single issue or feature.
- If adding new features, consider writing tests to cover them.
- Ensure that existing functionality and tests remain unaffected.

## Development Setup
To set up your local environment for development:

1. **Clone the Repository**

```bash
git clone https://github.com/hasib-devs/hono-routing-controller.git
```

2. **Install Dependencies**

Install the required dependencies:
```bash
pnpm install
```

3. **Start Development**

To run the application locally during development:
```bash
pnpm dev
```

4. **Build**

To create a production build of the application:
```bash
pnpm build
```

5. **Run Tests**

To run the test suite and ensure everything is working:
```bash
pnpm test
```
___
Thanks for your contributions to the hono-routing-controller project!
___
62 changes: 62 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import tsEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import globals from 'globals';

export default [
{
files: ['**/*.ts'],
languageOptions: {
sourceType: 'module',
parser: tsParser,
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname
},
globals: {
...globals.node,
...globals.es2022
}
},
plugins: {
'@typescript-eslint': tsEslint
},
rules: {
// TypeScript rules
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',

// Base ESLint rules
'no-console': 'warn',
'no-debugger': 'error',
'eqeqeq': ['error', 'always'],
'curly': 'error',
'arrow-body-style': ['error', 'as-needed'],

// New ESLint 9.x rules
'no-constant-binary-expression': 'error',
'prefer-object-has-own': 'error',
'logical-assignment-operators': 'error'
},
settings: {
'import/resolver': {
typescript: {}
}
}
},
{
ignores: [
'**/node_modules/',
'dist/',
'tests/',
'coverage/',
'*.d.ts',
'*.config.js',
'*.config.ts',
'*.config.mjs',
]
}
];
Loading
Loading