w7a9q
w7a9q
Explore posts from servers
NNuxt
Created by w7a9q on 9/11/2024 in #❓・help
Nitro typecheck
@cuebit The thing is that Nitro uses TypeScript without it being installed. zsh: command not found: tsc
4 replies
NNuxt
Created by w7a9q on 7/12/2024 in #❓・help
Get body of the response
Great! Thanks
13 replies
NNuxt
Created by w7a9q on 7/12/2024 in #❓・help
Get body of the response
The client wants us to verify that the actual response body is JSON.
13 replies
NNuxt
Created by w7a9q on 7/12/2024 in #❓・help
Get body of the response
Yeah but you can use middleware to manipulate with the response as well, right? I don't have any code. I want to write a middleware and read the body of the response I return back from endpoint implemented in the server/api.
13 replies
NNuxt
Created by w7a9q on 7/12/2024 in #❓・help
Get body of the response
HTTP response body
13 replies
NNuxt
Created by w7a9q on 7/10/2024 in #❓・help
async Nitro middleware
That was it! Of course, thank you!
8 replies
NNuxt
Created by w7a9q on 7/10/2024 in #❓・help
async Nitro middleware
No description
8 replies
NNuxt
Created by w7a9q on 7/10/2024 in #❓・help
async Nitro middleware
export default defineEventHandler(async event => {
const body = await readBody(event)

try {
JSON.parse(body)
}
catch {
throw createError({
statusCode: 415,
statusMessage: 'Body is not JSON.',
})
}
})
export default defineEventHandler(async event => {
const body = await readBody(event)

try {
JSON.parse(body)
}
catch {
throw createError({
statusCode: 415,
statusMessage: 'Body is not JSON.',
})
}
})
8 replies
NNuxt
Created by w7a9q on 7/10/2024 in #❓・help
async Nitro middleware
Anyone?
8 replies
NNuxt
Created by w7a9q on 6/17/2024 in #❓・help
Mocking useStorage
Looks like Nitro is not accessible outside of server: https://github.com/nuxt/nuxt/issues/23484#issuecomment-1742010287
4 replies
NNuxt
Created by w7a9q on 6/17/2024 in #❓・help
Mocking useStorage
I have tried adding @vueuse/core package and then importing the function from it: import { useStorage } from '@vueuse/core'. It did not solve the problem. Here is the StackBlitz repl: https://stackblitz.com/edit/nuxt-starter-bf2fpu?file=test%2Futils.test.ts
4 replies
NNuxt
Created by w7a9q on 6/17/2024 in #❓・help
Mocking useStorage
I tried this solution: https://stackoverflow.com/questions/74993530/how-to-test-a-function-that-uses-nitros-usestorage Now the error is thrown from the actual function: ReferenceError: useStorage is not defined - that should beeen autoimported as well. In the post he changes the actual implementation to use mock, I don't want this. What is the best practice about this?
4 replies
NNuxt
Created by w7a9q on 6/10/2024 in #❓・help
useStorage in nuxt/test-utils
The point of the function is to process the object and save some of the properties to the KV. I need to verify that the content saved into the KV is correct.
8 replies
NNuxt
Created by w7a9q on 6/10/2024 in #❓・help
useStorage in nuxt/test-utils
So you think it's bad designed test?
8 replies
NNuxt
Created by w7a9q on 6/10/2024 in #❓・help
useStorage in nuxt/test-utils
That doesn't solve the issue when I want to test a function that saves an item to the storage. I want to load the item afterwards and perform assertion on it.
8 replies