From 17d5dada8e601944863eb14a3462fc0b6fed43af Mon Sep 17 00:00:00 2001 From: samir paudyal <75193555+samir-byte@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:39:38 +0545 Subject: [PATCH] perf: inline return promise (#121) --- frontend/actions/generate-user-stripe.ts | 2 +- .../blog/en/decrypt-verify-authjs-jwt-token.mdx | 2 +- .../blog/en/memfree-build-4-bun-gpt-4o-stream.mdx | 2 +- .../blog/zh/decrypt-verify-authjs-jwt-token.mdx | 2 +- .../blog/zh/memfree-build-4-bun-gpt-4o-stream.mdx | 2 +- frontend/lib/tools/auto.ts | 2 +- frontend/lib/tools/hacker-news.ts | 2 +- vector/auth.ts | 2 +- vector/db.ts | 12 ++++++------ 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/frontend/actions/generate-user-stripe.ts b/frontend/actions/generate-user-stripe.ts index 0706b807..14a4890b 100644 --- a/frontend/actions/generate-user-stripe.ts +++ b/frontend/actions/generate-user-stripe.ts @@ -16,7 +16,7 @@ export type responseAction = { const billingUrl = absoluteUrl('/pricing'); async function createStripeSession(priceId, locale, session, params) { - return await stripe.checkout.sessions.create({ + return stripe.checkout.sessions.create({ success_url: billingUrl, cancel_url: billingUrl, billing_address_collection: 'auto', diff --git a/frontend/content/blog/en/decrypt-verify-authjs-jwt-token.mdx b/frontend/content/blog/en/decrypt-verify-authjs-jwt-token.mdx index 6481079f..7b41400b 100644 --- a/frontend/content/blog/en/decrypt-verify-authjs-jwt-token.mdx +++ b/frontend/content/blog/en/decrypt-verify-authjs-jwt-token.mdx @@ -53,7 +53,7 @@ So, I checked the source code of auth.js and found that it uses the jose library ```ts async function getDerivedEncryptionKey(enc: string, keyMaterial: Parameters[1], salt: Parameters[2]) { const length = enc === 'A256CBC-HS512' ? 64 : 32; - return await hkdf('sha256', keyMaterial, salt, `Auth.js Generated Encryption Key (${salt})`, length); + return hkdf('sha256', keyMaterial, salt, `Auth.js Generated Encryption Key (${salt})`, length); } ``` diff --git a/frontend/content/blog/en/memfree-build-4-bun-gpt-4o-stream.mdx b/frontend/content/blog/en/memfree-build-4-bun-gpt-4o-stream.mdx index f251c1b0..35ad3584 100644 --- a/frontend/content/blog/en/memfree-build-4-bun-gpt-4o-stream.mdx +++ b/frontend/content/blog/en/memfree-build-4-bun-gpt-4o-stream.mdx @@ -72,7 +72,7 @@ const openai = new OpenAI({ async function readImageFile(filePath: string) { const baseDir = dirname(fileURLToPath(import.meta.url)); - return await readFile(join(baseDir, filePath)); + return readFile(join(baseDir, filePath)); } export async function chatImage() { diff --git a/frontend/content/blog/zh/decrypt-verify-authjs-jwt-token.mdx b/frontend/content/blog/zh/decrypt-verify-authjs-jwt-token.mdx index 819084dd..fd0b9456 100644 --- a/frontend/content/blog/zh/decrypt-verify-authjs-jwt-token.mdx +++ b/frontend/content/blog/zh/decrypt-verify-authjs-jwt-token.mdx @@ -53,7 +53,7 @@ export const getAuthToken = async () => { ```ts async function getDerivedEncryptionKey(enc: string, keyMaterial: Parameters[1], salt: Parameters[2]) { const length = enc === 'A256CBC-HS512' ? 64 : 32; - return await hkdf('sha256', keyMaterial, salt, `Auth.js 生成的加密密钥 (${salt})`, length); + return hkdf('sha256', keyMaterial, salt, `Auth.js 生成的加密密钥 (${salt})`, length); } ``` diff --git a/frontend/content/blog/zh/memfree-build-4-bun-gpt-4o-stream.mdx b/frontend/content/blog/zh/memfree-build-4-bun-gpt-4o-stream.mdx index 1074bd8a..e0f3dc83 100644 --- a/frontend/content/blog/zh/memfree-build-4-bun-gpt-4o-stream.mdx +++ b/frontend/content/blog/zh/memfree-build-4-bun-gpt-4o-stream.mdx @@ -72,7 +72,7 @@ const openai = new OpenAI({ async function readImageFile(filePath: string) { const baseDir = dirname(fileURLToPath(import.meta.url)); - return await readFile(join(baseDir, filePath)); + return readFile(join(baseDir, filePath)); } export async function chatImage() { diff --git a/frontend/lib/tools/auto.ts b/frontend/lib/tools/auto.ts index 2a886e30..3a164a0e 100644 --- a/frontend/lib/tools/auto.ts +++ b/frontend/lib/tools/auto.ts @@ -58,7 +58,7 @@ export async function autoAnswer( url: z.string().describe('the url to access'), }), execute: async ({ url }) => { - return await accessWebPage(url, onStream); + return accessWebPage(url, onStream); }, }), }, diff --git a/frontend/lib/tools/hacker-news.ts b/frontend/lib/tools/hacker-news.ts index 1d64cf27..9fe2999d 100644 --- a/frontend/lib/tools/hacker-news.ts +++ b/frontend/lib/tools/hacker-news.ts @@ -24,7 +24,7 @@ export async function get_top_stories(limit: number, onStream?: (...args: any[]) export async function get_story(id: number) { const response = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`); - return await response.json(); + return response.json(); } export async function get_story_with_comments(id: number) { diff --git a/vector/auth.ts b/vector/auth.ts index 72d6947a..52493dc5 100644 --- a/vector/auth.ts +++ b/vector/auth.ts @@ -47,7 +47,7 @@ async function getDerivedEncryptionKey( salt: Parameters[2] ) { const length = enc === "A256CBC-HS512" ? 64 : 32; - return await hkdf( + return hkdf( "sha256", keyMaterial, salt, diff --git a/vector/db.ts b/vector/db.ts index 0e2bc8fb..3bbef01a 100644 --- a/vector/db.ts +++ b/vector/db.ts @@ -27,7 +27,7 @@ const schema = new Schema([ async function getConnection() { const bucket = process.env.AWS_BUCKET || ""; if (bucket) { - return await lancedb.connect(bucket, { + return lancedb.connect(bucket, { storageOptions: { awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID || "", s3Express: "true", @@ -38,15 +38,15 @@ async function getConnection() { } else { // Let open source users could one click deploy const localDirectory = process.cwd(); - return await lancedb.connect(localDirectory); + return lancedb.connect(localDirectory); } } async function getTable(db: any, tableName: string): Promise { if ((await db.tableNames()).includes(tableName)) { - return await db.openTable(tableName); + return db.openTable(tableName); } else { - return await db.createEmptyTable(tableName, schema); + return db.createEmptyTable(tableName, schema); } } @@ -151,12 +151,12 @@ export async function dropTable(tableName: string) { export async function createEmptyTable(tableName: string) { const db = await getConnection(); - return await db.createEmptyTable(tableName, schema); + return db.createEmptyTable(tableName, schema); } export async function reCreateEmptyTable(tableName: string) { const db = await getConnection(); - return await db.createEmptyTable(tableName, schema, { mode: "overwrite" }); + return db.createEmptyTable(tableName, schema, { mode: "overwrite" }); } export async function size(tableName: string) {