https://github.com/lostovayne/high-performance-api
Experience the power of lightning-fast search with our cutting-edge API, built on a robust foundation of Hono,Nextjs, and Cloudflare.
https://github.com/lostovayne/high-performance-api
bun cloudflare hono next15 reddis
Last synced: 3 months ago
JSON representation
Experience the power of lightning-fast search with our cutting-edge API, built on a robust foundation of Hono,Nextjs, and Cloudflare.
- Host: GitHub
- URL: https://github.com/lostovayne/high-performance-api
- Owner: Lostovayne
- Created: 2024-11-07T21:06:02.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-02-06T19:37:40.000Z (5 months ago)
- Last Synced: 2025-03-25T08:42:32.686Z (3 months ago)
- Topics: bun, cloudflare, hono, next15, reddis
- Language: TypeScript
- Homepage: https://fast-api-khalest.vercel.app
- Size: 351 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FAST API
![]()
![]()
![]()
FAST API is a complete and efficient API built with modern technologies such as Cloudflare, Hono, Bun, TypeScript, Tailwind, and Redis. This project is designed to be fast, scalable, and easy to use.
## Technologies Used
- **Cloudflare**: Provides security and performance through its content delivery network (CDN).
- **Hono**: A lightweight and fast web framework for building applications in TypeScript.
- **Bun**: A JavaScript and TypeScript runtime that offers superior performance.
- **TypeScript**: A superset of JavaScript that adds static typing.
- **Tailwind CSS**: A utility-first CSS framework that allows for rapid and responsive design.
- **Redis**: An in-memory database used for caching and session management.## Installation
Follow these steps to install and set up the project on your local machine:
1. **Clone the repository**:
```bash
git clone https://github.com/yourusername/fast-api.git
cd fast-api
```2. **Install Bun** (if not already installed):
```bash
curl -fsSL https://bun.sh/install | bash
```3. **Install dependencies**:
```bash
bun install
```4. **Configure Redis**:
- Ensure Redis is installed and running. You can install it using Docker:
```bash
docker run --name redis -d -p 6379:6379 redis
```5. **Set up environment variables**:
- Create a `.env` file in the root of the project and add the following variables:
```env
REDIS_URL=redis://localhost:6379
```## Dependencies
Ensure the following dependencies are included in your `package.json`:
```json
{
"dependencies": {
"hono": "^3.0.0",
"redis": "^4.0.0",
"tailwindcss": "^2.0.0"
},
"devDependencies": {
"typescript": "^4.0.0",
"bun-types": "^0.1.0"
}
}
```## Integrations
### Cloudflare
To use Cloudflare, follow these steps:
1. Sign up at [Cloudflare](https://www.cloudflare.com/).
2. Add your domain and configure the DNS records.
3. Set up firewall rules and performance settings as needed.### Hono
To create routes in Hono, you can use the following example:
```typescript
import { Hono } from 'hono';const app = new Hono();
app.get('/', (c) => c.text('Hello, FAST API!'));
app.listen(3000);
```### Redis
To interact with Redis, you can use the following code:
```typescript
import { createClient } from 'redis';const client = createClient();
client.on('error', (err) => console.log('Redis Client Error', err));
async function connectRedis() {
await client.connect();
}connectRedis();
```## Styles with Tailwind CSS
To set up Tailwind CSS, follow these steps:
1. Create a Tailwind configuration file:
```bash
npx tailwindcss init
```2. Configure your `tailwind.config.js` file:
```javascript
module.exports = {
content: ['./src/**/*.{html,js,ts}'],
theme: {
extend: {},
},
plugins: [],
};
```3. Import Tailwind in your CSS file:
```css
@tailwind base;
@tailwind components;
@tailwind utilities;
```## Running the API
To run the API, use the following command:
```bash
bun run start
```## Deploy in Cloudflare
To deploy the API on Cloudflare, use the following command:
```bash
bun add -D @opennextjs/cloudflare
```Create the `wrangler.toml` file:
```toml
compatibility_date = "2024-11-08"
name = "fastapi"[vars]
UPSTASH_REDIS_REST_TOKEN = ".................."
UPSTASH_REDIS_REST_URL = "................"# wrangler.toml (wrangler v3.79.0^)
[observability]
enabled = true
head_sampling_rate = 1
```## Contributing
Contributions are welcome. If you would like to contribute, please follow these steps:
1. Fork the repository.
2. Create a new branch (`git checkout -b feature/new-feature`).
3. Make your changes and commit (`git commit -m 'Add new feature'`).
4. Push to the branch.## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## Contact
For more information, you can contact me at [[email protected]](mailto:[email protected]).