diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..25fa621 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib" +} diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..8cf7f96 --- /dev/null +++ b/biome.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.5.3/schema.json", + "organizeImports": { + "enabled": true + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true + } + }, + "formatter": { + "indentStyle": "space" + }, + "javascript": { + "formatter": { "semicolons": "asNeeded", "quoteStyle": "single" } + } +} diff --git a/nuxt.config.ts b/nuxt.config.ts index d948e4c..3f78d37 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -16,9 +16,7 @@ export default defineNuxtConfig({ asyncContext: true, headNext: true, componentIslands: true, - inlineSSRStyles: true, }, - vue: { defineModel: true }, // Modules modules: [ @@ -104,14 +102,15 @@ export default defineNuxtConfig({ '/': { swr: true }, '/quiz/**': { swr: true }, '/info/**': { static: true }, - '/_api/**': { proxy: '/api/**' }, + }, + runtimeConfig: { + databaseUrl: process.env.DATABASE_URL, }, - // Development + // Development devtools: { enabled: true }, typescript: { strict: true, - shim: false, tsConfig: { compilerOptions: { types: ['@types/node'], diff --git a/src/pages/index/quiz/[section].vue b/src/pages/index/quiz/[section].vue index 84d3f22..ffa521b 100644 --- a/src/pages/index/quiz/[section].vue +++ b/src/pages/index/quiz/[section].vue @@ -50,8 +50,16 @@ definePageMeta({ scrollToTop: false, middleware: async (to) => { const currentSection = to.params.section as string - const { sections } = await useFetchSection() - const isSectionValid = !!sections.value?.find( + // XXX: nuxt says that you cannot use a composable outside of setup or + // custom composable. For the same reason, we cannot use useFetchSection() + // in the middleware. We will resort to direct `$fetch` call. + let sections + try { + sections = await $fetch('/api/sections') + } catch (error) { + return abortNavigation({ statusCode: 404, message: 'No sections found' }) + } + const isSectionValid = !!sections.find( (s) => s.msgid === currentSection )