Titan
Titan
Explore posts from servers
DTDrizzle Team
Created by Titan on 11/4/2024 in #help
pgTable This overload is deprecated. Use the other method overload instead.
No description
4 replies
NNuxt
Created by Titan on 10/29/2024 in #❓・help
[solved] Vue app aliases are not allowed in server runtime
[nitro 09:24:56] ERROR RollupError: [plugin impound] Vue app aliases are not allowed in server runtime. [importing #build/nuxt.config.mjs from node_modules/nuxt/dist/app/nuxt.js]
[nitro 09:24:56] ERROR RollupError: [plugin impound] Vue app aliases are not allowed in server runtime. [importing #build/nuxt.config.mjs from node_modules/nuxt/dist/app/nuxt.js]
How do I go about debugging this error? I've been through all my server/ files and checked I'm not importing anything from the client or Vue based and the error doesn't give any more hints about where the problem is.
9 replies
NNuxt
Created by Titan on 10/29/2024 in #❓・help
[solved] Add excludes to server tsconfig
No description
5 replies
NNuxt
Created by Titan on 7/30/2024 in #❓・help
How to "mock" an H3 request with query string
I'm writing some unit tests for my "useValidatedQuery/useValidatedBody" functions that take a yup schema and validate the request. I've got this working fine for the body with: ✅ this works
it('returns the body if it is valid', async () => {
const testSchema = object({
email: string().email().required()
})

const h3BodyEvent = {
method: 'POST',
node: { req: { headers: [], body: { email: '[email protected]', foo: 'bar' } } }
}

const result = await useValidatedBody(testSchema, h3Event)

expect(result).toEqual({ email: '[email protected]', foo: 'bar' })
})
it('returns the body if it is valid', async () => {
const testSchema = object({
email: string().email().required()
})

const h3BodyEvent = {
method: 'POST',
node: { req: { headers: [], body: { email: '[email protected]', foo: 'bar' } } }
}

const result = await useValidatedBody(testSchema, h3Event)

expect(result).toEqual({ email: '[email protected]', foo: 'bar' })
})
However I cannot get it work with the query string, I just can't work out the shape of the event, I've tried it in all the below places and none of them seem to work: ❌ none of these work
const h3QueryEvent = {
method: 'GET',
queryString: 'email=bar', <-- doesn't work here
url: 'https://test.com/?email=bar', <-- doesn't work here
node: { req: { headers: [], queryString: 'email=bar', search: 'email=bar', url: { search: 'email=bar' } } }, <-- doesn't work here
web: { request: { url: 'https://test.com/?email=bar' }, url: 'https://test.com/?email=bar' } <-- doesn't work here
}
const h3QueryEvent = {
method: 'GET',
queryString: 'email=bar', <-- doesn't work here
url: 'https://test.com/?email=bar', <-- doesn't work here
node: { req: { headers: [], queryString: 'email=bar', search: 'email=bar', url: { search: 'email=bar' } } }, <-- doesn't work here
web: { request: { url: 'https://test.com/?email=bar' }, url: 'https://test.com/?email=bar' } <-- doesn't work here
}
The function it gets passed into is the H3 getQuery function: const query = getQuery(event) currently returning empty object
2 replies
DTDrizzle Team
Created by Titan on 6/28/2024 in #help
Multiple FROM support (word_similarity) fuzzy search
I'm trying to create this SQL:
SELECT *, similarity
FROM "app-user", word_similarity('test query', "fullName" || "email") as similarity
WHERE similarity > 0.3
ORDER BY similarity DESC
SELECT *, similarity
FROM "app-user", word_similarity('test query', "fullName" || "email") as similarity
WHERE similarity > 0.3
ORDER BY similarity DESC
Here's what I have, but Drizzle doesn't like the sql${user}: Your "id" field references a column "app-user"."id", but the table "app-user" is not part of the query! Did you forget to join it?
const columnQuery = [user.fullName, user.email]
.map((column: string) => `${column}`)
.join(' || ')

const rows = await db
.select({ ...userReturnSensitiveColumns, similarity: true })
.from(sql`${user}, word_similarity(${searchQuery}, ${columnQuery}) as similarity`)
.where(
searchQuery ? sql`similarity > 0.3` : undefined)
)
.orderBy(
searchQuery ? desc('similarity') : undefined
)
const columnQuery = [user.fullName, user.email]
.map((column: string) => `${column}`)
.join(' || ')

const rows = await db
.select({ ...userReturnSensitiveColumns, similarity: true })
.from(sql`${user}, word_similarity(${searchQuery}, ${columnQuery}) as similarity`)
.where(
searchQuery ? sql`similarity > 0.3` : undefined)
)
.orderBy(
searchQuery ? desc('similarity') : undefined
)
1 replies
CDCloudflare Developers
Created by Titan on 6/26/2024 in #general-help
Custom hostnames for SaaS timing out
No description
13 replies
DTDrizzle Team
Created by Titan on 5/31/2024 in #help
Not possible to add a new column to schema with drizzle migrate push (pg)
I'm adding a new column to my schema and running drizzle-kit push connecting to a postgres db It never adds the new column. However if the new column contains a foreign key constraint it will attempt to add that, but will of course fail because the column hasn't been created. This has never worked in the few months I've been using drizzle kit, perhaps I'm missunderstanding the purpose of push? Does it not handle column level modificatons only new tables?
1 replies
NNuxt
Created by Titan on 5/24/2024 in #❓・help
Dynamic/computed layout without causing content shift or re-render after route change
In my app.vue I'm using dynamic layouts to avoid having to specify the layout in every page:
const route = useRoute()

const layout = computed(() => {
if (route.path.startsWith('/platform')) {
return 'platform'
}

if (route.path.startsWith('/staff')) {
return 'staff'
}

if (route.path.startsWith('/admin')) {
return 'tenant-admin'
}

if (route.path.startsWith('/auth')) {
return 'auth'
}

return 'brochureware'
})

<template>
<NuxtLayout :name="layout">
const route = useRoute()

const layout = computed(() => {
if (route.path.startsWith('/platform')) {
return 'platform'
}

if (route.path.startsWith('/staff')) {
return 'staff'
}

if (route.path.startsWith('/admin')) {
return 'tenant-admin'
}

if (route.path.startsWith('/auth')) {
return 'auth'
}

return 'brochureware'
})

<template>
<NuxtLayout :name="layout">
However when switching from /auth to /platform you see a noticable shift in the content as the layout switches after the page has rendered. This re-rendering also breaks automated e2e tests as it attempts to fill in forms while the shift is happening. Is there anyway to make the layout change blocking or apply before the next <NuxtPage /> renders I assume it's because the computed watcher on useRoute is just updating too slow. Can it be set in the middleware maybe?
2 replies
DTDrizzle Team
Created by Titan on 4/26/2024 in #help
Return type is only "with" types, ignores "columns" types
Not sure if I'm using it wrong but the return type of a relational query is just the columns from the "with" clause, and doesn't merge with the "columns" object like I'd expect
3 replies
NNuxt
Created by Titan on 4/11/2024 in #❓・help
nuxt-ui with input masking recommendations
Does anyone have any recommendations for input masking with nuxt-ui UInput? I've previously used imaskjs but it requires binding to the native input element which won't work with <UInput />. Thanks!
1 replies
DTDrizzle Team
Created by Titan on 4/8/2024 in #help
Insert returning api to match select columns
No description
8 replies
NNuxt
Created by Titan on 4/7/2024 in #❓・help
Supress <Suspense> warning, adds lots of console logs in tests
How do I hide the <Suspense> is an experimental feature and its API will likely change. message in Nuxt 3? When unit testing it appears many times for each test which is pretty frustrating
7 replies
NNuxt
Created by Titan on 4/5/2024 in #❓・help
Can Nuxt Hub features be used outside of the base template?
Reading CF's announcement today: https://blog.cloudflare.com/blazing-fast-development-with-full-stack-frameworks-and-cloudflare And realising this sounds a lot like what you guys are doing in Nuxt Hub, is there a way to utilise parts of it, say the D1 or R2 functions, without opting into all the core when I already have my own base application? E.g it wouldn't also be importing a bunch of irrelevant code from core that my app wouldn't utilise? Thanks, it's not quite clear how standalone some of the Nuxt Hub features are.
1 replies
NNuxt
Created by Titan on 4/5/2024 in #❓・help
SOLVED: How to create server middleware just for API routes?
I'm trying to create middleware for my server API routes, but I've found they also run on SSR mode when trying to render the client, which has nothing to do with my API. How do I target just API H3 routes with middleware?
3 replies
NNuxt
Created by Titan on 2/29/2024 in #❓・help
Nuxt server API on subdomain
For native app reasons I need my Nuxt API routes to be on a subdomain of the Nuxt FE root domain. Has anyone done this before? In my head I feel like the solution is to just deploy the entire thing twice to both the root domain and subdomain and change the base URL for the API to point to the subdomain
9 replies
DTDrizzle Team
Created by Titan on 2/28/2024 in #help
Type for schema when creating db client
import { BetterSQLite3Database, drizzle } from 'drizzle-orm/better-sqlite3'

import { drizzle as drizzleLibSQL, LibSQLDatabase } from 'drizzle-orm/libsql'

import * as schema from '~/server/database/schema'

let _db: BetterSQLite3Database | LibSQLDatabase | null = null

export const useDB = () => {
if (!_db) {
_db = drizzleLibSQL(
createLibSQLClient({
url: process.env.TURSO_DB_URL,
authToken: process.env.TURSO_DB_TOKEN
}),
{ schema }
)
import { BetterSQLite3Database, drizzle } from 'drizzle-orm/better-sqlite3'

import { drizzle as drizzleLibSQL, LibSQLDatabase } from 'drizzle-orm/libsql'

import * as schema from '~/server/database/schema'

let _db: BetterSQLite3Database | LibSQLDatabase | null = null

export const useDB = () => {
if (!_db) {
_db = drizzleLibSQL(
createLibSQLClient({
url: process.env.TURSO_DB_URL,
authToken: process.env.TURSO_DB_TOKEN
}),
{ schema }
)
I get the following typescript error whenever I try to include { schema } into my db creation: ``` Type 'LibSQLDatabase<typeof import("server/database/schema")>' is not assignable to type 'BetterSQLite3Database | LibSQLDatabase<Record<string, never>> | null'. Type 'LibSQLDatabase<typeof import("server/database/schema")>' is not assignable to type 'LibSQLDatabase<Record<string, never>>'. The types of '.schema' are incompatible between these types. Type 'ExtractTablesWithRelations<typeof import("server/database/schema")> | undefined' is not assignable to type 'ExtractTablesWithRelations<Record<string, never>> | undefined'. Type 'ExtractTablesWithRelations<typeof import("server/database/schema")>' is not assignable to type 'ExtractTablesWithRelations<Record<string, never>>'. Property 'todos' is incompatible with index signature. Type '{ tsName: "todos"; dbName: "todos"; columns: { id: SQLiteColumn<{ name: "id"; tableName: "todos"; dataType: "number"; columnType: "SQLiteInteger"; data: number; driverParam: number; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, object>; userId: SQLiteColumn<...>; title: SQLiteColumn<....' is not assignable to type '{ tsName: string; dbName: never; columns: never; relations: Record<string, Relation<string>>; primaryKey: AnyColumn[]; }'. Types of property 'dbName' are incompatible. Type 'string' is not assignable to type 'never'.```
10 replies
CDCloudflare Developers
Created by Titan on 2/13/2024 in #general-help
Port 80 on my origin, but SSL via cloudflare
I'd like to keep using port 80 on my non-important origin apache server, and I was under the impression if I proxied the DNS via CF, CF could provide https for the domain for client->CF communication and get CF to communicate with my origin server on port 80. I've got SSL set to flexible, but CF can't seem to connect. Is there a way to tell CF to communicate with the origin on port 80 always?
10 replies