Bobakanoosh
Bobakanoosh
Explore posts from servers
Aarktype
Created by Bobakanoosh on 11/15/2024 in #questions
Using scope with morphs
I store some data in a json file, so I'm using string.json.parse to read that data in and validate it.
const UserConfigSchema = scope({
config: type("string.json.parse").to({
// ERROR:
// "windowMeta" is unresolvable
windowMeta: "Record<string, windowMeta>",
}),
windowMeta: {
"position?": {
x: "number",
y: "number",
},
},
}).export();
const UserConfigSchema = scope({
config: type("string.json.parse").to({
// ERROR:
// "windowMeta" is unresolvable
windowMeta: "Record<string, windowMeta>",
}),
windowMeta: {
"position?": {
x: "number",
y: "number",
},
},
}).export();
Maybe I shouldn't be using scope here and should instead be directly using the windowMeta type within the Record?
59 replies
Aarktype
Created by Bobakanoosh on 11/15/2024 in #questions
Passing an exported scope to a function (Type 'string' is not assignable to type 'never')
Hello, I have an exported scope that I'm trying to pass to a generic class to be used.
// the class
class SomeClass<TData extends any> {
// I tried `Type<TData>` here but get this when trying to call `this.schema()` "Type 'unknown' has no call signatures"
constuctor(public schema: Type) {
}
}

// the schema
const UserConfigSchema = scope({
config: {
windowMeta: "Record<string, windowMeta>",
},
windowMeta: {
position: {
x: "number",
y: "number",
},
}
}).export();

type UserConfig = typeof UserConfigSchema.config.infer;

class SomeParentClass extends SomeClass<UserConfig> {
constructor() {
// ERROR:
// Type 'string' is not assignable to type 'never'
super(UserConfigSchema.config);
}
}
// the class
class SomeClass<TData extends any> {
// I tried `Type<TData>` here but get this when trying to call `this.schema()` "Type 'unknown' has no call signatures"
constuctor(public schema: Type) {
}
}

// the schema
const UserConfigSchema = scope({
config: {
windowMeta: "Record<string, windowMeta>",
},
windowMeta: {
position: {
x: "number",
y: "number",
},
}
}).export();

type UserConfig = typeof UserConfigSchema.config.infer;

class SomeParentClass extends SomeClass<UserConfig> {
constructor() {
// ERROR:
// Type 'string' is not assignable to type 'never'
super(UserConfigSchema.config);
}
}
I see that .export() yields type Module, but I couldn't figure out how to use that either. Appreciate any help
16 replies
Aarktype
Created by Bobakanoosh on 10/2/2024 in #questions
Customizing Error Messages
I've searched Github & Discord a bit and seen a few mentions of "full error customization", and am finding that I need it, but can't find any examples of it. I have a type:
const form = type({
user: {
email: 'string.email',
age: 'number>13',
}
})
const form = type({
user: {
email: 'string.email',
age: 'number>13',
}
})
When these fields are incorrect, it yields the following error messages:
{
"user.email": "user.email must be an email address (was \"test\")",
"user.age": "user.age must be more than 13 (was 12)"
}
{
"user.email": "user.email must be an email address (was \"test\")",
"user.age": "user.age must be more than 13 (was 12)"
}
I want to show these outputs in-line in a form. To do that, I need some more customization like: - Showing email instead of user.email (I can use css capitalize to capitalize it if necessary) - Getting rid of (was ___) Right now my best option is to manually manipulate the string to make these changes, which isn't ideal.
5 replies
Aarktype
Created by Bobakanoosh on 10/2/2024 in #questions
v2 docs
I see the v2 docs mentioned frequently here and in GitHub, but I can’t find a link to them. Are they deployed? Even if they’re a WIP, they’d be extremely valuable to have I think
2 replies
NNuxt
Created by Bobakanoosh on 9/21/2024 in #❓・help
i18n language auto detection not working
I have users telling me my site doesn't automatically detect their language. I tried switching my browser and browser language to spanish, and it doesn't work (on ANY site, even google?). My Accept-Language header is es-ES,en-US;q=0.7,en;q=0.3 My navigator.language is es-ES But no matter what when I delete the i18n_redirected cookie, it recreates it en "en". What setting do I need to change on chrome for a site to auto detect my language?
5 replies
NNuxt
Created by Bobakanoosh on 5/10/2024 in #❓・help
nuxt-i18n dynamically load translations
I want to make it easier for people helping translate my site by giving them an embedded JSON editor that as they change, updates the site. That way they can visually see where their translations are going. Any idea how I could accomplish this?
23 replies
NNuxt
Created by Bobakanoosh on 4/21/2024 in #❓・help
useCookie() not working
Maybe this is expected behavior. If not, I'll make a Github issue I have { swr: true } in a route rule. When on that route, when trying to use useCookie, the cookie doesn't persist. Here's a minimal reproduction: https://stackblitz.com/edit/github-pvvuiv-4zjjl5?file=nuxt.config.ts,app.vue
1 replies
NNuxt
Created by Bobakanoosh on 4/19/2024 in #❓・help
swr: true breaks useCookie
Maybe this is expected behavior. If not, I'll make a Github issue I have { swr: true } in a route rule. When on that route, when trying to use useCookie, the cookie doesn't persist. Here's a minimal reproduction: https://stackblitz.com/edit/github-pvvuiv-4zjjl5?file=nuxt.config.ts,app.vue
1 replies
CDCloudflare Developers
Created by Bobakanoosh on 4/4/2024 in #general-help
Workers & Billing Page Not Aligning
No description
7 replies
NNuxt
Created by Bobakanoosh on 3/2/2024 in #❓・help
Debug dev server warmup speed & build speed
Is there a way to debug the dev server warmup speed & build speed? Both of mine are very slow (80 seconds) but I have no idea whats causing it. Vite client warmed up in 80606ms 7:03:33 PM Vite server warmed up in 80820ms 7:03:33 PM
------------------------------
- Operating System: Windows_NT
- Node Version: v20.11.0
- Nuxt Version: 3.9.3
- CLI Version: 3.10.1
- Nitro Version: 2.9.1
- Package Manager: [email protected]
- Builder: -
- User Config: runtimeConfig, modules, vite, devServer, nitro, googleFonts, serverDir, imports, vue, css, devtools, experimental, srcDir, image, sourcemap, features, alias
- Runtime Modules: @pinia/[email protected], [email protected], @vueuse/[email protected], @unocss/[email protected], radix-vue/nuxt, [email protected], @nuxtjs/[email protected], @nuxt/[email protected]
- Build Modules: -
------------------------------
------------------------------
- Operating System: Windows_NT
- Node Version: v20.11.0
- Nuxt Version: 3.9.3
- CLI Version: 3.10.1
- Nitro Version: 2.9.1
- Package Manager: [email protected]
- Builder: -
- User Config: runtimeConfig, modules, vite, devServer, nitro, googleFonts, serverDir, imports, vue, css, devtools, experimental, srcDir, image, sourcemap, features, alias
- Runtime Modules: @pinia/[email protected], [email protected], @vueuse/[email protected], @unocss/[email protected], radix-vue/nuxt, [email protected], @nuxtjs/[email protected], @nuxt/[email protected]
- Build Modules: -
------------------------------
3 replies
CDCloudflare Developers
Created by Bobakanoosh on 12/8/2023 in #general-help
s2 is not a function on pnpx wrangler deploy
I'm running pnpx wrangler deploy with the following wrangler.toml to deploy a Nuxt 3 application from Windows 11. Everything was working perfectly fine yesterday. I haven't found anything on google, in this discord, or as a Github issue. Wrangler.toml:
name = "frontend-nuxt"
main = "./.output/server/index.mjs"
workers_dev = true
compatibility_date = "2023-11-12"
account_id = "REDACTED"
route = "REDACTED"

rules = [
{ type = "ESModule", globs = ["**/*.js", "**/*.mjs"]},
]

[site]
bucket = ".output/public"

[env.production]
route="REDACTED"

[vars]
BACKEND_DOMAIN="REDACTED"
name = "frontend-nuxt"
main = "./.output/server/index.mjs"
workers_dev = true
compatibility_date = "2023-11-12"
account_id = "REDACTED"
route = "REDACTED"

rules = [
{ type = "ESModule", globs = ["**/*.js", "**/*.mjs"]},
]

[site]
bucket = ".output/public"

[env.production]
route="REDACTED"

[vars]
BACKEND_DOMAIN="REDACTED"
Error:
X [ERROR] A request to the Cloudflare API (/accounts/REDACTED/workers/scripts/frontend-nuxt) failed.

Uncaught TypeError: s2 is not a function
at worker.js:27540:16
at worker.js:27542:6
at worker.js:33657:4
at worker.js:33658:3
[code: 10021]
X [ERROR] A request to the Cloudflare API (/accounts/REDACTED/workers/scripts/frontend-nuxt) failed.

Uncaught TypeError: s2 is not a function
at worker.js:27540:16
at worker.js:27542:6
at worker.js:33657:4
at worker.js:33658:3
[code: 10021]
3 replies
NNuxt
Created by Bobakanoosh on 6/12/2023 in #❓・help
How to name route file *not* index.get.ts, etc
Is there a way to still use the folder-based api routes, but not name files index? I'm really used to navigating projects by just searching the files, not using the file tree. I see that I could do posts.get.ts, but having folders like /posts/ is nice too for related helper functions, etc
1 replies
NNuxt
Created by Bobakanoosh on 12/9/2022 in #❓・help
API Routes - Nested dynamic parameters
No description
2 replies