You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hyperdrive accelerates access to your existing databases from Cloudflare Workers, making even single-region databases feel globally distributed.
11
11
@@ -43,7 +43,7 @@ If you want to skip the steps and get started quickly, click on the button below
43
43
44
44
**MySQL deployment**
45
45
46
-
[](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/hyperdrive-get-started/hyperdrive/hyperdrive-get-started-mysql)
46
+
[](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/templates/tree/main/mysql-hyperdrive-template)
47
47
48
48
</TabItem>
49
49
</Tabs>
@@ -241,7 +241,8 @@ The `index.ts` file is where you configure your Worker's interactions with Hyper
241
241
242
242
Populate your `index.ts` file with the following code:
243
243
244
-
```typescript
244
+
<TypeScriptExample>
245
+
```ts
245
246
// Postgres.js 3.4.5 or later is recommended
246
247
importpostgresfrom"postgres";
247
248
@@ -284,6 +285,7 @@ export default {
284
285
},
285
286
} satisfiesExportedHandler<Env>;
286
287
```
288
+
</TypeScriptExample>
287
289
288
290
Upon receiving a request, the code above does the following:
289
291
@@ -301,7 +303,8 @@ The `index.ts` file is where you configure your Worker's interactions with Hyper
301
303
302
304
Populate your `index.ts` file with the following code:
303
305
304
-
```typescript
306
+
<TypeScriptExample>
307
+
```ts
305
308
// mysql2 v3.13.0 or later is required
306
309
import { createConnection } from'mysql2/promise';
307
310
@@ -321,7 +324,7 @@ export default {
321
324
user: env.HYPERDRIVE.user,
322
325
password: env.HYPERDRIVE.password,
323
326
database: env.HYPERDRIVE.database,
324
-
port: env.HYPERDRIVE.port
327
+
port: env.HYPERDRIVE.port,
325
328
326
329
// The following line is needed for mysql2 compatibility with Workers
327
330
// mysql2 uses eval() to optimize result parsing for rows with > 100 columns
@@ -358,6 +361,7 @@ export default {
358
361
} satisfiesExportedHandler<Env>;
359
362
360
363
```
364
+
</TypeScriptExample>
361
365
362
366
Upon receiving a request, the code above does the following:
0 commit comments