next/nuxt.config.ts

160 lines
3.2 KiB
TypeScript
Raw Normal View History

2023-09-23 15:58:51 -04:00
// https://nuxt.com/docs/api/configuration/nuxt-config
import { IUser } from "@models/user";
import { fileURLToPath } from "url";
// import speedkitHydrate from "nuxt-speedkit/dist/runtime/hydrate.mjs";
export type SessionData = IUser;
const cac = {
isr: true,
headersOnly: true,
cache: {
headersOnly: true,
// integrity: "",
2023-12-06 21:58:35 -05:00
varies: ["Content-Length", "Cookie"],
maxAge: 60,
},
swr: false,
};
const ct =
<T>() =>
<U extends T>(u: U) =>
u;
2023-09-23 15:58:51 -04:00
export default defineNuxtConfig({
experimental: {
watcher: "chokidar-granular",
// noScripts: true,
treeshakeClientOnly: true,
},
devtools: { enabled: true },
modules: [
"vue-recaptcha/nuxt",
"@ant-design-vue/nuxt",
"@sidebase/nuxt-auth",
"@pinia/nuxt",
"@vueuse/nuxt",
"nuxt-speedkit",
// "@nuxtjs/i18n",
2023-12-06 21:58:35 -05:00
// "./modules/09.loaded",
],
// i18n: {
// vueI18n: `./i18n.config.ts`,
// },
speedkit: {
disableNuxtFontaine: true,
lazyOffset: {
component: "0%",
asset: "0%",
},
},
css: ["~/public/fonts.css", "~/public/css/all.css"],
auth: {
baseURL: "/api/auth",
provider: {
type: "local",
pages: {
login: "/login",
},
token: {
signInResponseTokenPointer: "/token",
type: "Bearer",
headerName: "Authorization",
maxAgeInSeconds: 14 * 24 * 60 * 60,
// sameSiteAttribute: ,
},
2023-12-09 17:49:09 -05:00
// @ts-ignore
2023-12-06 21:58:35 -05:00
sessionDataType: {} as IUser,
endpoints: {
signUp: { path: "/register", method: "post" },
signOut: { path: "/logout", method: "post" },
getSession: {
path: "/session",
method: "get",
},
},
},
globalAppMiddleware: false,
//@ts-ignore
session: {
enableRefreshPeriodically: 60 * 60 * 2 * 1000,
enableRefreshOnWindowFocus: false,
},
},
nitro: {
esbuild: {
options: {
minify: true,
sourceMap: "inline",
},
},
2023-12-06 21:58:35 -05:00
preset: "node-server",
},
routeRules: {
"/": cac,
"/api/**": { cors: true },
2023-12-06 21:58:35 -05:00
"/band/**": cac,
"/authors": cac,
"/story/**": {
swr: true,
isr: true,
cache: {
maxAge: 1800,
2023-12-06 21:58:35 -05:00
headersOnly: true,
varies: ["Cookie", "Set-Cookie"],
},
},
// "/authors": { swr: 0 },
// "/bands": { swr: 0 },
},
// routeRules: {
// "/**": {
// cache: {
// maxAge: 60,
// headersOnly: true,
// },
// // swr: 60 * 60,
// },
// },
// ssr: false,
alias: {
"@models": fileURLToPath(new URL("./models", import.meta.url)),
"@client": fileURLToPath(new URL("./lib/client", import.meta.url)),
"@server": fileURLToPath(new URL("./lib/server", import.meta.url)),
"@functions": fileURLToPath(new URL("./lib/functions.ts", import.meta.url)),
"@dbconfig": fileURLToPath(new URL("./lib/dbconfig.ts", import.meta.url)),
},
sourcemap: {
server: true,
client: true,
},
runtimeConfig: {
captcha: {
secret: process.env.CAPTCHASECRET,
key: process.env.CAPTCHAKEY,
},
database: {
user: process.env.DBUSER,
password: process.env.DBPASS,
uri: `mongodb://${process.env.DB}`,
},
jwt: process.env.JWT,
public: {
recaptcha: {
v2SiteKey: process.env.CAPTCHAKEY,
},
auth: {
computed: {
origin: "127.0.0.1",
},
},
// apiBase: "/api"
},
nodebb: {
masterToken: process.env.nbb_bearer,
},
},
// components: {
// transform: (str) =>
// },
});