From 96f630f69d7749ed357815e21582667ef7a45a50 Mon Sep 17 00:00:00 2001 From: shiyuhang <1136742008@qq.com> Date: Tue, 26 Dec 2023 11:35:43 +0800 Subject: [PATCH] fix lint --- documentation/en/Cloudflare-Workers.md | 36 ++++++++++++-------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/documentation/en/Cloudflare-Workers.md b/documentation/en/Cloudflare-Workers.md index b74cb3da2c..3b564898fd 100644 --- a/documentation/en/Cloudflare-Workers.md +++ b/documentation/en/Cloudflare-Workers.md @@ -54,8 +54,12 @@ Develop your code in the `src/index.ts`. Here are some examples: 1. local mysql example ```ts + import { createConnection } from 'mysql2'; + async function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } export default { async fetch( request: Request, @@ -84,17 +88,16 @@ Develop your code in the `src/index.ts`. Here are some examples: return new Response(JSON.stringify(result)) }, }; - - async function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); - } ``` 2. TiDB Serverless example with TLS: - ```js + ```ts import { createConnection } from 'mysql2'; + async function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } export default { async fetch( request: Request, @@ -128,17 +131,17 @@ Develop your code in the `src/index.ts`. Here are some examples: return new Response(JSON.stringify(result)) }, }; - - async function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); - } ``` 3. PlanetScale example with TLS: - ```js + ```ts import { createConnection } from 'mysql2'; + async function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + export default { async fetch( request: Request, @@ -172,10 +175,6 @@ Develop your code in the `src/index.ts`. Here are some examples: return new Response(JSON.stringify(result)) }, }; - - async function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); - } ``` ## Step 4: Test locally @@ -231,8 +230,11 @@ If you want to develop the corresponding feature. Here is a simaple example of t 4. write your test code inside worker.js - ``` + ```js const { createConnection } = require('../index'); + async function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } export default { async fetch(request, env, ctx) { let result @@ -257,10 +259,6 @@ If you want to develop the corresponding feature. Here is a simaple example of t return new Response(JSON.stringify(result)) } }; - - async function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); - } ``` 5. Test locally