Skip to content

Commit f5765be

Browse files
committed
fix db configs
1 parent fcadb8b commit f5765be

12 files changed

+154
-206
lines changed

.ignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
drizzle

service/.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DATABASE_URL=file:./local.db

service/.gitignore

+2-175
Original file line numberDiff line numberDiff line change
@@ -1,175 +1,2 @@
1-
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
2-
3-
# Logs
4-
5-
logs
6-
_.log
7-
npm-debug.log_
8-
yarn-debug.log*
9-
yarn-error.log*
10-
lerna-debug.log*
11-
.pnpm-debug.log*
12-
13-
# Caches
14-
15-
.cache
16-
17-
# Diagnostic reports (https://nodejs.org/api/report.html)
18-
19-
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
20-
21-
# Runtime data
22-
23-
pids
24-
_.pid
25-
_.seed
26-
*.pid.lock
27-
28-
# Directory for instrumented libs generated by jscoverage/JSCover
29-
30-
lib-cov
31-
32-
# Coverage directory used by tools like istanbul
33-
34-
coverage
35-
*.lcov
36-
37-
# nyc test coverage
38-
39-
.nyc_output
40-
41-
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
42-
43-
.grunt
44-
45-
# Bower dependency directory (https://bower.io/)
46-
47-
bower_components
48-
49-
# node-waf configuration
50-
51-
.lock-wscript
52-
53-
# Compiled binary addons (https://nodejs.org/api/addons.html)
54-
55-
build/Release
56-
57-
# Dependency directories
58-
59-
node_modules/
60-
jspm_packages/
61-
62-
# Snowpack dependency directory (https://snowpack.dev/)
63-
64-
web_modules/
65-
66-
# TypeScript cache
67-
68-
*.tsbuildinfo
69-
70-
# Optional npm cache directory
71-
72-
.npm
73-
74-
# Optional eslint cache
75-
76-
.eslintcache
77-
78-
# Optional stylelint cache
79-
80-
.stylelintcache
81-
82-
# Microbundle cache
83-
84-
.rpt2_cache/
85-
.rts2_cache_cjs/
86-
.rts2_cache_es/
87-
.rts2_cache_umd/
88-
89-
# Optional REPL history
90-
91-
.node_repl_history
92-
93-
# Output of 'npm pack'
94-
95-
*.tgz
96-
97-
# Yarn Integrity file
98-
99-
.yarn-integrity
100-
101-
# dotenv environment variable files
102-
103-
.env
104-
.env.development.local
105-
.env.test.local
106-
.env.production.local
107-
.env.local
108-
109-
# parcel-bundler cache (https://parceljs.org/)
110-
111-
.parcel-cache
112-
113-
# Next.js build output
114-
115-
.next
116-
out
117-
118-
# Nuxt.js build / generate output
119-
120-
.nuxt
121-
dist
122-
123-
# Gatsby files
124-
125-
# Comment in the public line in if your project uses Gatsby and not Next.js
126-
127-
# https://nextjs.org/blog/next-9-1#public-directory-support
128-
129-
# public
130-
131-
# vuepress build output
132-
133-
.vuepress/dist
134-
135-
# vuepress v2.x temp and cache directory
136-
137-
.temp
138-
139-
# Docusaurus cache and generated files
140-
141-
.docusaurus
142-
143-
# Serverless directories
144-
145-
.serverless/
146-
147-
# FuseBox cache
148-
149-
.fusebox/
150-
151-
# DynamoDB Local files
152-
153-
.dynamodb/
154-
155-
# TernJS port file
156-
157-
.tern-port
158-
159-
# Stores VSCode versions used for testing VSCode extensions
160-
161-
.vscode-test
162-
163-
# yarn v2
164-
165-
.yarn/cache
166-
.yarn/unplugged
167-
.yarn/build-state.yml
168-
.yarn/install-state.gz
169-
.pnp.*
170-
171-
# IntelliJ based IDEs
172-
.idea
173-
174-
# Finder (MacOS) folder config
175-
.DS_Store
1+
/local.db
2+
/node_modules

service/bun.lock

+119
Large diffs are not rendered by default.
File renamed without changes.

service/db/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { drizzle } from "drizzle-orm/libsql";
2+
export const db = drizzle(process.env.DATABASE_URL ?? "./local.db");
File renamed without changes.

service/drizzle.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineConfig } from "drizzle-kit";
22
if (!process.env.DATABASE_URL) throw new Error("DATABASE_URL is not set");
33

44
export default defineConfig({
5-
schema: "./src/lib/server/db/schema.ts",
5+
schema: "./db/schema.ts",
66

77
dbCredentials: {
88
url: process.env.DATABASE_URL,

service/index.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
export { type App, app } from "./src/app.ts";
1+
// is there really no other way to do this?
2+
import { init as _init } from "./src/app.ts";
3+
4+
export const init = _init;
5+
export type App = ReturnType<typeof _init>;

service/package.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,21 @@
66
"db:push": "drizzle-kit push",
77
"db:migrate": "drizzle-kit migrate",
88
"db:studio": "drizzle-kit studio",
9-
"dev": "bun run --watch ./surfaces/bun.ts"
9+
"dev": "bun run --watch ./cmd/dev.ts"
1010
},
1111
"devDependencies": {
1212
"@cloudflare/workers-types": "^4.20250124.3",
13-
"@types/bun": "latest"
13+
"@types/bun": "latest",
14+
"drizzle-kit": "^0.30.2"
1415
},
1516
"peerDependencies": {
1617
"typescript": "^5.7.3"
1718
},
1819
"dependencies": {
19-
"hono": "^4.6.19",
20-
"zod": "^3.24.1",
21-
"drizzle-orm": "^0.38.4",
2220
"@hono/zod-validator": "^0.4.2",
23-
"@libsql/client": "^0.14.0"
21+
"@libsql/client": "^0.14.0",
22+
"drizzle-orm": "^0.38.4",
23+
"hono": "^4.6.19",
24+
"zod": "^3.24.1"
2425
}
2526
}

service/src/app.ts

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import { zValidator } from "@hono/zod-validator";
2+
import type { LibSQLDatabase } from "drizzle-orm/libsql";
23
import { Hono } from "hono";
34
import { z } from "zod";
45

5-
export const app = new Hono().post(
6-
"/",
7-
zValidator(
8-
"json",
9-
z.object({
10-
name: z.string(),
11-
}),
12-
),
13-
(c) => {
14-
const name = c.req.valid("json").name;
15-
return c.text(`Hello ${name}!`);
16-
},
17-
);
18-
19-
export type App = typeof app;
6+
export function init(_db: LibSQLDatabase) {
7+
return new Hono().post(
8+
"/",
9+
zValidator(
10+
"json",
11+
z.object({
12+
name: z.string(),
13+
}),
14+
),
15+
(c) => {
16+
const name = c.req.valid("json").name;
17+
return c.text(`Hello ${name}!`);
18+
},
19+
);
20+
}

service/src/db/index.ts

-8
This file was deleted.

0 commit comments

Comments
 (0)