Skip to content

sherbolotarbaev/deno-hono

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ¦– Fastest API with Deno 2.0 & Hono.js

This project showcases a performant API built with Deno 2.0 and Hono.js. It includes message handling, caching, validation, and security features.

πŸš€ Features

  • Deno 2.0: A modern, fast JavaScript/TypeScript runtime.
  • Hono.js: Ultra-fast web framework for handling requests.
  • Message Caching: Uses a cache to store messages with timestamps.
  • Validation: Validates request body using Zod.
  • Security: Secure headers for enhanced API security.
  • CORS & Logging: CORS and request logging are enabled for better API handling.

πŸ› οΈ Installation

  1. Install Deno (if not already installed):

    deno --version
  2. Clone the repository:

    git clone https://github.com/sherbolotarbaev/deno-hono.git
    cd deno-hono
  3. Run the API:

    deno task dev

    The server will start on http://localhost:999.

πŸ“š API Endpoints

  • GET /messages: Fetch all cached messages.

    Example:

    curl http://localhost:999/messages
  • POST /messages: Add a new message to the cache. Expects a JSON body:

    {
      "message": "Your message here"
    }

    Example:

    curl -X POST http://localhost:999/messages \
    -H "Content-Type: application/json" \
    -d '{"message": "Hello World"}'

πŸ“¦ Message Caching

Messages are cached daily, using a date-based key format. Cached messages can be fetched via GET /messages or added via POST /messages.

πŸ” Security

The API is secured with:

  • CORS: Allows cross-origin requests.
  • Secure Headers: Provides protection against common web vulnerabilities.

πŸ§‘β€πŸ’» Development

  • To lint or format your code, use Deno's built-in tools:

    deno lint
    deno fmt

🀝 Contributing

Contributions are welcome! Please submit issues or pull requests.

About

πŸ¦– Fastest API build with Deno 2.0 & Hono.js

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published