Skip to content

Commit 461900b

Browse files
committed
Hyperdrive is fixed (I think) so I'm reenabling it
1 parent 2b0dfcc commit 461900b

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "labelzoom-cf-api-proxy",
33
"description": "A Cloudflare Worker that serves as a reverse proxy for LabelZoom's public REST API",
4-
"version": "1.2.3",
4+
"version": "1.2.4",
55
"private": true,
66
"dependencies": {
77
"hono": "4.8.9",

src/worker/index.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { every } from "hono/combine";
1111
import { hyperdriveMysql } from "./middleware/hyperdrive-mysql";
1212
import { bearerAuth } from "hono/bearer-auth";
1313
import { logger } from "hono/logger";
14-
import { VERIFY_LICENSE_SQL } from "./constants";
14+
import { GET_LATEST_VERSION_SQL, VERIFY_LICENSE_SQL } from "./constants";
1515

1616
async function verifyTokenAndLicense(token: string, c: Context) {
1717
const db = c.get('db');
@@ -90,23 +90,22 @@ app.use("/api/v2/convert/:sourceFormat/to/:targetFormat", (c, next) => {
9090
//#endregion
9191

9292
//#region Download redirects
93-
// TODO: Disabled temporarily until I figure out why Hyperdrive is broken
94-
// app.use("/download/*", (c, next) => {
95-
// return hyperdriveMysql({
96-
// config: c.env.DB,
97-
// })(c, next);
98-
// });
99-
// app.get("/download/:version/:packageName", async (c) => {
100-
// let { version, packageName } = c.req.param();
101-
// if (version === 'latest') {
102-
// const db = c.get('db');
103-
// if (!db) throw new Error('download controller must be used with (and sequenced after) the hyperdrive middleware');
104-
// const [results] = await db.query(GET_LATEST_VERSION_SQL);
105-
// const rows = results as mysql.RowDataPacket[];
106-
// version = `${rows[0].major}.${rows[0].minor}.${rows[0].revision}`;
107-
// }
108-
// return c.redirect(`${c.env.S3_BUCKET}/${version}/${packageName}`);
109-
// });
93+
app.use("/download/*", (c, next) => {
94+
return hyperdriveMysql({
95+
config: c.env.DB,
96+
})(c, next);
97+
});
98+
app.get("/download/:version/:packageName", async (c) => {
99+
let { version, packageName } = c.req.param();
100+
if (version === 'latest') {
101+
const db = c.get('db');
102+
if (!db) throw new Error('download controller must be used with (and sequenced after) the hyperdrive middleware');
103+
const [results] = await db.query(GET_LATEST_VERSION_SQL);
104+
const rows = results as mysql.RowDataPacket[];
105+
version = `${rows[0].major}.${rows[0].minor}.${rows[0].revision}`;
106+
}
107+
return c.redirect(`${c.env.S3_BUCKET}/${version}/${packageName}`);
108+
});
110109
//#endregion
111110

112111
//#region All other requests

wrangler.jsonc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"hyperdrive": [
4343
{
4444
"binding": "DB",
45-
"id": "acbb74fcce674bb1920028d49c46b58f",
45+
"id": "68c40b656bce4b29ae0ed0bd2f309865",
4646
"localConnectionString": "mysql://lz_hyperdrive:Uid4lDiH5pltxYBFFNqe@ubuntu-database.internal.robfaust.com:3306/lz_spring"
4747
}
4848
],
@@ -133,7 +133,7 @@
133133
"hyperdrive": [
134134
{
135135
"binding": "DB",
136-
"id": "acbb74fcce674bb1920028d49c46b58f",
136+
"id": "68c40b656bce4b29ae0ed0bd2f309865",
137137
"localConnectionString": "mysql://lz_hyperdrive:Uid4lDiH5pltxYBFFNqe@ubuntu-database.internal.robfaust.com:3306/lz_spring"
138138
}
139139
],
@@ -176,7 +176,7 @@
176176
"hyperdrive": [
177177
{
178178
"binding": "DB",
179-
"id": "acbb74fcce674bb1920028d49c46b58f",
179+
"id": "68c40b656bce4b29ae0ed0bd2f309865",
180180
"localConnectionString": "mysql://lz_hyperdrive:Uid4lDiH5pltxYBFFNqe@ubuntu-database.internal.robfaust.com:3306/lz_spring"
181181
}
182182
],
@@ -219,7 +219,7 @@
219219
"hyperdrive": [
220220
{
221221
"binding": "DB",
222-
"id": "acbb74fcce674bb1920028d49c46b58f",
222+
"id": "68c40b656bce4b29ae0ed0bd2f309865",
223223
"localConnectionString": "mysql://lz_hyperdrive:Uid4lDiH5pltxYBFFNqe@ubuntu-database.internal.robfaust.com:3306/lz_spring"
224224
}
225225
],

0 commit comments

Comments
 (0)