An open API service indexing awesome lists of open source software.

https://github.com/anthonyrovira/portfolio_backend

A modern, secure, and scalable backend API built with Hono.js, TypeScript, and Firebase.
https://github.com/anthonyrovira/portfolio_backend

firebase honojs nodejs resend-email software-craftsmanship typescript zod-validation

Last synced: 7 months ago
JSON representation

A modern, secure, and scalable backend API built with Hono.js, TypeScript, and Firebase.

Awesome Lists containing this project

README

          

# Anthony Rovira - Portfolio Backend

A modern, secure, and scalable backend API built with Hono.js, TypeScript, and Firebase.

## Features

- ๐Ÿ”’ Secure API endpoints with rate limiting
- ๐Ÿ“ง Email notifications using Resend
- ๐Ÿ’พ Firebase Firestore database
- ๐Ÿš€ TypeScript for type safety
- ๐Ÿ›ก๏ธ Security headers and CORS protection
- ๐Ÿ“ Input validation with Zod
- ๐Ÿงน Clean Architecture principles

## Prerequisites

- Node.js (v18 or higher)
- pnpm
- Firebase project
- Resend account
- Upstash Redis account

## Environment Variables

Create a `.env` file in the root directory with the following variables:

```env
# API Security
API_SECRET=your_secure_secret_here

# Firebase Configuration
FIREBASE_API_KEY=your_firebase_api_key
FIREBASE_AUTH_DOMAIN=your_firebase_auth_domain
FIREBASE_PROJECT_ID=your_firebase_project_id
FIREBASE_STORAGE_BUCKET=your_firebase_storage_bucket
FIREBASE_MESSAGING_SENDER_ID=your_firebase_messaging_sender_id
FIREBASE_APP_ID=your_firebase_app_id
FIREBASE_MEASUREMENT_ID=your_firebase_measurement_id

# Email Configuration (Resend)
RESEND_API_KEY=your_resend_api_key
RESEND_FROM_EMAIL=your_verified_email@domain.com

# Redis Configuration (Upstash)
UPSTASH_REDIS_REST_URL=your_redis_url
UPSTASH_REDIS_REST_TOKEN=your_redis_token

# CORS Configuration
ALLOWED_ORIGIN=http://localhost:3000
```

## Installation

1. Clone the repository:

```bash
git clone https://github.com/yourusername/anthonyrovira_backend.git
cd anthonyrovira_backend
```

2. Install dependencies:

```bash
pnpm install
```

3. Start the development server:

```bash
pnpm run dev
```

The server will start on `http://localhost:3000`

## API Endpoints

### Contact Form

- `POST /api/messages`
- Rate limited: 5 requests per hour
- Validates input data
- Sends email notification
- Stores message in Firebase

### Admin

- `GET /api/messages`
- Retrieves all messages (protected)

## Project Structure

```
src/
โ”œโ”€โ”€ config/ # Configuration files
โ”œโ”€โ”€ features/ # Feature modules
โ”‚ โ””โ”€โ”€ messages/ # Message feature
โ”œโ”€โ”€ shared/ # Shared utilities
โ”‚ โ”œโ”€โ”€ middleware/ # Custom middleware
โ”‚ โ””โ”€โ”€ errors/ # Error handling
โ””โ”€โ”€ index.ts # Application entry point
```

## Security Features

- Rate limiting on API endpoints
- Security headers (XSS, CSRF, etc.)
- CORS protection
- Input validation
- Error handling
- Type safety with TypeScript

## Development

The project uses:

- TypeScript for type safety
- ESLint for code linting
- Prettier for code formatting
- Hono.js for the web framework

## License

MIT