diff --git a/package.json b/package.json index 2f4bd8c..0417ae8 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/http/routes/index.ts b/src/http/routes/index.ts index 672749c..97984ac 100644 --- a/src/http/routes/index.ts +++ b/src/http/routes/index.ts @@ -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(); diff --git a/wrangler.toml b/wrangler.toml index 343d071..14ab344 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -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"