Jonas
Jonas
Explore posts from servers
DTDrizzle Team
Created by Jonas on 8/24/2024 in #help
How do I dynamically insert multiple encrypted values?
const encryptedEmails = emails.map(email => encryptColumn(email));

const fetchedUsers = await db
.select({
id: neptun_user.id,
})
.from(neptun_user)
/* @ts-ignore */
.where(inArray(neptun_user.primary_email, encryptedEmails))
.catch((err) => {
if (LOG_BACKEND) console.error('Failed to fetch user from database', err);
return null;
})
const encryptedEmails = emails.map(email => encryptColumn(email));

const fetchedUsers = await db
.select({
id: neptun_user.id,
})
.from(neptun_user)
/* @ts-ignore */
.where(inArray(neptun_user.primary_email, encryptedEmails))
.catch((err) => {
if (LOG_BACKEND) console.error('Failed to fetch user from database', err);
return null;
})
7 replies
NNuxt
Created by Jonas on 7/11/2024 in #❓・help
nuxt-auth-utils^0.1.0: Cannot find package 'nitropack'
I am not sure why I am getting this error now. It worked fine for a few hours.
[02:10:37] WARN [plugin node-resolve] Could not resolve import "nitropack/runtime" in A:\xxx\node_modules\.pnpm\nuxt-auth-utils@0.1.0_magicast@0.3.4_rollup@4.18.1\node_modules\nuxt-auth-utils\dist\runtime\server\plugins\oauth.js using exports defined in A:\xxx\node_modules\.pnpm\nitropack@2.7.2_ioredis@5.4.1_magicast@0.3.4\node_modules\nitropack\package.json.

[02:10:38] WARN [plugin node-resolve] Could not resolve import "nitropack/runtime" in A:\xxx\node_modules\.pnpm\nuxt-auth-utils@0.1.0_magicast@0.3.4_rollup@4.18.1\node_modules\nuxt-auth-utils\dist\runtime\server\plugins\oauth.js using exports defined in A:\xxx\node_modules\.pnpm\nitropack@2.7.2_ioredis@5.4.1_magicast@0.3.4\node_modules\nitropack\package.json.

[02:10:38] WARN "nitropack/runtime" is imported by "node_modules/.pnpm/nuxt-auth-utils@0.1.0_magicast@0.3.4_rollup@4.18.1/node_modules/nuxt-auth-utils/dist/runtime/server/plugins/oauth.js", but could not be resolved – treating it as an external dependency.

[worker reload] [worker init] Cannot find package 'nitropack' imported from A:\xxx\.nuxt\dev\index.mjs 02:13:16

at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
at new NodeError (node:internal/errors:405:5)
at packageResolve (node:internal/modules/esm/resolve:916:9)
at moduleResolve (node:internal/modules/esm/resolve:973:20)
at defaultResolve (node:internal/modules/esm/resolve:1193:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:403:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:372:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:249:38)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:39)
at link (node:internal/modules/esm/module_job:75:36)
[02:10:37] WARN [plugin node-resolve] Could not resolve import "nitropack/runtime" in A:\xxx\node_modules\.pnpm\nuxt-auth-utils@0.1.0_magicast@0.3.4_rollup@4.18.1\node_modules\nuxt-auth-utils\dist\runtime\server\plugins\oauth.js using exports defined in A:\xxx\node_modules\.pnpm\nitropack@2.7.2_ioredis@5.4.1_magicast@0.3.4\node_modules\nitropack\package.json.

[02:10:38] WARN [plugin node-resolve] Could not resolve import "nitropack/runtime" in A:\xxx\node_modules\.pnpm\nuxt-auth-utils@0.1.0_magicast@0.3.4_rollup@4.18.1\node_modules\nuxt-auth-utils\dist\runtime\server\plugins\oauth.js using exports defined in A:\xxx\node_modules\.pnpm\nitropack@2.7.2_ioredis@5.4.1_magicast@0.3.4\node_modules\nitropack\package.json.

[02:10:38] WARN "nitropack/runtime" is imported by "node_modules/.pnpm/nuxt-auth-utils@0.1.0_magicast@0.3.4_rollup@4.18.1/node_modules/nuxt-auth-utils/dist/runtime/server/plugins/oauth.js", but could not be resolved – treating it as an external dependency.

[worker reload] [worker init] Cannot find package 'nitropack' imported from A:\xxx\.nuxt\dev\index.mjs 02:13:16

at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
at new NodeError (node:internal/errors:405:5)
at packageResolve (node:internal/modules/esm/resolve:916:9)
at moduleResolve (node:internal/modules/esm/resolve:973:20)
at defaultResolve (node:internal/modules/esm/resolve:1193:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:403:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:372:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:249:38)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:39)
at link (node:internal/modules/esm/module_job:75:36)
I tried installing nitropack as a dev dependency, but that didn't fix it.
8 replies
NNuxt
Created by Jonas on 7/10/2024 in #❓・help
@ai-sdk/vue: How do I react to an error I catch inside `/api` in .vue file?
I am both new to vue and nuxt. How and where do I react to that error, i sent from the api endpoint now? I want to create a new toast message in the frontend on error. This is my code at /api/chat:
import { StreamingTextResponse, streamText } from 'ai';
import { createOpenAI } from '@ai-sdk/openai';

export default defineLazyEventHandler(async () => {
const apiKey = useRuntimeConfig().openaiApiKey;
if (!apiKey) throw new Error('Missing OpenAI API key');

const openai = createOpenAI({
apiKey: apiKey,
});

return defineEventHandler(async (event: any) => {
const { messages } = await readBody(event);

try {
const result = await streamText({
model: openai('gpt-4-turbo'),
messages,
});

return new StreamingTextResponse(result.toAIStream());
} catch (error) {
console.error("AI request errored:", error);
sendError(event, createError({ statusCode: 500, statusMessage: 'Internal Server Error', message: 'AI request errored' }));
}
});
});
import { StreamingTextResponse, streamText } from 'ai';
import { createOpenAI } from '@ai-sdk/openai';

export default defineLazyEventHandler(async () => {
const apiKey = useRuntimeConfig().openaiApiKey;
if (!apiKey) throw new Error('Missing OpenAI API key');

const openai = createOpenAI({
apiKey: apiKey,
});

return defineEventHandler(async (event: any) => {
const { messages } = await readBody(event);

try {
const result = await streamText({
model: openai('gpt-4-turbo'),
messages,
});

return new StreamingTextResponse(result.toAIStream());
} catch (error) {
console.error("AI request errored:", error);
sendError(event, createError({ statusCode: 500, statusMessage: 'Internal Server Error', message: 'AI request errored' }));
}
});
});
How I interact in the frontend:
const { messages, input, handleSubmit, isLoading } = useChat()
const { messages, input, handleSubmit, isLoading } = useChat()
1 replies
DTDrizzle Team
Created by Jonas on 2/29/2024 in #help
ClientAuthentication Error using heroku-postgres
What do I have to do? This one is a heroku-postgres database (actually aws), it worked using a vercel-postgres database.
xxx\node_modules\drizzle-kit\bin.cjs:23472
const message = name === "notice" ? new messages_1.NoticeMessage(length, messageValue) : new messages_1.DatabaseError(messageValue, length, name);

error: no pg_hba.conf entry for host "xxx", user "xxx", database "xxx", no encryption
at Parser.parseErrorMessage (xxx\node_modules\drizzle-kit\bin.cjs:23472:98)
at Parser.handlePacket (xxx\node_modules\drizzle-kit\bin.cjs:23313:25)
at Parser.parse (xxx\node_modules\drizzle-kit\bin.cjs:23237:34)
at Socket.<anonymous> (xxx\node_modules\drizzle-kit\bin.cjs:23513:44)
at Socket.emit (node:events:517:28)
at addChunk (node:internal/streams/readable:368:12)
at readableAddChunk (node:internal/streams/readable:341:9)
at Readable.push (node:internal/streams/readable:278:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
at TCP.callbackTrampoline (node:internal/async_hooks:128:17) {
length: 175,
severity: 'FATAL',
code: '28000',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'auth.c',
line: '536',
routine: 'ClientAuthentication'
}

Node.js v18.19.0
xxx\node_modules\drizzle-kit\bin.cjs:23472
const message = name === "notice" ? new messages_1.NoticeMessage(length, messageValue) : new messages_1.DatabaseError(messageValue, length, name);

error: no pg_hba.conf entry for host "xxx", user "xxx", database "xxx", no encryption
at Parser.parseErrorMessage (xxx\node_modules\drizzle-kit\bin.cjs:23472:98)
at Parser.handlePacket (xxx\node_modules\drizzle-kit\bin.cjs:23313:25)
at Parser.parse (xxx\node_modules\drizzle-kit\bin.cjs:23237:34)
at Socket.<anonymous> (xxx\node_modules\drizzle-kit\bin.cjs:23513:44)
at Socket.emit (node:events:517:28)
at addChunk (node:internal/streams/readable:368:12)
at readableAddChunk (node:internal/streams/readable:341:9)
at Readable.push (node:internal/streams/readable:278:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
at TCP.callbackTrampoline (node:internal/async_hooks:128:17) {
length: 175,
severity: 'FATAL',
code: '28000',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'auth.c',
line: '536',
routine: 'ClientAuthentication'
}

Node.js v18.19.0
10 replies