Skip to content

Commit

Permalink
fix: response body and db config
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianLThomas committed Apr 7, 2024
1 parent d3fdeda commit 70223b0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
"deploy": "wrangler deploy",
"dev": "wrangler dev",
"start": "wrangler dev",
"db:query": "npx wrangler d1 execute url-shortener --local --command='SELECT * FROM urls'",
"db:init": "npx wrangler d1 execute url-shortener --local --file=./drizzle/0000_handy_bishop.sql",
"db:query:local": "npx wrangler d1 execute urls --local --command='SELECT * FROM urls'",
"db:query:remote": "npx wrangler d1 execute urls --local --command='SELECT * FROM urls'",
"db:init:local": "npx wrangler d1 execute urls --remote --file=./drizzle/0000_handy_bishop.sql",
"db:init:remote": "npx wrangler d1 execute urls --remote --file=./drizzle/0000_handy_bishop.sql",
"db:generate": "drizzle-kit generate:sqlite --schema=src/db/schema.ts",
"test": "npx jest --runInBand",
"test:unit": "jest --runInBand **/*.spec.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/http/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default async (request: Request, db: DrizzleD1Database) => {
.onConflictDoNothing()
.run();

return Response.json({ shortUrl: `${request.headers.get('host')}/api/redirect?url=${shortUrlToken}` });
return Response.json({ shortUrl: `${request.headers.get('host')}/api/redirect?token=${shortUrlToken}` });
}
default:
return NOT_FOUND();
Expand Down
4 changes: 2 additions & 2 deletions wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ route = { pattern = "api.adrian-thomas.com", custom_domain = true }

[[d1_databases]]
binding = "DB" # i.e. available in your Worker on env.DB
database_name = "url-shortener"
database_id = "99821c73-c638-413e-bc5d-a1364429ff68"
database_name = "urls"
database_id = "dd665acd-330d-4087-b014-d0630ab98576"

0 comments on commit 70223b0

Please sign in to comment.