create-katajs 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +59 -0
- package/dist/index.js +568 -0
- package/dist/templates/api/.github/workflows/deploy.yml +26 -0
- package/dist/templates/api/README.md +95 -0
- package/dist/templates/api/_dev.vars.example +3 -0
- package/dist/templates/api/_gitignore +11 -0
- package/dist/templates/api/drizzle.config.ts +10 -0
- package/dist/templates/api/package.json +32 -0
- package/dist/templates/api/scripts/graph.ts +19 -0
- package/dist/templates/api/scripts/modules.ts +7 -0
- package/dist/templates/api/src/app.ts +39 -0
- package/dist/templates/api/src/db/schema.ts +11 -0
- package/dist/templates/api/src/index.ts +6 -0
- package/dist/templates/api/src/modules/posts/index.ts +31 -0
- package/dist/templates/api/src/modules/posts/posts.errors.ts +15 -0
- package/dist/templates/api/src/modules/posts/posts.repository.ts +22 -0
- package/dist/templates/api/src/modules/posts/posts.routes.ts +20 -0
- package/dist/templates/api/src/modules/posts/posts.schema.ts +12 -0
- package/dist/templates/api/src/modules/posts/posts.service.ts +26 -0
- package/dist/templates/api/src/types.d.ts +31 -0
- package/dist/templates/api/tsconfig.json +22 -0
- package/dist/templates/api/wrangler.jsonc +35 -0
- package/dist/templates/auth-snippets/api/src/db/auth-schema.ts +53 -0
- package/dist/templates/auth-snippets/api/src/modules/auth/auth.config.ts +30 -0
- package/dist/templates/auth-snippets/api/src/modules/auth/auth.errors.ts +10 -0
- package/dist/templates/auth-snippets/api/src/modules/auth/auth.middleware.ts +37 -0
- package/dist/templates/auth-snippets/api/src/modules/auth/auth.routes.ts +7 -0
- package/dist/templates/auth-snippets/api/src/modules/auth/index.ts +28 -0
- package/dist/templates/auth-snippets/monorepo/apps/api/src/modules/auth/auth.errors.ts +10 -0
- package/dist/templates/auth-snippets/monorepo/apps/api/src/modules/auth/auth.middleware.ts +37 -0
- package/dist/templates/auth-snippets/monorepo/apps/api/src/modules/auth/auth.routes.ts +7 -0
- package/dist/templates/auth-snippets/monorepo/apps/api/src/modules/auth/index.ts +29 -0
- package/dist/templates/auth-snippets/monorepo/packages/auth/package.json +22 -0
- package/dist/templates/auth-snippets/monorepo/packages/auth/src/auth.ts +40 -0
- package/dist/templates/auth-snippets/monorepo/packages/auth/src/index.ts +2 -0
- package/dist/templates/auth-snippets/monorepo/packages/auth/tsconfig.json +4 -0
- package/dist/templates/auth-snippets/monorepo/packages/db/src/auth-schema.ts +53 -0
- package/dist/templates/monorepo/.github/workflows/deploy.yml +39 -0
- package/dist/templates/monorepo/README.md +91 -0
- package/dist/templates/monorepo/_gitignore +12 -0
- package/dist/templates/monorepo/apps/api/_dev.vars.example +7 -0
- package/dist/templates/monorepo/apps/api/_gitignore +7 -0
- package/dist/templates/monorepo/apps/api/package.json +36 -0
- package/dist/templates/monorepo/apps/api/scripts/graph.ts +19 -0
- package/dist/templates/monorepo/apps/api/scripts/modules.ts +7 -0
- package/dist/templates/monorepo/apps/api/src/app.ts +42 -0
- package/dist/templates/monorepo/apps/api/src/index.ts +7 -0
- package/dist/templates/monorepo/apps/api/src/modules/posts/index.ts +31 -0
- package/dist/templates/monorepo/apps/api/src/modules/posts/posts.errors.ts +15 -0
- package/dist/templates/monorepo/apps/api/src/modules/posts/posts.repository.ts +22 -0
- package/dist/templates/monorepo/apps/api/src/modules/posts/posts.routes.ts +20 -0
- package/dist/templates/monorepo/apps/api/src/modules/posts/posts.schema.ts +13 -0
- package/dist/templates/monorepo/apps/api/src/modules/posts/posts.service.ts +26 -0
- package/dist/templates/monorepo/apps/api/src/types.d.ts +29 -0
- package/dist/templates/monorepo/apps/api/tsconfig.json +7 -0
- package/dist/templates/monorepo/apps/api/wrangler.jsonc +34 -0
- package/dist/templates/monorepo/package.json +24 -0
- package/dist/templates/monorepo/packages/api-client/package.json +20 -0
- package/dist/templates/monorepo/packages/api-client/src/index.ts +43 -0
- package/dist/templates/monorepo/packages/api-client/tsconfig.json +4 -0
- package/dist/templates/monorepo/packages/db/drizzle.config.ts +12 -0
- package/dist/templates/monorepo/packages/db/package.json +26 -0
- package/dist/templates/monorepo/packages/db/src/index.ts +13 -0
- package/dist/templates/monorepo/packages/db/src/schema.ts +12 -0
- package/dist/templates/monorepo/packages/db/tsconfig.json +4 -0
- package/dist/templates/monorepo/pnpm-workspace.yaml +3 -0
- package/dist/templates/monorepo/tsconfig.base.json +18 -0
- package/dist/templates/monorepo/turbo.json +19 -0
- package/dist/templates/monorepo-worker/apps/worker/_dev.vars.example +4 -0
- package/dist/templates/monorepo-worker/apps/worker/_gitignore +6 -0
- package/dist/templates/monorepo-worker/apps/worker/package.json +29 -0
- package/dist/templates/monorepo-worker/apps/worker/src/app.ts +27 -0
- package/dist/templates/monorepo-worker/apps/worker/src/index.ts +6 -0
- package/dist/templates/monorepo-worker/apps/worker/src/modules/example-consumer/example.consumer.ts +23 -0
- package/dist/templates/monorepo-worker/apps/worker/src/modules/example-consumer/example.service.ts +18 -0
- package/dist/templates/monorepo-worker/apps/worker/src/modules/example-consumer/index.ts +24 -0
- package/dist/templates/monorepo-worker/apps/worker/src/types.d.ts +19 -0
- package/dist/templates/monorepo-worker/apps/worker/tsconfig.json +7 -0
- package/dist/templates/monorepo-worker/apps/worker/wrangler.jsonc +28 -0
- package/package.json +54 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "node_modules/wrangler/config-schema.json",
|
|
3
|
+
"name": "{{PROJECT_NAME}}",
|
|
4
|
+
"main": "src/index.ts",
|
|
5
|
+
"compatibility_date": "{{TODAY_ISO}}",
|
|
6
|
+
"compatibility_flags": ["nodejs_compat"],
|
|
7
|
+
"observability": { "enabled": true },
|
|
8
|
+
"hyperdrive": [
|
|
9
|
+
{
|
|
10
|
+
"binding": "HYPERDRIVE",
|
|
11
|
+
"id": "<your-hyperdrive-id>",
|
|
12
|
+
"localConnectionString": "postgres://postgres:postgres@localhost:5432/{{PROJECT_NAME}}_dev"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
// Cloudflare Queues bindings. Uncomment + adjust when a module in this app
|
|
17
|
+
// declares a `consumer:` field (see docs/concepts/queues.md).
|
|
18
|
+
//
|
|
19
|
+
// "queues": {
|
|
20
|
+
// "producers": [
|
|
21
|
+
// { "binding": "ORDER_QUEUE", "queue": "orders" },
|
|
22
|
+
// { "binding": "ORDER_DLQ", "queue": "orders-dlq" }
|
|
23
|
+
// ],
|
|
24
|
+
// "consumers": [
|
|
25
|
+
// {
|
|
26
|
+
// "queue": "orders",
|
|
27
|
+
// "max_batch_size": 100,
|
|
28
|
+
// "max_batch_timeout": 30,
|
|
29
|
+
// "max_retries": 3,
|
|
30
|
+
// "dead_letter_queue": "orders-dlq"
|
|
31
|
+
// }
|
|
32
|
+
// ]
|
|
33
|
+
// }
|
|
34
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{PROJECT_NAME}}",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "turbo run dev",
|
|
8
|
+
"test": "turbo run test",
|
|
9
|
+
"typecheck": "turbo run typecheck",
|
|
10
|
+
"deploy": "pnpm --filter @{{PROJECT_NAME}}/api deploy",
|
|
11
|
+
"db:generate": "pnpm --filter @{{PROJECT_NAME}}/db db:generate",
|
|
12
|
+
"db:migrate": "pnpm --filter @{{PROJECT_NAME}}/db db:migrate",
|
|
13
|
+
"graph": "pnpm --filter @{{PROJECT_NAME}}/api graph"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"turbo": "^2.3.0",
|
|
17
|
+
"typescript": "^5.6.3"
|
|
18
|
+
},
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20",
|
|
21
|
+
"pnpm": ">=9"
|
|
22
|
+
},
|
|
23
|
+
"packageManager": "pnpm@9.12.3"
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@{{PROJECT_NAME}}/api-client",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.ts",
|
|
7
|
+
"types": "./src/index.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/index.ts"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"typecheck": "tsc --noEmit"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"hono": "^4.6.10"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.6.3"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed Hono RPC client factory.
|
|
3
|
+
*
|
|
4
|
+
* Generic over the API's `AppType` so this package has zero workspace deps —
|
|
5
|
+
* it doesn't try to resolve types from `apps/api`, which would force a
|
|
6
|
+
* cross-package typecheck of the entire API source. The consumer provides
|
|
7
|
+
* the type:
|
|
8
|
+
*
|
|
9
|
+
* import { createApiClient } from '@{{PROJECT_NAME}}/api-client';
|
|
10
|
+
* import type { AppType } from '@{{PROJECT_NAME}}/api';
|
|
11
|
+
*
|
|
12
|
+
* const api = createApiClient<AppType>('https://api.example.com');
|
|
13
|
+
* const res = await api.posts.$post({ json: { title: 't', body: 'b' } });
|
|
14
|
+
* const data = await res.json(); // typed end-to-end
|
|
15
|
+
*
|
|
16
|
+
* This package is the place to evolve cross-cutting client concerns over time
|
|
17
|
+
* — auth header injection, retry policy, error response parsing, request
|
|
18
|
+
* tracing, mock clients for testing.
|
|
19
|
+
*/
|
|
20
|
+
import { hc } from 'hono/client';
|
|
21
|
+
import type { Hono } from 'hono';
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
type AnyHono = Hono<any, any, any>;
|
|
25
|
+
|
|
26
|
+
export type ApiClient<App extends AnyHono> = ReturnType<typeof hc<App>>;
|
|
27
|
+
|
|
28
|
+
export type ApiClientOptions = {
|
|
29
|
+
/** Optional headers merged into every request (e.g. Authorization). */
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
/** Custom fetch implementation (e.g. for testing). Defaults to global `fetch`. */
|
|
32
|
+
fetch?: typeof fetch;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function createApiClient<App extends AnyHono>(
|
|
36
|
+
baseUrl: string,
|
|
37
|
+
options: ApiClientOptions = {},
|
|
38
|
+
): ApiClient<App> {
|
|
39
|
+
return hc<App>(baseUrl, {
|
|
40
|
+
headers: options.headers,
|
|
41
|
+
fetch: options.fetch,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineConfig } from 'drizzle-kit';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
dialect: 'postgresql',
|
|
5
|
+
schema: './src/schema.ts',
|
|
6
|
+
out: './migrations',
|
|
7
|
+
dbCredentials: {
|
|
8
|
+
url: process.env.DATABASE_URL ?? 'postgres://postgres:postgres@localhost:5432/{{PROJECT_NAME}}',
|
|
9
|
+
},
|
|
10
|
+
strict: true,
|
|
11
|
+
verbose: true,
|
|
12
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@{{PROJECT_NAME}}/db",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.ts",
|
|
7
|
+
"types": "./src/index.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/index.ts",
|
|
10
|
+
"./schema": "./src/schema.ts"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"typecheck": "tsc --noEmit",
|
|
14
|
+
"db:generate": "drizzle-kit generate",
|
|
15
|
+
"db:migrate": "drizzle-kit migrate"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"drizzle-orm": "^0.36.4",
|
|
19
|
+
"pg": "^8.13.1"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/pg": "^8.11.10",
|
|
23
|
+
"drizzle-kit": "^0.28.1",
|
|
24
|
+
"typescript": "^5.6.3"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public surface of @{{PROJECT_NAME}}/db.
|
|
3
|
+
*
|
|
4
|
+
* Workspace consumers import schema tables and types from here:
|
|
5
|
+
*
|
|
6
|
+
* import * as schema from '@{{PROJECT_NAME}}/db';
|
|
7
|
+
* import { posts, type Post, type NewPost } from '@{{PROJECT_NAME}}/db';
|
|
8
|
+
*
|
|
9
|
+
* Or pull just the schema namespace:
|
|
10
|
+
*
|
|
11
|
+
* import * as schema from '@{{PROJECT_NAME}}/db/schema';
|
|
12
|
+
*/
|
|
13
|
+
export * from './schema';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { pgTable, text, timestamp, uuid } from 'drizzle-orm/pg-core';
|
|
2
|
+
|
|
3
|
+
export const posts = pgTable('posts', {
|
|
4
|
+
id: uuid('id').primaryKey().defaultRandom(),
|
|
5
|
+
title: text('title').notNull(),
|
|
6
|
+
body: text('body').notNull(),
|
|
7
|
+
authorId: text('author_id').notNull(),
|
|
8
|
+
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type Post = typeof posts.$inferSelect;
|
|
12
|
+
export type NewPost = typeof posts.$inferInsert;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"noUncheckedIndexedAccess": true,
|
|
12
|
+
"allowSyntheticDefaultImports": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"isolatedModules": true,
|
|
15
|
+
"verbatimModuleSyntax": false,
|
|
16
|
+
"noEmit": true
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://turbo.build/schema.json",
|
|
3
|
+
"tasks": {
|
|
4
|
+
"dev": {
|
|
5
|
+
"persistent": true,
|
|
6
|
+
"cache": false
|
|
7
|
+
},
|
|
8
|
+
"test": {
|
|
9
|
+
"outputs": []
|
|
10
|
+
},
|
|
11
|
+
"typecheck": {
|
|
12
|
+
"outputs": []
|
|
13
|
+
},
|
|
14
|
+
"deploy": {
|
|
15
|
+
"cache": false,
|
|
16
|
+
"outputs": []
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@{{PROJECT_NAME}}/{{WORKER_NAME}}",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "wrangler dev",
|
|
8
|
+
"deploy": "wrangler deploy",
|
|
9
|
+
"typecheck": "tsc --noEmit"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@{{PROJECT_NAME}}/db": "workspace:*",
|
|
13
|
+
"@hono/zod-validator": "^0.4.1",
|
|
14
|
+
"@katajs/core": "^0.1.0",
|
|
15
|
+
"@katajs/drizzle": "^0.1.0",
|
|
16
|
+
"drizzle-orm": "^0.36.4",
|
|
17
|
+
"hono": "^4.6.10",
|
|
18
|
+
"pg": "^8.13.1",
|
|
19
|
+
"zod": "^3.23.8"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@cloudflare/workers-types": "^4.20241112.0",
|
|
23
|
+
"@katajs/cli": "^0.1.0",
|
|
24
|
+
"@types/node": "^22.9.0",
|
|
25
|
+
"@types/pg": "^8.11.10",
|
|
26
|
+
"typescript": "^5.6.3",
|
|
27
|
+
"wrangler": "^3.86.0"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createApp } from '@katajs/core';
|
|
2
|
+
import { drizzleAdapter } from '@katajs/drizzle';
|
|
3
|
+
import * as schema from '@{{PROJECT_NAME}}/db';
|
|
4
|
+
|
|
5
|
+
import { exampleConsumerModule } from './modules/example-consumer/index';
|
|
6
|
+
// katajs:module-imports
|
|
7
|
+
|
|
8
|
+
export type Bindings = {
|
|
9
|
+
HYPERDRIVE: Hyperdrive;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const { queue } = createApp({
|
|
13
|
+
bindings: {} as Bindings,
|
|
14
|
+
db: drizzleAdapter({ schema }),
|
|
15
|
+
modules: [
|
|
16
|
+
exampleConsumerModule,
|
|
17
|
+
// katajs:modules
|
|
18
|
+
],
|
|
19
|
+
queueErrorMapper: {
|
|
20
|
+
onUnhandled: (_err, _ctx) => {
|
|
21
|
+
// Real apps ship to Sentry/Logflare/etc. here.
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
// No routes — this Worker has no HTTP surface.
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export { queue };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { queue } from './app';
|
|
2
|
+
|
|
3
|
+
// Worker default export. This Worker is queue-only — no `fetch` handler.
|
|
4
|
+
// Cloudflare invokes `queue` for each message batch delivered to a queue
|
|
5
|
+
// listed in this Worker's `queues.consumers` block in wrangler.jsonc.
|
|
6
|
+
export default { queue };
|
package/dist/templates/monorepo-worker/apps/worker/src/modules/example-consumer/example.consumer.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineConsumer } from '@katajs/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Message body schema for the example queue. Replace this with the schema
|
|
6
|
+
* your producer (in apps/api) actually sends. If you want the producer and
|
|
7
|
+
* consumer to share the schema definition, extract it into a small shared
|
|
8
|
+
* package (e.g. `packages/events/`) and import from there.
|
|
9
|
+
*/
|
|
10
|
+
export const ExampleEventSchema = z.object({
|
|
11
|
+
id: z.string().uuid(),
|
|
12
|
+
payload: z.unknown(),
|
|
13
|
+
});
|
|
14
|
+
export type ExampleEvent = z.infer<typeof ExampleEventSchema>;
|
|
15
|
+
|
|
16
|
+
export const exampleConsumer = defineConsumer({
|
|
17
|
+
queue: 'EXAMPLE_QUEUE',
|
|
18
|
+
schema: ExampleEventSchema,
|
|
19
|
+
async handle(message, c) {
|
|
20
|
+
const service = c.resolve('exampleService');
|
|
21
|
+
await service.process(message.body);
|
|
22
|
+
},
|
|
23
|
+
});
|
package/dist/templates/monorepo-worker/apps/worker/src/modules/example-consumer/example.service.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RequestContainer } from '@katajs/core';
|
|
2
|
+
import type { ExampleEvent } from './example.consumer';
|
|
3
|
+
|
|
4
|
+
export type ExampleService = {
|
|
5
|
+
process(event: ExampleEvent): Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function makeExampleService(_c: RequestContainer): ExampleService {
|
|
9
|
+
return {
|
|
10
|
+
async process(event) {
|
|
11
|
+
// TODO: implement message processing.
|
|
12
|
+
// Reach `_c.db` for database access (the Drizzle client is shared with
|
|
13
|
+
// apps/api via `packages/db`). Reach `_c.resolve('otherService')` for
|
|
14
|
+
// services from other modules in this worker's `modules:` array.
|
|
15
|
+
void event;
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineModule } from '@katajs/core';
|
|
2
|
+
import { makeExampleService, type ExampleService } from './example.service';
|
|
3
|
+
// katajs:module-service-imports
|
|
4
|
+
import { exampleConsumer } from './example.consumer';
|
|
5
|
+
|
|
6
|
+
export const exampleConsumerModule = defineModule({
|
|
7
|
+
name: 'example-consumer',
|
|
8
|
+
provides: {
|
|
9
|
+
exampleService: (c): ExampleService => makeExampleService(c),
|
|
10
|
+
// katajs:module-provides
|
|
11
|
+
},
|
|
12
|
+
requires: [] as const,
|
|
13
|
+
consumer: exampleConsumer,
|
|
14
|
+
// katajs:module-consumer
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/** Services this module contributes to the container's `Registry`. */
|
|
18
|
+
export type ExampleConsumerRegistry = {
|
|
19
|
+
exampleService: ExampleService;
|
|
20
|
+
// katajs:module-registry
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type { ExampleService };
|
|
24
|
+
export { ExampleEventSchema, type ExampleEvent } from './example.consumer';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module augmentations for `@katajs/core`. Picked up automatically by
|
|
3
|
+
* tsconfig's `include` glob — no runtime import needed.
|
|
4
|
+
*/
|
|
5
|
+
import type { DrizzleClient } from '@katajs/drizzle';
|
|
6
|
+
import type * as schema from '@{{PROJECT_NAME}}/db';
|
|
7
|
+
import type { Bindings } from './app';
|
|
8
|
+
|
|
9
|
+
import type { ExampleConsumerRegistry } from './modules/example-consumer/index';
|
|
10
|
+
// katajs:registry-imports
|
|
11
|
+
|
|
12
|
+
declare module '@katajs/core' {
|
|
13
|
+
interface AppDb extends DrizzleClient<typeof schema> {}
|
|
14
|
+
interface AppEnv extends Bindings {}
|
|
15
|
+
interface Registry
|
|
16
|
+
extends ExampleConsumerRegistry
|
|
17
|
+
// katajs:registry
|
|
18
|
+
{}
|
|
19
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "node_modules/wrangler/config-schema.json",
|
|
3
|
+
"name": "{{PROJECT_NAME}}-{{WORKER_NAME}}",
|
|
4
|
+
"main": "src/index.ts",
|
|
5
|
+
"compatibility_date": "{{TODAY_ISO}}",
|
|
6
|
+
"compatibility_flags": ["nodejs_compat"],
|
|
7
|
+
"observability": { "enabled": true },
|
|
8
|
+
"hyperdrive": [
|
|
9
|
+
{
|
|
10
|
+
"binding": "HYPERDRIVE",
|
|
11
|
+
"id": "<your-hyperdrive-id>",
|
|
12
|
+
"localConnectionString": "postgres://postgres:postgres@localhost:5432/{{PROJECT_NAME}}_dev"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
|
|
16
|
+
// Queue consumer bindings. The producer side lives in apps/api/wrangler.jsonc.
|
|
17
|
+
// Add one entry per queue this worker consumes.
|
|
18
|
+
"queues": {
|
|
19
|
+
"consumers": [
|
|
20
|
+
{
|
|
21
|
+
"queue": "example-events",
|
|
22
|
+
"max_batch_size": 100,
|
|
23
|
+
"max_batch_timeout": 30,
|
|
24
|
+
"max_retries": 3
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-katajs",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Scaffolding CLI for katajs projects.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"katajs",
|
|
7
|
+
"create",
|
|
8
|
+
"scaffold",
|
|
9
|
+
"cli",
|
|
10
|
+
"hono",
|
|
11
|
+
"cloudflare",
|
|
12
|
+
"workers"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "Yaseer A. Okino <yaseerokino@gmail.com>",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/ookino/katajs.git",
|
|
19
|
+
"directory": "packages/cli"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/ookino/katajs/tree/main/packages/cli#readme",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/ookino/katajs/issues"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"bin": {
|
|
27
|
+
"create-katajs": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@clack/prompts": "^0.8.2",
|
|
36
|
+
"cac": "^6.7.14",
|
|
37
|
+
"kolorist": "^1.8.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^22.9.0",
|
|
41
|
+
"tsup": "^8.3.5",
|
|
42
|
+
"typescript": "^5.6.3",
|
|
43
|
+
"vitest": "^2.1.5"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsup",
|
|
50
|
+
"dev": "tsup --watch",
|
|
51
|
+
"test": "vitest run --passWithNoTests",
|
|
52
|
+
"typecheck": "tsc --noEmit"
|
|
53
|
+
}
|
|
54
|
+
}
|