-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
127 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,42 @@ | ||
export const PROMPT = ` | ||
Your job is to ONLY return a block of Javascript code for a Cloudflare worker. | ||
You will receive a database schema as a SQL statement to know what tables and columns exist in case you need to interact with the database. | ||
You will also receive an object that describes what this Cloudflare worker does. | ||
Your job is to understand the object and write a Cloudflare worker that accomplishes the desired task. | ||
An expected output would be something like the following: | ||
\`\`\` | ||
export default { | ||
async fetch(request, env, ctx) { | ||
const url = "https://jsonplaceholder.typicode.com/todos/1"; | ||
// gatherResponse returns both content-type & response body as a string | ||
async function gatherResponse(response) { | ||
const { headers } = response; | ||
const contentType = headers.get("content-type") || ""; | ||
if (contentType.includes("application/json")) { | ||
return { contentType, result: JSON.stringify(await response.json()) }; | ||
} | ||
return { contentType, result: response.text() }; | ||
} | ||
const response = await fetch(url); | ||
const { contentType, result } = await gatherResponse(response); | ||
const options = { headers: { "content-type": contentType } }; | ||
return new Response(result, options); | ||
} | ||
}; | ||
\`\`\` | ||
*Rules:* | ||
- Do not return a guide or directions on how to implement it. | ||
- Only return a block of Javascript code! | ||
- The code block should be able to be deployed to Cloudflare Workers. | ||
- Do not return any code on how to setup the database, your only concern is to make Javascript code for this Cloudflare worker. | ||
- If you need to interact with the database you can do so by doing "sdk.query()" and passing in the SQL query you need to run. | ||
Important: Only respond with a single block of Javascript code, nothing else. | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,14 @@ | ||
import { AbstractDialect, ColumnDataType } from '../index'; | ||
import { QueryBuilder } from '../../client'; | ||
import { QueryType } from '../../query-params'; | ||
|
||
export class MySQLDialect extends AbstractDialect { | ||
mapDataType(dataType: ColumnDataType): string { | ||
switch (dataType.toLowerCase()) { | ||
case ColumnDataType.STRING: | ||
return 'VARCHAR(255)'; // MySQL specific VARCHAR length | ||
return 'VARCHAR(255)'; | ||
case ColumnDataType.BOOLEAN: | ||
return 'TINYINT(1)'; // MySQL uses TINYINT for boolean | ||
return 'TINYINT(1)'; | ||
default: | ||
return super.mapDataType(dataType); | ||
} | ||
} | ||
|
||
// select(builder: QueryBuilder, type: QueryType): string { | ||
// return `SELECT MYSQL` | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters