-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
6321525
commit 6bb1ecd
Showing
63 changed files
with
1,186 additions
and
1,571 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
``` | ||
npm install | ||
npm run dev | ||
``` | ||
|
||
``` | ||
npm run deploy | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import rootConfig from '../../eslint.config.js'; | ||
|
||
export default [...rootConfig]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.