@oyolincc/create 0.0.0-dev-20260918103756 → 0.0.0-dev-20261006065712

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.
Files changed (135) hide show
  1. package/package.json +1 -1
  2. package/templates/hono-fullstack/.vscode/launch.json +14 -3
  3. package/templates/hono-fullstack/.vscode/settings.json +3 -1
  4. package/templates/hono-fullstack/AGENTS.md +7 -0
  5. package/templates/hono-fullstack/README.md +28 -14
  6. package/templates/hono-fullstack/_gitignore +4 -0
  7. package/templates/hono-fullstack/apps/server/.dev.vars.example +9 -0
  8. package/templates/hono-fullstack/apps/server/package.json +17 -10
  9. package/templates/hono-fullstack/apps/server/src/adapters/cloudflare/entry.ts +36 -0
  10. package/templates/hono-fullstack/apps/server/src/adapters/nodejs/bootstrap.ts +3 -6
  11. package/templates/hono-fullstack/apps/server/src/adapters/nodejs/entry.ts +21 -6
  12. package/templates/hono-fullstack/apps/server/src/app.ts +4 -6
  13. package/templates/hono-fullstack/apps/server/src/config.ts +47 -0
  14. package/templates/hono-fullstack/apps/server/src/infra/logger/pino.ts +4 -0
  15. package/templates/hono-fullstack/apps/server/src/infra/work-runner/example/worker-entry.ts +4 -25
  16. package/templates/hono-fullstack/apps/server/src/infra/work-runner/pass-through/runner.ts +42 -0
  17. package/templates/{hono-server/apps/server/src/infra/work-runner/example → hono-fullstack/apps/server/src/infra/work-runner/piscina}/runner.ts +9 -9
  18. package/templates/hono-fullstack/apps/server/src/infra/work-runner/types.ts +7 -2
  19. package/templates/hono-fullstack/apps/server/src/infra/work-runner/utils/message.ts +7 -4
  20. package/templates/hono-fullstack/apps/server/src/modules/example/routes.ts +3 -5
  21. package/templates/hono-fullstack/apps/server/src/modules/example/work-task/tasks.test.ts +17 -5
  22. package/templates/hono-fullstack/apps/server/src/modules/example/work-task/tasks.ts +38 -15
  23. package/templates/hono-fullstack/apps/server/src/shared/app/types.ts +8 -4
  24. package/templates/hono-fullstack/apps/server/src/shared/network/validator.ts +10 -3
  25. package/templates/hono-fullstack/apps/server/tsconfig.json +1 -0
  26. package/templates/hono-fullstack/apps/server/vite.config.ts +8 -3
  27. package/templates/hono-fullstack/apps/server/wrangler.jsonc +29 -0
  28. package/templates/hono-fullstack/apps/stack/backend/cloudflare.ts +5 -0
  29. package/templates/hono-fullstack/apps/stack/backend/node.ts +3 -0
  30. package/templates/hono-fullstack/apps/stack/frontend/components/general/ErrorMessage.tsx +4 -0
  31. package/templates/hono-fullstack/apps/stack/frontend/components/layouts/AppLayout.tsx +11 -0
  32. package/templates/hono-fullstack/apps/stack/frontend/components/layouts/Header.tsx +7 -0
  33. package/templates/hono-fullstack/apps/stack/frontend/components/layouts/Page.tsx +5 -0
  34. package/templates/hono-fullstack/apps/stack/frontend/components/layouts/PageContainer.tsx +5 -0
  35. package/templates/hono-fullstack/apps/stack/frontend/modules/example/components/ExampleForm.tsx +45 -0
  36. package/templates/hono-fullstack/apps/stack/frontend/modules/example/components/ExampleList.tsx +13 -0
  37. package/templates/hono-fullstack/apps/stack/frontend/modules/example/{hooks.ts → hooks/api-hooks.ts} +2 -1
  38. package/templates/hono-fullstack/apps/stack/frontend/modules/example/stores/index.ts +3 -0
  39. package/templates/hono-fullstack/apps/stack/frontend/routeTree.gen.ts +21 -4
  40. package/templates/hono-fullstack/apps/stack/frontend/routes/api/$.ts +18 -0
  41. package/templates/hono-fullstack/apps/stack/frontend/routes/index.tsx +48 -2
  42. package/templates/hono-fullstack/apps/stack/frontend/vite-env.d.ts +5 -0
  43. package/templates/hono-fullstack/apps/stack/package.json +20 -4
  44. package/templates/hono-fullstack/apps/stack/tsconfig.json +7 -4
  45. package/templates/hono-fullstack/apps/stack/tsr.config.json +2 -2
  46. package/templates/hono-fullstack/apps/stack/vite.config.ts +75 -26
  47. package/templates/hono-fullstack/apps/stack/wrangler.jsonc +20 -0
  48. package/templates/hono-fullstack/envs/.env.example.server +1 -1
  49. package/templates/hono-fullstack/envs/.env.example.sqlite +1 -2
  50. package/templates/hono-fullstack/envs/.env.example.sqlite-d1 +3 -0
  51. package/templates/hono-fullstack/libs/db/drizzle-kit/sqlite-d1.config.ts +22 -0
  52. package/templates/hono-fullstack/libs/db/package.json +9 -6
  53. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/d1-client.ts +12 -0
  54. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/columns.ts +5 -0
  55. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/modules/examples/examples.ts +2 -2
  56. package/templates/hono-fullstack/libs/db/vite.config.ts +1 -0
  57. package/templates/hono-fullstack/libs/definition/src/configs/defs/runtime.ts +1 -0
  58. package/templates/hono-fullstack/libs/definition/src/configs/defs/sqlite.ts +16 -3
  59. package/templates/hono-fullstack/oyo.config.json +2 -1
  60. package/templates/hono-fullstack/package.json +1 -5
  61. package/templates/hono-fullstack/pnpm-workspace.yaml +8 -6
  62. package/templates/hono-fullstack/turbo.json +26 -3
  63. package/templates/hono-fullstack/vite.config.ts +1 -0
  64. package/templates/hono-server/.vscode/launch.json +7 -3
  65. package/templates/hono-server/.vscode/settings.json +3 -1
  66. package/templates/hono-server/AGENTS.md +7 -0
  67. package/templates/hono-server/README.md +25 -12
  68. package/templates/hono-server/_gitignore +4 -0
  69. package/templates/hono-server/apps/server/.dev.vars.example +9 -0
  70. package/templates/hono-server/apps/server/package.json +18 -9
  71. package/templates/hono-server/apps/server/src/adapters/cloudflare/entry.ts +36 -0
  72. package/templates/hono-server/apps/server/src/adapters/nodejs/bootstrap.ts +3 -3
  73. package/templates/hono-server/apps/server/src/adapters/nodejs/entry.ts +28 -6
  74. package/templates/hono-server/apps/server/src/app.ts +4 -6
  75. package/templates/hono-server/apps/server/src/config.ts +47 -0
  76. package/templates/hono-server/apps/server/src/infra/logger/pino.ts +4 -0
  77. package/templates/hono-server/apps/server/src/infra/work-runner/example/worker-entry.ts +4 -25
  78. package/templates/hono-server/apps/server/src/infra/work-runner/pass-through/runner.ts +42 -0
  79. package/templates/{hono-fullstack/apps/server/src/infra/work-runner/example → hono-server/apps/server/src/infra/work-runner/piscina}/runner.ts +9 -9
  80. package/templates/hono-server/apps/server/src/infra/work-runner/types.ts +7 -2
  81. package/templates/hono-server/apps/server/src/infra/work-runner/utils/message.ts +7 -4
  82. package/templates/hono-server/apps/server/src/modules/example/contracts.ts +4 -0
  83. package/templates/hono-server/apps/server/src/modules/example/routes.ts +32 -5
  84. package/templates/hono-server/apps/server/src/modules/example/work-task/tasks.test.ts +17 -5
  85. package/templates/hono-server/apps/server/src/modules/example/work-task/tasks.ts +38 -15
  86. package/templates/hono-server/apps/server/src/shared/app/types.ts +8 -4
  87. package/templates/hono-server/apps/server/src/shared/network/validator.ts +10 -3
  88. package/templates/hono-server/apps/server/tsconfig.json +1 -0
  89. package/templates/hono-server/apps/server/vite.config.ts +8 -3
  90. package/templates/hono-server/apps/server/wrangler.jsonc +29 -0
  91. package/templates/hono-server/docker/server.Dockerfile +3 -5
  92. package/templates/hono-server/envs/.env.example.server +1 -1
  93. package/templates/hono-server/envs/.env.example.sqlite +1 -0
  94. package/templates/hono-server/envs/.env.example.sqlite-d1 +3 -0
  95. package/templates/hono-server/libs/db/drizzle-kit/sqlite-d1.config.ts +22 -0
  96. package/templates/hono-server/libs/db/drizzle-kit/sqlite.config.ts +22 -0
  97. package/templates/hono-server/libs/db/package.json +42 -0
  98. package/templates/hono-server/libs/db/src/dialects/sqlite/client.ts +35 -0
  99. package/templates/hono-server/libs/db/src/dialects/sqlite/d1-client.ts +12 -0
  100. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/columns.ts +37 -0
  101. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/index.ts +7 -0
  102. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/modules/examples/examples.ts +22 -0
  103. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/relations.ts +5 -0
  104. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/tables.ts +5 -0
  105. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/types.ts +7 -0
  106. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/vo.ts +1 -0
  107. package/templates/hono-server/libs/db/src/dialects/sqlite/utils.ts +8 -0
  108. package/templates/hono-server/libs/db/src/shared/types.ts +26 -0
  109. package/templates/hono-server/libs/db/tsconfig.json +10 -0
  110. package/templates/hono-server/libs/db/vite.config.ts +22 -0
  111. package/templates/hono-server/libs/definition/src/configs/defs/runtime.ts +1 -0
  112. package/templates/hono-server/libs/definition/src/configs/defs/sqlite.ts +26 -0
  113. package/templates/hono-server/libs/definition/src/configs/index.ts +1 -0
  114. package/templates/hono-server/libs/definition/vite.config.ts +1 -1
  115. package/templates/hono-server/oyo.config.json +3 -1
  116. package/templates/hono-server/package.json +2 -3
  117. package/templates/hono-server/pnpm-workspace.yaml +13 -4
  118. package/templates/hono-server/turbo.json +26 -3
  119. package/templates/hono-server/vite.config.ts +1 -0
  120. package/templates/monorepo/.vscode/launch.json +0 -3
  121. package/templates/monorepo/.vscode/settings.json +3 -1
  122. package/templates/monorepo/AGENTS.md +7 -0
  123. package/templates/monorepo/_gitignore +4 -0
  124. package/templates/monorepo/pnpm-workspace.yaml +6 -3
  125. package/templates/monorepo/turbo.json +26 -3
  126. package/templates/monorepo/vite.config.ts +1 -0
  127. package/templates/hono-fullstack/apps/server/src/adapters/nodejs/config.ts +0 -53
  128. package/templates/hono-fullstack/apps/server/src/app.test.ts +0 -52
  129. package/templates/hono-fullstack/apps/server/src/infra/work-runner/example/runner.test.ts +0 -56
  130. package/templates/hono-fullstack/apps/stack/frontend/modules/example/ExamplePage.tsx +0 -57
  131. package/templates/hono-fullstack/apps/stack/nitro/handlers/hono.ts +0 -1
  132. package/templates/hono-fullstack/apps/stack/nitro/plugins/hono.ts +0 -9
  133. package/templates/hono-server/apps/server/src/adapters/nodejs/config.ts +0 -53
  134. package/templates/hono-server/apps/server/src/app.test.ts +0 -52
  135. package/templates/hono-server/apps/server/src/infra/work-runner/example/runner.test.ts +0 -56
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "./node_modules/wrangler/config-schema.json",
3
+ "name": "repo-server-dev",
4
+ "main": "./src/adapters/cloudflare/entry.ts",
5
+ "compatibility_date": "2026-09-23",
6
+ "compatibility_flags": ["nodejs_compat"],
7
+ "dev": {
8
+ "port": 6464,
9
+ "inspector_port": 19230,
10
+ },
11
+ "observability": {
12
+ "logs": {
13
+ "enabled": true,
14
+ "invocation_logs": true,
15
+ },
16
+ "traces": {
17
+ "enabled": false,
18
+ },
19
+ },
20
+ "d1_databases": [
21
+ {
22
+ "binding": "DB",
23
+ "database_name": "repo-db",
24
+ "database_id": "00000000-0000-0000-0000-000000000000",
25
+ "migrations_dir": "../../libs/db/migrations/sqlite-d1",
26
+ "migrations_pattern": "../../libs/db/migrations/sqlite-d1/*/migration.sql",
27
+ },
28
+ ],
29
+ }
@@ -20,9 +20,8 @@ RUN pnpm exec turbo build
20
20
 
21
21
  FROM builder AS packager
22
22
  RUN pnpm --filter=@repo/server --prod --legacy deploy /app/deploy
23
- RUN test -f /app/deploy/dist/nodeMain.mjs && \
24
- test -f /app/deploy/dist/nodeEntry.mjs && \
25
- test -f /app/deploy/dist/workers/example-worker.mjs
23
+ RUN test -f /app/deploy/dist/nodejsMain.mjs && \
24
+ test -f /app/deploy/dist/nodejsEntry.mjs
26
25
 
27
26
  FROM base AS runner
28
27
  ENV NODE_ENV=production
@@ -36,5 +35,4 @@ USER server
36
35
  EXPOSE 6464
37
36
  HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
38
37
  CMD node -e "require('http').get('http://127.0.0.1:6464/health',r=>process.exit(r.statusCode<500?0:1)).on('error',()=>process.exit(1))"
39
- CMD ["node", "--import", "dotenv/config", "dist/nodeMain.mjs"]
40
-
38
+ CMD ["node", "--import", "dotenv/config", "dist/nodejsMain.mjs"]
@@ -1,4 +1,5 @@
1
1
  NODE_PORT=6464
2
+ SERVER_BASE_PATH=/api
2
3
  SERVER_ENV=local
3
4
  LOGGER_DIR=./logs
4
5
  LOGGER_FILE_BASE=app
@@ -9,4 +10,3 @@ CORS_DOMAINS='*'
9
10
  # CONCURRENT_TASKS_PER_WORKER=1
10
11
  # MAX_QUEUE=12
11
12
  # WORKER_TASK_TIMEOUT_MS=30000
12
-
@@ -0,0 +1 @@
1
+ DB_PATH=/absolute/path/to/repo.sqlite
@@ -0,0 +1,3 @@
1
+ CLOUDFLARE_ACCOUNT_ID=
2
+ CLOUDFLARE_DATABASE_ID=
3
+ CLOUDFLARE_TOKEN=
@@ -0,0 +1,22 @@
1
+ import path from 'node:path'
2
+ import { defineConfig } from 'drizzle-kit'
3
+ import { d1SchemaConfig } from '@repo/definition/backend'
4
+
5
+ const configDir = import.meta.dirname
6
+
7
+ const { cloudflareAccountId, cloudflareDatabaseId, cloudflareToken } = d1SchemaConfig.resolve({
8
+ context: process.env,
9
+ matchContextKey: 'constantCase',
10
+ })
11
+
12
+ export default defineConfig({
13
+ dialect: 'sqlite',
14
+ driver: 'd1-http',
15
+ schema: path.join(configDir, '../src/dialects/sqlite/schema/tables.ts'),
16
+ out: path.join(configDir, '../migrations/sqlite-d1'),
17
+ dbCredentials: {
18
+ accountId: cloudflareAccountId,
19
+ databaseId: cloudflareDatabaseId,
20
+ token: cloudflareToken,
21
+ },
22
+ })
@@ -0,0 +1,22 @@
1
+ import path from 'node:path'
2
+ import { defineConfig } from 'drizzle-kit'
3
+ import { ensureDatabaseDirectory } from '../src/dialects/sqlite/utils'
4
+ import { sqliteSchemaConfig } from '@repo/definition/backend'
5
+
6
+ const configDir = import.meta.dirname
7
+
8
+ const { dbPath } = sqliteSchemaConfig.resolve({
9
+ context: process.env,
10
+ matchContextKey: 'constantCase',
11
+ })
12
+
13
+ ensureDatabaseDirectory(dbPath)
14
+
15
+ export default defineConfig({
16
+ dialect: 'sqlite',
17
+ schema: path.join(configDir, '../src/dialects/sqlite/schema/tables.ts'),
18
+ out: path.join(configDir, '../migrations/sqlite'),
19
+ dbCredentials: {
20
+ url: dbPath,
21
+ },
22
+ })
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@repo/db",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "type": "module",
9
+ "exports": {
10
+ "./sqlite/d1-client": "./dist/sqlite/d1-client.mjs",
11
+ "./sqlite/schema": "./dist/sqlite/schema.mjs",
12
+ "./sqlite/sqlite": "./dist/sqlite/sqlite.mjs",
13
+ "./package.json": "./package.json"
14
+ },
15
+ "scripts": {
16
+ "build": "vp pack",
17
+ "dev": "vp pack --watch",
18
+ "test": "vp test",
19
+ "check": "vp check",
20
+ "sqlite:export": "oyo env sqlite -- drizzle-kit export --config=drizzle-kit/sqlite.config.ts",
21
+ "dev:sqlite:push": "oyo env sqlite -- drizzle-kit push --config=drizzle-kit/sqlite.config.ts",
22
+ "dev:sqlite:gen": "oyo env sqlite -- drizzle-kit generate --config=drizzle-kit/sqlite.config.ts",
23
+ "dev:sqlite:migrate": "oyo env sqlite -- drizzle-kit migrate --config=drizzle-kit/sqlite.config.ts",
24
+ "dev:d1:gen": "oyo env sqlite-d1 -- drizzle-kit generate --config=drizzle-kit/sqlite-d1.config.ts",
25
+ "dev:d1:migrate": "oyo env sqlite-d1 -- drizzle-kit migrate --config=drizzle-kit/sqlite-d1.config.ts"
26
+ },
27
+ "dependencies": {
28
+ "@repo/definition": "workspace:*",
29
+ "better-sqlite3": "catalog:db",
30
+ "drizzle-orm": "catalog:db"
31
+ },
32
+ "devDependencies": {
33
+ "@oyolincc/cli": "catalog:",
34
+ "@oyolincc/dev-config": "catalog:",
35
+ "@types/better-sqlite3": "catalog:db",
36
+ "@types/node": "catalog:",
37
+ "drizzle-kit": "catalog:db",
38
+ "tsx": "catalog:",
39
+ "typescript": "catalog:",
40
+ "vite-plus": "catalog:"
41
+ }
42
+ }
@@ -0,0 +1,35 @@
1
+ import Database from 'better-sqlite3'
2
+ import { drizzle } from 'drizzle-orm/better-sqlite3'
3
+ import { relations, type SqliteDBType } from './schema'
4
+ import { ensureDatabaseDirectory } from './utils'
5
+
6
+ export type SqliteDatabase = SqliteDBType
7
+
8
+ export interface SqliteClient {
9
+ db: SqliteDatabase
10
+ close(): void
11
+ }
12
+
13
+ export function createSqliteClient(databaseFile: string): SqliteClient {
14
+ if (!databaseFile) throw new Error('databaseFile must not be empty')
15
+
16
+ ensureDatabaseDirectory(databaseFile)
17
+
18
+ const client = new Database(databaseFile)
19
+ client.pragma('foreign_keys = ON')
20
+ if (databaseFile !== ':memory:') client.pragma('journal_mode = WAL')
21
+
22
+ const db = drizzle({ client, relations })
23
+
24
+ let closed = false
25
+
26
+ return {
27
+ db,
28
+ close() {
29
+ if (!closed) {
30
+ client.close()
31
+ closed = true
32
+ }
33
+ },
34
+ }
35
+ }
@@ -0,0 +1,12 @@
1
+ import { drizzle, type AnyD1Database } from 'drizzle-orm/d1'
2
+ import { relations } from './schema'
3
+
4
+ export type D1Binding = AnyD1Database
5
+
6
+ export function createD1Client(database: D1Binding) {
7
+ if (!database) throw new Error('database must not be empty')
8
+
9
+ const db = drizzle(database, { relations })
10
+
11
+ return { db }
12
+ }
@@ -0,0 +1,37 @@
1
+ import { sql } from 'drizzle-orm'
2
+ import { customType, integer, text } from 'drizzle-orm/sqlite-core'
3
+
4
+ export const idType = customType<{ data: string; driverData: number | bigint }>({
5
+ dataType() {
6
+ return 'integer'
7
+ },
8
+ fromDriver(value) {
9
+ return String(value)
10
+ },
11
+ })
12
+
13
+ export const autoIncrementId = (name: string) =>
14
+ idType(name)
15
+ .primaryKey({ autoIncrement: true })
16
+ .$defaultFn(() => sql`null`)
17
+
18
+ export function timestampMsColumn(name: string) {
19
+ return integer(name, { mode: 'timestamp_ms' })
20
+ .notNull()
21
+ .default(sql`(unixepoch('subsec') * 1000)`)
22
+ }
23
+
24
+ export const updatedAtCol = () => timestampMsColumn('updated_at').$onUpdateFn(() => new Date())
25
+
26
+ /**
27
+ * createdAt 和 updatedAt 是数据库行的创建/修改时间,SQLite 保存毫秒时间戳,代码里使用 Date。
28
+ * syncState.updatedTime 是客户端同步版本号,和这两个时间不是一回事,不要混用。
29
+ */
30
+ export const modifiedTimeCols = () => ({
31
+ createdAt: timestampMsColumn('created_at'),
32
+ updatedAt: updatedAtCol(),
33
+ })
34
+
35
+ export function jsonColumn<T>(name: string) {
36
+ return text(name, { mode: 'json' }).$type<T>()
37
+ }
@@ -0,0 +1,7 @@
1
+ export * from './relations'
2
+ export * from './tables'
3
+ export * from './types'
4
+ export * from './vo'
5
+ export * from '@/shared/types'
6
+
7
+ export { relations } from './relations'
@@ -0,0 +1,22 @@
1
+ import { sqliteTable, text } from 'drizzle-orm/sqlite-core'
2
+ import { autoIncrementId, modifiedTimeCols } from '../../columns'
3
+ import type { SelectVOResults } from '@/shared/types'
4
+ import { defineVO } from '@/shared/types'
5
+
6
+ export const examples = sqliteTable('examples', {
7
+ id: autoIncrementId('id'),
8
+ message: text('message').notNull(),
9
+ ...modifiedTimeCols(),
10
+ })
11
+
12
+ export type InsertExample = typeof examples.$inferInsert
13
+
14
+ export const voExamples = defineVO({
15
+ id: examples.id,
16
+ message: examples.message,
17
+ createdAt: examples.createdAt,
18
+ updatedAt: examples.updatedAt,
19
+ })
20
+ export type IExamplesVO = SelectVOResults<typeof voExamples>
21
+
22
+ export const vcExamples = { default: voExamples } as const
@@ -0,0 +1,5 @@
1
+ import { defineRelations } from 'drizzle-orm'
2
+ import { sqliteTableDefs } from './tables'
3
+
4
+ /** The example table has no relationships; keep the relations entrypoint for future modules. */
5
+ export const relations = defineRelations(sqliteTableDefs)
@@ -0,0 +1,5 @@
1
+ export { examples, type InsertExample } from './modules/examples/examples'
2
+
3
+ import { examples } from './modules/examples/examples'
4
+
5
+ export const sqliteTableDefs = { examples } as const
@@ -0,0 +1,7 @@
1
+ import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3'
2
+ import type { AnySQLiteColumn, AnySQLiteTable } from 'drizzle-orm/sqlite-core'
3
+ import type { relations } from './relations'
4
+
5
+ export type SqliteDBType = BetterSQLite3Database<typeof relations>
6
+ export type SqliteTableType = AnySQLiteTable
7
+ export type SqliteColType = AnySQLiteColumn
@@ -0,0 +1 @@
1
+ export { vcExamples, voExamples, type IExamplesVO } from './modules/examples/examples'
@@ -0,0 +1,8 @@
1
+ import { mkdirSync } from 'node:fs'
2
+ import { dirname } from 'node:path'
3
+
4
+ export function ensureDatabaseDirectory(databaseFile: string): void {
5
+ if (!databaseFile || databaseFile === ':memory:') return
6
+
7
+ mkdirSync(dirname(databaseFile), { recursive: true })
8
+ }
@@ -0,0 +1,26 @@
1
+ import type { AnyColumn, GetColumnData, InferModelFromColumns, Table } from 'drizzle-orm'
2
+
3
+ export type AnyTableType = Table
4
+ export type AnyColType = AnyColumn
5
+
6
+ export type TableColsMap<T extends AnyTableType> = T['_']['columns']
7
+ export type TableField<T extends AnyTableType> = keyof TableColsMap<T> & string
8
+ export type TableFieldValue<T extends AnyTableType, K extends TableField<T>> = GetColumnData<
9
+ TableColsMap<T>[K],
10
+ 'query'
11
+ >
12
+
13
+ export type VO<TColumn extends AnyColType = AnyColType> = Record<string, TColumn>
14
+ export type InsertModel<T extends AnyTableType> = InferModelFromColumns<TableColsMap<T>, 'insert'>
15
+
16
+ export function defineVO<T extends VO>(vo: T): T {
17
+ return vo
18
+ }
19
+
20
+ export type SelectVOResults<V extends VO> = {
21
+ [K in keyof V]: GetColumnData<V[K], 'query'>
22
+ }
23
+
24
+ export type VOColsOption<V extends VO> = {
25
+ [K in keyof V]: true
26
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "@oyolincc/dev-config/tsconfig.bundler.json",
3
+ "compilerOptions": {
4
+ "paths": {
5
+ "@/*": ["./src/*"]
6
+ }
7
+ },
8
+ "files": [],
9
+ "include": ["src", "drizzle-kit", "./*.ts", "./*.mts"]
10
+ }
@@ -0,0 +1,22 @@
1
+ import { defineConfig } from 'vite-plus'
2
+ import { packConfig } from '@oyolincc/dev-config'
3
+ import path from 'node:path'
4
+
5
+ const __dirname = import.meta.dirname
6
+
7
+ export default defineConfig({
8
+ pack: {
9
+ ...packConfig,
10
+ entry: {
11
+ 'sqlite/schema': 'src/dialects/sqlite/schema/index.ts',
12
+ 'sqlite/sqlite': 'src/dialects/sqlite/client.ts',
13
+ 'sqlite/d1-client': 'src/dialects/sqlite/d1-client.ts',
14
+ },
15
+ exports: true,
16
+ },
17
+ resolve: {
18
+ alias: {
19
+ '@': path.resolve(__dirname, './src'),
20
+ },
21
+ },
22
+ })
@@ -2,6 +2,7 @@ import * as v from 'valibot'
2
2
  import { defineSchemaConfig } from '../proto'
3
3
 
4
4
  export const $S_RuntimeConfig = v.object({
5
+ serverBasePath: v.optional(v.string(), '/'),
5
6
  serverEnv: v.optional(
6
7
  v.union([v.literal('local'), v.literal('test'), v.literal('staging'), v.literal('main')]),
7
8
  'local',
@@ -0,0 +1,26 @@
1
+ import path from 'node:path'
2
+ import * as v from 'valibot'
3
+ import { defineSchemaConfig } from '../proto'
4
+ import { $S_NonEmptyString } from '../schema'
5
+
6
+ function defaultSqliteDbPath(): string {
7
+ const workspaceRoot = path.join(import.meta.dirname, '../../..')
8
+ return path.join(workspaceRoot, 'db-data', 'repo.sqlite')
9
+ }
10
+
11
+ export const $S_SqliteSchemaConfig = v.object({
12
+ dbPath: v.pipe(
13
+ v.optional($S_NonEmptyString),
14
+ v.transform((dbPath) => dbPath || defaultSqliteDbPath()),
15
+ ) as v.GenericSchema<string | undefined, string>,
16
+ })
17
+ export type SqliteSchemaConfig = v.InferOutput<typeof $S_SqliteSchemaConfig>
18
+ export const sqliteSchemaConfig = defineSchemaConfig($S_SqliteSchemaConfig)
19
+
20
+ export const $S_D1SchemaConfig = v.object({
21
+ cloudflareAccountId: $S_NonEmptyString,
22
+ cloudflareDatabaseId: $S_NonEmptyString,
23
+ cloudflareToken: $S_NonEmptyString,
24
+ })
25
+ export type D1SchemaConfig = v.InferOutput<typeof $S_D1SchemaConfig>
26
+ export const d1SchemaConfig = defineSchemaConfig($S_D1SchemaConfig)
@@ -2,3 +2,4 @@ export * from './defs/runtime'
2
2
  export * from './defs/log'
3
3
  export * from './defs/middleware'
4
4
  export * from './defs/worker'
5
+ export * from './defs/sqlite'
@@ -7,6 +7,6 @@ export default defineConfig({
7
7
  entry: {
8
8
  backend: 'src/backend.ts',
9
9
  },
10
- exports: true,
10
+ exports: false,
11
11
  },
12
12
  })
@@ -2,7 +2,9 @@
2
2
  "env": {
3
3
  "dir": "./envs/",
4
4
  "presets": {
5
- "server": [".env.server"]
5
+ "server": [".env.server", ".env.sqlite"],
6
+ "sqlite": [".env.sqlite"],
7
+ "sqlite-d1": [".env.sqlite-d1"]
6
8
  }
7
9
  },
8
10
  "codeGenerator": {
@@ -5,8 +5,8 @@
5
5
  "scripts": {
6
6
  "prepare": "vp config",
7
7
  "changeset": "vp exec changeset",
8
- "dev": "turbo build --filter=@repo/definition && concurrently -k -n definition,server -c blue,green \"pnpm --filter @repo/definition dev\" \"pnpm --filter @repo/server dev\"",
9
- "build": "turbo build"
8
+ "build": "turbo build",
9
+ "build:libs": "turbo build --filter=!@repo/stack --filter=!@repo/server"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@changesets/changelog-github": "catalog:",
@@ -14,7 +14,6 @@
14
14
  "@oyolincc/cli": "catalog:",
15
15
  "@oyolincc/dev-config": "catalog:",
16
16
  "@types/node": "catalog:",
17
- "concurrently": "catalog:",
18
17
  "tsx": "catalog:",
19
18
  "turbo": "catalog:",
20
19
  "vite-plus": "catalog:"
@@ -8,6 +8,7 @@ catalogPrune: true
8
8
  catalog:
9
9
  '@changesets/changelog-github': '0.5.0'
10
10
  '@changesets/cli': '2.27.12'
11
+ '@cloudflare/vite-plugin': '1.62.5'
11
12
  '@oyolincc/cli': '2.1.3'
12
13
  '@oyolincc/dev-config': '0.1.1'
13
14
  '@oyolincc/env-loader': '^0.2.0'
@@ -17,8 +18,9 @@ catalog:
17
18
  'tsx': '4.21.0'
18
19
  'turbo': '^2.9.14'
19
20
  'typescript': '7.0.2'
20
- 'vite': 'npm:@voidzero-dev/vite-plus-core@0.2.8'
21
- 'vite-plus': '0.2.8'
21
+ 'vite': 'npm:@voidzero-dev/vite-plus-core@0.3.1'
22
+ 'vite-plus': '0.3.1'
23
+ 'wrangler': '4.147.0'
22
24
 
23
25
  catalogs:
24
26
  shared:
@@ -36,16 +38,21 @@ catalogs:
36
38
  '@hono/vite-dev-server': '^0.26.1'
37
39
  '@valibot/to-json-schema': '^1.7.1'
38
40
  'hono': '^4.13.1'
39
- 'hono-openapi': '^1.3.1'
41
+ 'hono-openapi': '^1.3.3'
40
42
  'hono-pino': '^0.10.3'
41
43
  'hono-problem-details': '^0.11.0'
42
44
  'pino': '^10.3.1'
43
45
  'pino-pretty': '^13.1.3'
44
46
  'pino-roll': '^4.0.0'
45
47
  'piscina': '^5.3.0'
48
+ db:
49
+ '@types/better-sqlite3': '^7.6.13'
50
+ 'better-sqlite3': '^12.11.1'
51
+ 'drizzle-kit': '1.0.0-rc.4'
52
+ 'drizzle-orm': '1.0.0-rc.4'
46
53
 
47
54
  overrides:
48
- 'vite': 'catalog:'
55
+ 'vite@*': 'catalog:'
49
56
 
50
57
  peerDependencyRules:
51
58
  allowAny:
@@ -54,4 +61,6 @@ peerDependencyRules:
54
61
  'vite': '*'
55
62
 
56
63
  allowBuilds:
64
+ 'better-sqlite3': true
57
65
  'esbuild': true
66
+ 'workerd': true
@@ -1,13 +1,36 @@
1
1
  {
2
2
  "$schema": "https://turbo.build/schema.json",
3
3
  "tasks": {
4
- "build": {
4
+ "dev": {
5
5
  "dependsOn": ["^build"],
6
- "outputs": ["dist/**", ".output/**"]
6
+ "cache": false,
7
+ "persistent": true
7
8
  },
8
- "dev": {
9
+ "dev:node": {
10
+ "dependsOn": ["^build"],
11
+ "env": ["DEPLOY_TARGET"],
12
+ "cache": false,
13
+ "persistent": true
14
+ },
15
+ "dev:cloudflare": {
16
+ "dependsOn": ["^build"],
17
+ "env": ["DEPLOY_TARGET"],
9
18
  "cache": false,
10
19
  "persistent": true
20
+ },
21
+ "build": {
22
+ "dependsOn": ["^build"],
23
+ "outputs": ["dist/**", ".output/**"]
24
+ },
25
+ "build:node": {
26
+ "dependsOn": ["^build"],
27
+ "env": ["DEPLOY_TARGET"],
28
+ "outputs": ["dist/**", ".output/**"]
29
+ },
30
+ "build:cloudflare": {
31
+ "dependsOn": ["^build"],
32
+ "env": ["DEPLOY_TARGET"],
33
+ "outputs": ["dist/**", ".output/**"]
11
34
  }
12
35
  }
13
36
  }
@@ -2,6 +2,7 @@ import { defineConfig } from 'vite-plus'
2
2
  import { lintConfig, fmtConfig } from '@oyolincc/dev-config'
3
3
 
4
4
  export default defineConfig({
5
+ create: { defaultTemplate: '@oyolincc' },
5
6
  staged: {
6
7
  '*': 'vp check --fix',
7
8
  },
@@ -18,8 +18,5 @@
18
18
  "type": "node"
19
19
  }
20
20
  ],
21
- // Use IntelliSense to learn about possible attributes.
22
- // Hover to view descriptions of existing attributes.
23
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
24
21
  "version": "0.2.0"
25
22
  }
@@ -20,5 +20,7 @@
20
20
  "editor.codeActionsOnSave": {
21
21
  "source.fixAll.oxc": "explicit"
22
22
  },
23
- "oxc.enable.oxlint": false
23
+ "oxc.enable.oxlint": false,
24
+ "oxc.disableNestedConfig": true,
25
+ "oxc.fmt.disableNestedConfig": true
24
26
  }
@@ -10,6 +10,13 @@ Docs are local at `node_modules/vite-plus/docs` or online at https://viteplus.de
10
10
 
11
11
  `vp <name>` runs a built-in command. `vp run <name>` runs a `package.json` script or a `vite.config.ts` task. Scripts cannot overwrite built-ins, so `vp dev` and `vp run dev` may do different things. Check `package.json` and `vite.config.ts` first, and run `vp run <name>` when the project defines a script or task with that name.
12
12
 
13
+ ## Tool Versions
14
+
15
+ Run `vp toolchain` to show versions and relationships in the active Vite+
16
+ release. Add a tool name to select part of the graph. For example, run
17
+ `vp toolchain vite`. Use `--global` to ignore the local `vite-plus` package. Use
18
+ `vp why <package>` to show the package-manager dependency graph.
19
+
13
20
  ## Review Checklist
14
21
 
15
22
  - [ ] Run `vp install` after pulling remote changes and before getting started.
@@ -10,6 +10,7 @@ lerna-debug.log*
10
10
  node_modules
11
11
  dist
12
12
  dist-ssr
13
+ .output
13
14
  *.local
14
15
 
15
16
  # Editor directories and files
@@ -28,3 +29,6 @@ dist-ssr
28
29
  .worktrees/
29
30
  **/temp/
30
31
  .turbo
32
+ .wrangler
33
+ .dev.vars
34
+ db-data
@@ -7,6 +7,7 @@ catalogPrune: true
7
7
  catalog:
8
8
  '@changesets/changelog-github': '0.5.0'
9
9
  '@changesets/cli': '2.27.12'
10
+ '@cloudflare/vite-plugin': '1.62.5'
10
11
  '@oyolincc/cli': '2.1.3'
11
12
  '@oyolincc/dev-config': '0.1.1'
12
13
  '@oyolincc/env-loader': '^0.2.0'
@@ -16,11 +17,12 @@ catalog:
16
17
  'tsx': '4.21.0'
17
18
  'turbo': '^2.9.14'
18
19
  'typescript': '7.0.2'
19
- 'vite': 'npm:@voidzero-dev/vite-plus-core@0.2.8'
20
- 'vite-plus': '0.2.8'
20
+ 'vite': 'npm:@voidzero-dev/vite-plus-core@0.3.1'
21
+ 'vite-plus': '0.3.1'
22
+ 'wrangler': '4.147.0'
21
23
 
22
24
  overrides:
23
- 'vite': 'catalog:'
25
+ 'vite@*': 'catalog:'
24
26
 
25
27
  peerDependencyRules:
26
28
  allowAny:
@@ -30,3 +32,4 @@ peerDependencyRules:
30
32
 
31
33
  allowBuilds:
32
34
  'esbuild': true
35
+ 'workerd': true