Skip to content

Commit

Permalink
Change from Astroflare to Flarekit
Browse files Browse the repository at this point in the history
Update the database package structure as I was not happy with the previous implementation. A singleton instance should be created for database init along with context of cache, queue if needs to be used for caching purpose. Thus to avoid complexity of the future we have updated the code for @flarekit/database

Change cloudflare worker to Hapi worker handling the queue, schedule and api request. Change the gallery function. However this is not yet fully functional, rewamp is needed for Astro.
  • Loading branch information
tirthbodawala committed Jan 2, 2025
1 parent 6321525 commit 6bb1ecd
Show file tree
Hide file tree
Showing 63 changed files with 1,186 additions and 1,571 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ jobs:
run: npm run setup

- name: Run Setup
run: npm run build --workspace=@services/database
run: npm run build --workspace=@flarekit/database

- name: Deploy to Cloudflare Workers
uses: cloudflare/wrangler-action@v3
Expand Down
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"coverage-gutters.coverageFilePaths": ["./coverage/lcov.info"],
"coverage-gutters.coverageFileNames": [
"clover.xml",
"lcov.info",
"coverage.xml",
"cov.xml"
],
"coverage-gutters.showGutterCoverage": true,
"editor.formatOnSave": true,
"eslint.validate": [
Expand Down
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<p align="center">
<img src="https://cdn.atyantik.com/Astroflare.webp" alt="Astroflare" width="200" style="border-radius: 20px;"
<img src="https://cdn.atyantik.com/Flarekit.webp" alt="Flarekit" width="200" style="border-radius: 20px;"
>
</p>
# **Astroflare**
# **Flarekit**

Astroflare is a scalable and modular monorepo ecosystem for building modern, edge-first web applications using **Astro** and **Cloudflare Workers**. It’s designed to simplify the development of performant, globally distributed applications while promoting code reusability and maintainability.
Flarekit is a scalable and modular monorepo ecosystem for building modern, edge-first web applications using **Astro** and **Cloudflare Workers**. It’s designed to simplify the development of performant, globally distributed applications while promoting code reusability and maintainability.

This project is supported and sponsored by [Atyantik Technologies](https://atyantik.com/). 🚀

Expand Down Expand Up @@ -37,17 +37,17 @@ This project is supported and sponsored by [Atyantik Technologies](https://atyan

## **Current Structure**

Astroflare is currently focused on providing:
Flarekit is currently focused on providing:

- A **web application** built with Astro.
- A basic structure for future apps and services.

### **Directory Layout**

```
astroflare/
flarekit/
├── apps/
│ └── web/ # Astro-based frontend (@apps/web)
│ └── web/ # Astro-based frontend (@flarekit/web)
├── packages/
│ └── db/ # Database schema and utilities (@services/db)
├── turbo.json # Turborepo configuration
Expand All @@ -57,19 +57,19 @@ astroflare/

### **Available Packages**

| Package | Description |
| -------------- | ---------------------------------------------- |
| `@apps/web` | The primary web frontend built with Astro. |
| `@services/db` | Database utilities and schema for the project. |
| Package | Description |
| --------------- | ---------------------------------------------- |
| `@flarekit/web` | The primary web frontend built with Astro. |
| `@services/db` | Database utilities and schema for the project. |

---

## **Future Scope**

Astroflare is designed with extensibility in mind. Future plans include:
Flarekit is designed with extensibility in mind. Future plans include:

- **New Applications**:
- `@apps/api`: Cloudflare Worker-based API services.
- `@flarekit/api`: Cloudflare Worker-based API services.
- **Reusable Services**:
- `@services/auth`: Authentication utilities and middleware.
- `@services/utils`: Shared utility functions for applications.
Expand All @@ -84,8 +84,8 @@ These features will be introduced incrementally, and contributions are welcome!
### **1. Clone the Repository**

```bash
git clone https://github.com/Atyantik/astroflare.git
cd astroflare
git clone https://github.com/Atyantik/flarekit.git
cd flarekit
```

### **2. Install Dependencies**
Expand Down Expand Up @@ -133,7 +133,7 @@ Each app or package may have its own configuration file. For example:

## **Contributing**

We’re building Astroflare to support modern, scalable web development. Contributions are welcome to help improve its features and extend its scope.
We’re building Flarekit to support modern, scalable web development. Contributions are welcome to help improve its features and extend its scope.

### **How to Contribute**

Expand All @@ -156,13 +156,13 @@ We’re building Astroflare to support modern, scalable web development. Contrib

## **License**

Astroflare is licensed under the [MIT License](LICENSE).
Flarekit is licensed under the [MIT License](LICENSE).

---

## **About Atyantik Technologies**

Astroflare is proudly supported and sponsored by **[Atyantik Technologies](https://atyantik.com)**, a leading software development company specializing in scalable web applications, cloud services, and cutting-edge technologies.
Flarekit is proudly supported and sponsored by **[Atyantik Technologies](https://atyantik.com)**, a leading software development company specializing in scalable web applications, cloud services, and cutting-edge technologies.

### **Contact Atyantik**

Expand All @@ -176,10 +176,10 @@ Astroflare is proudly supported and sponsored by **[Atyantik Technologies](https

---

Astroflare – Simplifying Edge-First Development with Cloudflare 🌍✨
Flarekit – Simplifying Edge-First Development with Cloudflare 🌍✨

---

### **Feedback and Support**

If you have suggestions or run into issues, please [open an issue](https://github.com/Atyantik/astroflare/issues) or contact us directly. We value your feedback and contributions!
If you have suggestions or run into issues, please [open an issue](https://github.com/Atyantik/flarekit/issues) or contact us directly. We value your feedback and contributions!
34 changes: 34 additions & 0 deletions apps/api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# prod
dist/

# dev
.yarn/
!.yarn/releases
.vscode/*
!.vscode/launch.json
!.vscode/*.code-snippets
.idea/workspace.xml
.idea/usage.statistics.xml
.idea/shelf

# deps
node_modules/
.wrangler

# env
.env
.env.production
.dev.vars
wrangler.json

# logs
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# misc
.DS_Store
8 changes: 8 additions & 0 deletions apps/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```
npm install
npm run dev
```

```
npm run deploy
```
3 changes: 3 additions & 0 deletions apps/api/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import rootConfig from '../../eslint.config.js';

export default [...rootConfig];
22 changes: 10 additions & 12 deletions apps/worker/package.json → apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
{
"name": "@apps/worker",
"version": "1.0.0",
"private": true,
"name": "@flarekit/api",
"scripts": {
"deploy": "npm run setup && wrangler deploy",
"dev": "npm run setup && wrangler dev --test-scheduled --persist-to=../../.wrangler/state",
"start": "npm run setup && wrangler dev",
"deploy": "npm run setup && wrangler deploy",
"test": "npm run setup && CI=true vitest run",
"setup": "node ../../scripts/generate-wrangler.json.js && wrangler types"
},
"dependencies": {
"@flarekit/database": "*",
"hono": "^4.6.15"
},
"devDependencies": {
"@cloudflare/vitest-pool-workers": "^0.5.2",
"@cloudflare/workers-types": "^4.20241224.0",
"typescript": "^5.5.2",
"vitest": "2.1.8",
"@cloudflare/vitest-pool-workers": "^0.5.40",
"@cloudflare/workers-types": "^4.20241230.0",
"typescript": "^5.7.2",
"vitest": "^2.1.8",
"wrangler": "^3.99.0"
},
"dependencies": {
"@services/database": "*"
}
}
46 changes: 46 additions & 0 deletions apps/api/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Handler, Hono } from 'hono';
// import { clearStorageRecords, getDBClient, listStorageRecords } from '@flarekit/database';

const app = new Hono<{ Bindings: Env }>();

const honoHomeRoute: Handler = (c) => {
return c.json({
message: 'Welcome to Hono!',
});
};
app.get('/', honoHomeRoute);

export default {
fetch: app.fetch,
/* istanbul ignore next: Cannot test Queue invocation */
// async queue( batch: MessageBatch, env: Environment, ctx: ExecutionContext)
async queue(batch): Promise<void> {
let messages = JSON.stringify(batch.messages);
console.log(`Consumed from our queue: ${messages}`);
batch.ackAll();
},

/* istanbul ignore next: Cannot test scheduled invocation */
// scheduled(event: ScheduledEvent, env: Environment, ctx: ExecutionContext)
async scheduled(event, env, ctx) {
// Pass a promise
ctx.waitUntil(
(async () => {
// Clear the storage every 5th minute
// if (event.cron.startsWith('*/5')) {
// const DB = await getDBClient(this, env.DB);
// const STORAGE = env.STORAGE;
// const CACHE = env.CACHE;
// // Get all storage Records
// const storageRecords = await listStorageRecords(DB);
// // Remove each storage record from
// for (const record of storageRecords) {
// await STORAGE.delete(record.key);
// }
// await clearStorageRecords(DB);
// await CACHE.delete('storage_records');
// }
})(),
);
},
} satisfies ExportedHandler<Env>;
15 changes: 15 additions & 0 deletions apps/api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"skipLibCheck": true,
"lib": ["ESNext"],
"types": ["@cloudflare/workers-types"],
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx"
},
"exclude": ["test"],
"include": ["worker-configuration.d.ts", "src/**/*.ts"]
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "../../node_modules/wrangler/config-schema.json",
"name": "astroflare-worker",
"name": "flarekit-backend",
"main": "src/index.ts",
"workers_dev": false,
"observability": {
Expand All @@ -13,15 +13,15 @@
"queues": {
"consumers": [
{
"queue": "astroflare-queue",
"queue": "flarekit-queue",
"max_batch_size": 10,
"max_batch_timeout": 5
}
]
},
"routes": [
{
"pattern": "astroflare-api.atyantik.com",
"pattern": "flarekit-api.atyantik.com",
"custom_domain": true
}
]
Expand Down
14 changes: 7 additions & 7 deletions apps/web/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# **Astroflare Web App**
# **Flarekit Web App**

This repository contains the **Astroflare Web App**, a high-performance, edge-first web application built with **Astro** and deployed on **Cloudflare Pages**. It includes serverless API routes, R2 integration, and D1 database management, making it an ideal choice for scalable web applications.
This repository contains the **Flarekit Web App**, a high-performance, edge-first web application built with **Astro** and deployed on **Cloudflare Pages**. It includes serverless API routes, R2 integration, and D1 database management, making it an ideal choice for scalable web applications.

---

Expand All @@ -18,7 +18,7 @@ This repository contains the **Astroflare Web App**, a high-performance, edge-fi

## **Overview**

The Astroflare Web App is part of the Astroflare ecosystem. This project leverages:
The Flarekit Web App is part of the Flarekit ecosystem. This project leverages:

- **Astro**: For creating fast, SEO-friendly frontends.
- **Cloudflare Pages**: For edge-first deployment and serverless APIs.
Expand All @@ -42,7 +42,7 @@ The Astroflare Web App is part of the Astroflare ecosystem. This project leverag
### **1. Clone the Repository**

```bash
git clone https://github.com/Atyantik/astroflare.git
git clone https://github.com/Atyantik/flarekit.git
cd apps/web
```

Expand Down Expand Up @@ -116,7 +116,7 @@ src/

## **Contributing**

We welcome contributions to improve Astroflare. Please follow these steps:
We welcome contributions to improve Flarekit. Please follow these steps:

1. Fork the repository.
2. Create a new branch:
Expand All @@ -137,7 +137,7 @@ We welcome contributions to improve Astroflare. Please follow these steps:

## **About Atyantik Technologies**

Astroflare is proudly supported and sponsored by **[Atyantik Technologies](https://atyantik.com)**, a leading software development company specializing in scalable web applications, cloud services, and cutting-edge technologies.
Flarekit is proudly supported and sponsored by **[Atyantik Technologies](https://atyantik.com)**, a leading software development company specializing in scalable web applications, cloud services, and cutting-edge technologies.

<p align="center">
<img src="https://cdn.atyantik.com/atyantik-logo.png" alt="Atyantik Technologies" width="200">
Expand All @@ -149,4 +149,4 @@ Astroflare is proudly supported and sponsored by **[Atyantik Technologies](https
- 💼 [LinkedIn](https://www.linkedin.com/company/atyantik-technologies/)
- 🐦 [Twitter](https://twitter.com/atyantik_tech)

Astroflare Web App – Simplifying Edge-First Development with Cloudflare 🌍✨
Flarekit Web App – Simplifying Edge-First Development with Cloudflare 🌍✨
2 changes: 1 addition & 1 deletion apps/web/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default defineConfig({
},
vite: {
optimizeDeps: {
include: ["@services/database"],
include: ["@flarekit/database"],
},
},
});
8 changes: 6 additions & 2 deletions apps/web/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import globals from "globals";
import eslintPluginAstro from "eslint-plugin-astro";
import astroParser from "astro-eslint-parser";
import tsParser from "@typescript-eslint/parser";
import rootConfig from "../../eslint.config.js";
import {
defaultRootConfig,
eslintConfigPrettier,
} from "../../eslint.config.js";

export default [
...rootConfig,
...defaultRootConfig,
{
settings: {
react: {
Expand Down Expand Up @@ -38,4 +41,5 @@ export default [
// add more generic rule sets here, such as:
// js.configs.recommended,
...eslintPluginAstro.configs.recommended,
eslintConfigPrettier,
];
Loading

0 comments on commit 6bb1ecd

Please sign in to comment.