mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-09 20:12:10 +10:00
fix: remove jank prisma script, and move to generated prisma client
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -31,3 +31,6 @@ logs
|
||||
deploy-template/*
|
||||
|
||||
!deploy-template/compose.yml
|
||||
|
||||
# generated prisma client
|
||||
/prisma/client
|
||||
@ -26,6 +26,6 @@ COPY --from=build-system /build/build ./startup
|
||||
|
||||
# OpenSSL as a dependency for Drop (TODO: seperate build environment)
|
||||
RUN apt-get update -y && apt-get install -y openssl
|
||||
RUN yarn global add prisma@6.6.0
|
||||
RUN yarn global add prisma@6.7.0
|
||||
|
||||
CMD ["/app/startup/launch.sh"]
|
||||
@ -1,55 +0,0 @@
|
||||
// thanks https://github.com/prisma/prisma/issues/26565#issuecomment-2777915354
|
||||
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
async function replaceInFiles(dir) {
|
||||
const files = await fs.readdir(dir, { withFileTypes: true });
|
||||
|
||||
for (const file of files) {
|
||||
const fullPath = path.join(dir, file.name);
|
||||
// Skip directories
|
||||
if (!file.isDirectory()) {
|
||||
if (
|
||||
file.name.endsWith(".js") ||
|
||||
file.name.endsWith(".ts") ||
|
||||
file.name.endsWith(".mjs")
|
||||
) {
|
||||
let content = await fs.readFile(fullPath, "utf8");
|
||||
if (content.includes(".prisma")) {
|
||||
const isWindows = content.includes("\r\n");
|
||||
const lineEnding = isWindows ? "\r\n" : "\n";
|
||||
|
||||
content = content
|
||||
.split(/\r?\n/)
|
||||
.map((line) => line.replace(/\.prisma/g, "_prisma"))
|
||||
.join(lineEnding);
|
||||
|
||||
await fs.writeFile(fullPath, content, "utf8");
|
||||
console.log(`Modified: ${fullPath}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const oldPath = path.join(__dirname, "../node_modules/.prisma");
|
||||
const newPath = path.join(__dirname, "../node_modules/_prisma");
|
||||
try {
|
||||
await fs.rename(oldPath, newPath);
|
||||
console.log("Directory renamed from .prisma to _prisma");
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
} catch (err) {
|
||||
console.log("Directory .prisma does not exist or has already been renamed");
|
||||
}
|
||||
|
||||
await replaceInFiles(path.join(__dirname, "../node_modules/@prisma/client"));
|
||||
console.log("Done! --- prisma!!!, replaced .prisma with _prisma");
|
||||
}
|
||||
|
||||
main().catch((err) => console.error(err));
|
||||
@ -82,7 +82,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { XCircleIcon } from "@heroicons/vue/20/solid";
|
||||
import type { User } from "@prisma/client";
|
||||
import type { User } from "~/prisma/client";
|
||||
|
||||
const username = ref("");
|
||||
const password = ref("");
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { DialogTitle } from "@headlessui/vue";
|
||||
import type { CollectionEntry, Game } from "@prisma/client";
|
||||
import type { CollectionEntry, Game } from "~/prisma/client";
|
||||
import type { SerializeObject } from "nitropack";
|
||||
|
||||
const props = defineProps<{
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Collection } from "@prisma/client";
|
||||
import type { Collection } from "~/prisma/client";
|
||||
import { DialogTitle } from "@headlessui/vue";
|
||||
|
||||
const collection = defineModel<Collection | undefined>();
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Game } from "@prisma/client";
|
||||
import type { Game } from "~/prisma/client";
|
||||
import type { SerializeObject } from "nitropack";
|
||||
|
||||
const props = defineProps<{
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { XMarkIcon } from "@heroicons/vue/24/solid";
|
||||
import type { Notification } from "@prisma/client";
|
||||
import type { Notification } from "~/prisma/client";
|
||||
|
||||
const props = defineProps<{ notification: Notification }>();
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Notification } from "@prisma/client";
|
||||
import type { Notification } from "~/prisma/client";
|
||||
|
||||
const props = defineProps<{ notifications: Array<Notification> }>();
|
||||
</script>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { Collection, CollectionEntry, Game } from "@prisma/client";
|
||||
import type { Collection, CollectionEntry, Game } from "~/prisma/client";
|
||||
import type { SerializeObject } from "nitropack";
|
||||
|
||||
type FullCollection = Collection & {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { Article } from "@prisma/client";
|
||||
import type { Article } from "~/prisma/client";
|
||||
import type { SerializeObject } from "nitropack";
|
||||
|
||||
export const useNews = () =>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { Notification } from "@prisma/client";
|
||||
import type { Notification } from "~/prisma/client";
|
||||
|
||||
const ws = new WebSocketHandler("/api/v1/notifications/ws");
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { User } from "@prisma/client";
|
||||
import type { User } from "~/prisma/client";
|
||||
|
||||
// undefined = haven't check
|
||||
// null = check, no user
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
"dev": "nuxt dev",
|
||||
"generate": "nuxt generate",
|
||||
"preview": "nuxt preview",
|
||||
"postinstall": "prisma generate && nuxt prepare && node build/fix-prisma.js",
|
||||
"postinstall": "prisma generate && nuxt prepare",
|
||||
"typecheck": "nuxt typecheck",
|
||||
"lint": "yarn lint:eslint && yarn lint:prettier",
|
||||
"lint:eslint": "eslint .",
|
||||
@ -21,7 +21,7 @@
|
||||
"@heroicons/vue": "^2.1.5",
|
||||
"@nuxt/fonts": "^0.11.0",
|
||||
"@nuxt/image": "^1.10.0",
|
||||
"@prisma/client": "^6.6.0",
|
||||
"@prisma/client": "^6.7.0",
|
||||
"@tailwindcss/vite": "^4.0.6",
|
||||
"argon2": "^0.41.1",
|
||||
"arktype": "^2.1.10",
|
||||
@ -35,7 +35,7 @@
|
||||
"micromark": "^4.0.1",
|
||||
"nuxt": "^3.16.2",
|
||||
"nuxt-security": "2.2.0",
|
||||
"prisma": "^6.6.0",
|
||||
"prisma": "^6.7.0",
|
||||
"sharp": "^0.33.5",
|
||||
"stream-mime-type": "^2.0.0",
|
||||
"turndown": "^7.2.0",
|
||||
|
||||
@ -519,7 +519,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Bars3Icon, TrashIcon } from "@heroicons/vue/16/solid";
|
||||
import type { Game, GameVersion } from "@prisma/client";
|
||||
import type { Game, GameVersion } from "~/prisma/client";
|
||||
import { micromark } from "micromark";
|
||||
import {
|
||||
ArrowTopRightOnSquareIcon,
|
||||
|
||||
@ -100,7 +100,7 @@ import { IconsSimpleAuthenticationLogo, IconsSSOLogo } from "#components";
|
||||
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/vue";
|
||||
import { EllipsisHorizontalIcon } from "@heroicons/vue/20/solid";
|
||||
import { CheckIcon, XMarkIcon } from "@heroicons/vue/24/solid";
|
||||
import type { AuthMec } from "@prisma/client";
|
||||
import type { AuthMec } from "~/prisma/client";
|
||||
import type { Component } from "vue";
|
||||
|
||||
useHead({
|
||||
|
||||
@ -369,7 +369,7 @@ import {
|
||||
} from "@headlessui/vue";
|
||||
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/vue/20/solid";
|
||||
import { TrashIcon, XCircleIcon } from "@heroicons/vue/24/solid";
|
||||
import type { Invitation } from "@prisma/client";
|
||||
import type { Invitation } from "~/prisma/client";
|
||||
import type { SerializeObject } from "nitropack";
|
||||
import type { DurationLike } from "luxon";
|
||||
import { DateTime } from "luxon";
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
<div class="mt-10">
|
||||
<div>
|
||||
<AuthSimple v-if="enabledAuths.includes(AuthMec.Simple)" />
|
||||
<AuthSimple v-if="enabledAuths.includes('Simple' as AuthMec)" />
|
||||
<div
|
||||
v-if="enabledAuths.length > 1"
|
||||
class="py-4 flex flex-row items-center justify-center gap-x-4 font-bold text-sm text-zinc-600"
|
||||
@ -27,7 +27,7 @@
|
||||
OR
|
||||
<span class="h-[1px] grow bg-zinc-600" />
|
||||
</div>
|
||||
<AuthOpenID v-if="enabledAuths.includes(AuthMec.OpenID)" />
|
||||
<AuthOpenID v-if="enabledAuths.includes('OpenID' as AuthMec)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -43,7 +43,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { AuthMec } from "@prisma/client";
|
||||
import type { AuthMec } from "~/prisma/client";
|
||||
import DropLogo from "~/components/DropLogo.vue";
|
||||
|
||||
const enabledAuths = await $dropFetch("/api/v1/auth");
|
||||
|
||||
@ -117,7 +117,7 @@ import {
|
||||
ArrowUpRightIcon,
|
||||
} from "@heroicons/vue/20/solid";
|
||||
import { micromark } from "micromark";
|
||||
import type { Game } from "@prisma/client";
|
||||
import type { Game } from "~/prisma/client";
|
||||
|
||||
const route = useRoute();
|
||||
const id = route.params.id.toString();
|
||||
|
||||
@ -92,7 +92,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { TrashIcon, PlusIcon } from "@heroicons/vue/20/solid";
|
||||
import type { Collection } from "@prisma/client";
|
||||
import type { Collection } from "~/prisma/client";
|
||||
|
||||
const collections = await useCollections();
|
||||
const collectionCreateOpen = ref(false);
|
||||
|
||||
@ -81,7 +81,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { DocumentIcon } from "@heroicons/vue/24/outline";
|
||||
import type { Article } from "@prisma/client";
|
||||
import type { Article } from "~/prisma/client";
|
||||
import type { SerializeObject } from "nitropack/types";
|
||||
|
||||
const { articles } = defineProps<{
|
||||
|
||||
@ -170,7 +170,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ArrowTopRightOnSquareIcon } from "@heroicons/vue/24/outline";
|
||||
import { StarIcon } from "@heroicons/vue/24/solid";
|
||||
import type { Game, GameVersion } from "@prisma/client";
|
||||
import type { Game, GameVersion } from "~/prisma/client";
|
||||
import { micromark } from "micromark";
|
||||
import { DateTime } from "luxon";
|
||||
import type { SerializeObject } from "nitropack";
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "client"
|
||||
moduleFormat = "esm"
|
||||
previewFeatures = ["prismaSchemaFolder", "fullTextSearchPostgres"]
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { AuthMec } from "@prisma/client";
|
||||
import { AuthMec } from "~/prisma/client";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import { enabledAuthManagers } from "~/server/plugins/04.auth-init";
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { AuthMec } from "@prisma/client";
|
||||
import { AuthMec } from "~/prisma/client";
|
||||
import type { JsonArray } from "@prisma/client/runtime/library";
|
||||
import { type } from "arktype";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { AuthMec } from "@prisma/client";
|
||||
import { AuthMec } from "~/prisma/client";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import { createHashArgon2 } from "~/server/internal/security/simple";
|
||||
import * as jdenticon from "jdenticon";
|
||||
|
||||
@ -24,7 +24,8 @@ export default defineClientEventHandler(async (h3) => {
|
||||
if (!version.dropletManifest) return undefined;
|
||||
|
||||
const newVersion = { ...version, dropletManifest: undefined };
|
||||
// @ts-expect-error idk why we delete an undefined object
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore idk why we delete an undefined object
|
||||
delete newVersion.dropletManifest;
|
||||
return {
|
||||
...newVersion,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ClientCapabilities } from "@prisma/client";
|
||||
import { ClientCapabilities } from "~/prisma/client";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ClientCapabilities } from "@prisma/client";
|
||||
import { ClientCapabilities } from "~/prisma/client";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ClientCapabilities } from "@prisma/client";
|
||||
import { ClientCapabilities } from "~/prisma/client";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import saveManager from "~/server/internal/saves";
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ClientCapabilities } from "@prisma/client";
|
||||
import { ClientCapabilities } from "~/prisma/client";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ClientCapabilities } from "@prisma/client";
|
||||
import { ClientCapabilities } from "~/prisma/client";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import { applicationSettings } from "~/server/internal/config/application-configuration";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ClientCapabilities } from "@prisma/client";
|
||||
import { ClientCapabilities } from "~/prisma/client";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ClientCapabilities } from "@prisma/client";
|
||||
import { ClientCapabilities } from "~/prisma/client";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import { applicationSettings } from "~/server/internal/config/application-configuration";
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { APITokenMode } from "@prisma/client";
|
||||
import { APITokenMode } from "~/prisma/client";
|
||||
import { DateTime } from "luxon";
|
||||
import type { UserACL } from "~/server/internal/acls";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { APITokenMode } from "@prisma/client";
|
||||
import { APITokenMode } from "~/prisma/client";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { APITokenMode } from "@prisma/client";
|
||||
import { APITokenMode } from "~/prisma/client";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { APITokenMode } from "@prisma/client";
|
||||
import { APITokenMode } from "~/prisma/client";
|
||||
import aclManager, { userACLs } from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { APITokenMode } from "@prisma/client";
|
||||
import { APITokenMode } from "~/prisma/client";
|
||||
import prisma from "../db/database";
|
||||
import sessionHandler from "../session";
|
||||
import type { MinimumRequestObject } from "~/server/h3";
|
||||
|
||||
@ -2,7 +2,7 @@ import type { EnumDictionary } from "../utils/types";
|
||||
import https from "https";
|
||||
import { useCertificateAuthority } from "~/server/plugins/ca";
|
||||
import prisma from "../db/database";
|
||||
import { ClientCapabilities } from "@prisma/client";
|
||||
import { ClientCapabilities } from "~/prisma/client";
|
||||
|
||||
// These values are technically mapped to the database,
|
||||
// but Typescript/Prisma doesn't let me link them
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { Client, User } from "@prisma/client";
|
||||
import type { Client, User } from "~/prisma/client";
|
||||
import type { EventHandlerRequest, H3Event } from "h3";
|
||||
import droplet from "@drop-oss/droplet";
|
||||
import prisma from "../db/database";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import prisma from "../db/database";
|
||||
import type { Platform } from "@prisma/client";
|
||||
import type { Platform } from "~/prisma/client";
|
||||
import { useCertificateAuthority } from "~/server/plugins/ca";
|
||||
|
||||
export interface ClientMetadata {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { ApplicationSettings } from "@prisma/client";
|
||||
import type { ApplicationSettings } from "~/prisma/client";
|
||||
import prisma from "../db/database";
|
||||
|
||||
class ApplicationConfiguration {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { PrismaClient } from "~/prisma/client";
|
||||
|
||||
const prismaClientSingleton = () => {
|
||||
return new PrismaClient({});
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { GameVersion } from "@prisma/client";
|
||||
import type { GameVersion } from "~/prisma/client";
|
||||
import prisma from "../db/database";
|
||||
|
||||
export type DropChunk = {
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import prisma from "../db/database";
|
||||
import type { GameVersion } from "@prisma/client";
|
||||
import type { GameVersion } from "~/prisma/client";
|
||||
import { fuzzy } from "fast-fuzzy";
|
||||
import { recursivelyReaddir } from "../utils/recursivedirs";
|
||||
import taskHandler from "../tasks";
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { Developer, Publisher } from "@prisma/client";
|
||||
import { MetadataSource } from "@prisma/client";
|
||||
import type { Developer, Publisher } from "~/prisma/client";
|
||||
import { MetadataSource } from "~/prisma/client";
|
||||
import type { MetadataProvider } from ".";
|
||||
import { MissingMetadataProviderConfig } from ".";
|
||||
import type {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { Developer, Publisher } from "@prisma/client";
|
||||
import { MetadataSource } from "@prisma/client";
|
||||
import type { Developer, Publisher } from "~/prisma/client";
|
||||
import { MetadataSource } from "~/prisma/client";
|
||||
import type { MetadataProvider } from ".";
|
||||
import { MissingMetadataProviderConfig } from ".";
|
||||
import type {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { Developer, Publisher } from "@prisma/client";
|
||||
import { MetadataSource } from "@prisma/client";
|
||||
import type { Developer, Publisher } from "~/prisma/client";
|
||||
import { MetadataSource } from "~/prisma/client";
|
||||
import prisma from "../db/database";
|
||||
import type {
|
||||
_FetchDeveloperMetadataParams,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { MetadataSource } from "@prisma/client";
|
||||
import { MetadataSource } from "~/prisma/client";
|
||||
import type { MetadataProvider } from ".";
|
||||
import type {
|
||||
_FetchGameMetadataParams,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { Developer, Publisher } from "@prisma/client";
|
||||
import { MetadataSource } from "@prisma/client";
|
||||
import type { Developer, Publisher } from "~/prisma/client";
|
||||
import { MetadataSource } from "~/prisma/client";
|
||||
import type { MetadataProvider } from ".";
|
||||
import type {
|
||||
GameMetadataSearchResult,
|
||||
|
||||
2
server/internal/metadata/types.d.ts
vendored
2
server/internal/metadata/types.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
import type { Developer, Publisher } from "@prisma/client";
|
||||
import type { Developer, Publisher } from "~/prisma/client";
|
||||
import type { TransactionDataType } from "../objects/transactional";
|
||||
import type { ObjectReference } from "../objects/objectHandler";
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ Design goals:
|
||||
2. Real-time; use websocket listeners to keep clients up-to-date
|
||||
*/
|
||||
|
||||
import type { Notification } from "@prisma/client";
|
||||
import type { Notification } from "~/prisma/client";
|
||||
import prisma from "../db/database";
|
||||
|
||||
export type NotificationCreateArgs = Pick<
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { randomUUID } from "crypto";
|
||||
import prisma from "../db/database";
|
||||
import { AuthMec } from "@prisma/client";
|
||||
import { AuthMec } from "~/prisma/client";
|
||||
import objectHandler from "../objects";
|
||||
import type { Readable } from "stream";
|
||||
import * as jdenticon from "jdenticon";
|
||||
|
||||
35
server/internal/session/cache.ts
Normal file
35
server/internal/session/cache.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import cacheHandler from "../cache";
|
||||
import type { Session, SessionProvider } from "./types";
|
||||
|
||||
export default function createCacheSessionProvider() {
|
||||
const sessions = cacheHandler.createCache<Session>("cacheSessionProvider");
|
||||
|
||||
const memoryProvider: SessionProvider = {
|
||||
async setSession(token, data) {
|
||||
await sessions.set(token, data);
|
||||
return true;
|
||||
},
|
||||
async getSession<T extends Session>(token: string): Promise<T | undefined> {
|
||||
const session = await sessions.get(token);
|
||||
return session ? (session as T) : undefined; // Ensure undefined is returned if session is not found
|
||||
},
|
||||
async updateSession(token, data) {
|
||||
return await this.setSession(token, data);
|
||||
},
|
||||
async removeSession(token) {
|
||||
await sessions.remove(token);
|
||||
return true;
|
||||
},
|
||||
async cleanupSessions() {
|
||||
const now = new Date();
|
||||
for (const token of await sessions.getKeys()) {
|
||||
const session = await sessions.get(token);
|
||||
if (!session) continue;
|
||||
// if expires at time is before now, the session is expired
|
||||
if (session.expiresAt < now) await this.removeSession(token);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
return memoryProvider;
|
||||
}
|
||||
@ -3,9 +3,9 @@ import type { Session, SessionProvider } from "./types";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { parse as parseCookies } from "cookie-es";
|
||||
import type { MinimumRequestObject } from "~/server/h3";
|
||||
import createDBSessionHandler from "./db";
|
||||
import type { DurationLike } from "luxon";
|
||||
import { DateTime } from "luxon";
|
||||
import createCacheSessionProvider from "./cache";
|
||||
|
||||
/*
|
||||
This implementation may need work.
|
||||
@ -26,7 +26,8 @@ export class SessionHandler {
|
||||
|
||||
constructor() {
|
||||
// Create a new provider
|
||||
this.sessionProvider = createDBSessionHandler();
|
||||
this.sessionProvider = createCacheSessionProvider();
|
||||
// this.sessionProvider = createDBSessionHandler();
|
||||
// this.sessionProvider = createMemorySessionProvider();
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Platform } from "@prisma/client";
|
||||
import { Platform } from "~/prisma/client";
|
||||
|
||||
export function parsePlatform(platform: string) {
|
||||
switch (platform.toLowerCase()) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { AuthMec } from "@prisma/client";
|
||||
import { AuthMec } from "~/prisma/client";
|
||||
import { OIDCManager } from "../internal/oidc";
|
||||
|
||||
export const enabledAuthManagers: {
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
{
|
||||
// https://nuxt.com/docs/guide/concepts/typescript
|
||||
"extends": "./.nuxt/tsconfig.json"
|
||||
"extends": "./.nuxt/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"exactOptionalPropertyTypes": false
|
||||
}
|
||||
}
|
||||
|
||||
89
yarn.lock
89
yarn.lock
@ -1485,54 +1485,54 @@
|
||||
resolved "https://registry.yarnpkg.com/@poppinss/exception/-/exception-1.2.1.tgz#8a5f2120fabb64a99772166d537d8a97490209ff"
|
||||
integrity sha512-aQypoot0HPSJa6gDPEPTntc1GT6QINrSbgRlRhadGW2WaYqUK3tK4Bw9SBMZXhmxd3GeAlZjVcODHgiu+THY7A==
|
||||
|
||||
"@prisma/client@^6.6.0":
|
||||
version "6.6.0"
|
||||
resolved "https://registry.yarnpkg.com/@prisma/client/-/client-6.6.0.tgz#21e8cf507091b6cffc8453970f782cb6adef0004"
|
||||
integrity sha512-vfp73YT/BHsWWOAuthKQ/1lBgESSqYqAWZEYyTdGXyFAHpmewwWL2Iz6ErIzkj4aHbuc6/cGSsE6ZY+pBO04Cg==
|
||||
"@prisma/client@^6.7.0":
|
||||
version "6.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@prisma/client/-/client-6.7.0.tgz#69f913b0a8cfb6aa5de5dca6aa57bfd4e91e7e95"
|
||||
integrity sha512-+k61zZn1XHjbZul8q6TdQLpuI/cvyfil87zqK2zpreNIXyXtpUv3+H/oM69hcsFcZXaokHJIzPAt5Z8C8eK2QA==
|
||||
|
||||
"@prisma/config@6.6.0":
|
||||
version "6.6.0"
|
||||
resolved "https://registry.yarnpkg.com/@prisma/config/-/config-6.6.0.tgz#ad945b707f613d0abe3164cf2341a6b14eebf93e"
|
||||
integrity sha512-d8FlXRHsx72RbN8nA2QCRORNv5AcUnPXgtPvwhXmYkQSMF/j9cKaJg+9VcUzBRXGy9QBckNzEQDEJZdEOZ+ubA==
|
||||
"@prisma/config@6.7.0":
|
||||
version "6.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@prisma/config/-/config-6.7.0.tgz#ae80b889ba1facc308ecca2009aa6dfbe92c28db"
|
||||
integrity sha512-di8QDdvSz7DLUi3OOcCHSwxRNeW7jtGRUD2+Z3SdNE3A+pPiNT8WgUJoUyOwJmUr5t+JA2W15P78C/N+8RXrOA==
|
||||
dependencies:
|
||||
esbuild ">=0.12 <1"
|
||||
esbuild-register "3.6.0"
|
||||
|
||||
"@prisma/debug@6.6.0":
|
||||
version "6.6.0"
|
||||
resolved "https://registry.yarnpkg.com/@prisma/debug/-/debug-6.6.0.tgz#150bbbda5e9f665c08eed6c4c394cda38bb70cce"
|
||||
integrity sha512-DL6n4IKlW5k2LEXzpN60SQ1kP/F6fqaCgU/McgaYsxSf43GZ8lwtmXLke9efS+L1uGmrhtBUP4npV/QKF8s2ZQ==
|
||||
"@prisma/debug@6.7.0":
|
||||
version "6.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@prisma/debug/-/debug-6.7.0.tgz#a955174e4f481b0ca5d7c0fd458ef848432afd59"
|
||||
integrity sha512-RabHn9emKoYFsv99RLxvfG2GHzWk2ZI1BuVzqYtmMSIcuGboHY5uFt3Q3boOREM9de6z5s3bQoyKeWnq8Fz22w==
|
||||
|
||||
"@prisma/engines-version@6.6.0-53.f676762280b54cd07c770017ed3711ddde35f37a":
|
||||
version "6.6.0-53.f676762280b54cd07c770017ed3711ddde35f37a"
|
||||
resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-6.6.0-53.f676762280b54cd07c770017ed3711ddde35f37a.tgz#2fd4327901d9496ffacbaecd9c53bad7c41cadda"
|
||||
integrity sha512-JzRaQ5Em1fuEcbR3nUsMNYaIYrOT1iMheenjCvzZblJcjv/3JIuxXN7RCNT5i6lRkLodW5ojCGhR7n5yvnNKrw==
|
||||
"@prisma/engines-version@6.7.0-36.3cff47a7f5d65c3ea74883f1d736e41d68ce91ed":
|
||||
version "6.7.0-36.3cff47a7f5d65c3ea74883f1d736e41d68ce91ed"
|
||||
resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-6.7.0-36.3cff47a7f5d65c3ea74883f1d736e41d68ce91ed.tgz#4ec7c8ee187924a910ec244e3790412d1069d723"
|
||||
integrity sha512-EvpOFEWf1KkJpDsBCrih0kg3HdHuaCnXmMn7XFPObpFTzagK1N0Q0FMnYPsEhvARfANP5Ok11QyoTIRA2hgJTA==
|
||||
|
||||
"@prisma/engines@6.6.0":
|
||||
version "6.6.0"
|
||||
resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-6.6.0.tgz#ef4ae4a9ba0cdf72878a60114d173fc463787bc8"
|
||||
integrity sha512-nC0IV4NHh7500cozD1fBoTwTD1ydJERndreIjpZr/S3mno3P6tm8qnXmIND5SwUkibNeSJMpgl4gAnlqJ/gVlg==
|
||||
"@prisma/engines@6.7.0":
|
||||
version "6.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-6.7.0.tgz#291835aa5df84e9c33a1cfe1566e639909d46627"
|
||||
integrity sha512-3wDMesnOxPrOsq++e5oKV9LmIiEazFTRFZrlULDQ8fxdub5w4NgRBoxtWbvXmj2nJVCnzuz6eFix3OhIqsZ1jw==
|
||||
dependencies:
|
||||
"@prisma/debug" "6.6.0"
|
||||
"@prisma/engines-version" "6.6.0-53.f676762280b54cd07c770017ed3711ddde35f37a"
|
||||
"@prisma/fetch-engine" "6.6.0"
|
||||
"@prisma/get-platform" "6.6.0"
|
||||
"@prisma/debug" "6.7.0"
|
||||
"@prisma/engines-version" "6.7.0-36.3cff47a7f5d65c3ea74883f1d736e41d68ce91ed"
|
||||
"@prisma/fetch-engine" "6.7.0"
|
||||
"@prisma/get-platform" "6.7.0"
|
||||
|
||||
"@prisma/fetch-engine@6.6.0":
|
||||
version "6.6.0"
|
||||
resolved "https://registry.yarnpkg.com/@prisma/fetch-engine/-/fetch-engine-6.6.0.tgz#1b947add9a950b479bb275bf987ef596ad4f94ca"
|
||||
integrity sha512-Ohfo8gKp05LFLZaBlPUApM0M7k43a0jmo86YY35u1/4t+vuQH9mRGU7jGwVzGFY3v+9edeb/cowb1oG4buM1yw==
|
||||
"@prisma/fetch-engine@6.7.0":
|
||||
version "6.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@prisma/fetch-engine/-/fetch-engine-6.7.0.tgz#c8bc042ee6438d62d5bf77aafa6c56cf0002c5d8"
|
||||
integrity sha512-zLlAGnrkmioPKJR4Yf7NfW3hftcvqeNNEHleMZK9yX7RZSkhmxacAYyfGsCcqRt47jiZ7RKdgE0Wh2fWnm7WsQ==
|
||||
dependencies:
|
||||
"@prisma/debug" "6.6.0"
|
||||
"@prisma/engines-version" "6.6.0-53.f676762280b54cd07c770017ed3711ddde35f37a"
|
||||
"@prisma/get-platform" "6.6.0"
|
||||
"@prisma/debug" "6.7.0"
|
||||
"@prisma/engines-version" "6.7.0-36.3cff47a7f5d65c3ea74883f1d736e41d68ce91ed"
|
||||
"@prisma/get-platform" "6.7.0"
|
||||
|
||||
"@prisma/get-platform@6.6.0":
|
||||
version "6.6.0"
|
||||
resolved "https://registry.yarnpkg.com/@prisma/get-platform/-/get-platform-6.6.0.tgz#ebe905a3f0a5e8b3a43dcf08206fd73034af5f0b"
|
||||
integrity sha512-3qCwmnT4Jh5WCGUrkWcc6VZaw0JY7eWN175/pcb5Z6FiLZZ3ygY93UX0WuV41bG51a6JN/oBH0uywJ90Y+V5eA==
|
||||
"@prisma/get-platform@6.7.0":
|
||||
version "6.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@prisma/get-platform/-/get-platform-6.7.0.tgz#967f21f8ad966b941dcb47b153b84958655390d1"
|
||||
integrity sha512-i9IH5lO4fQwnMLvQLYNdgVh9TK3PuWBfQd7QLk/YurnAIg+VeADcZDbmhAi4XBBDD+hDif9hrKyASu0hbjwabw==
|
||||
dependencies:
|
||||
"@prisma/debug" "6.6.0"
|
||||
"@prisma/debug" "6.7.0"
|
||||
|
||||
"@rollup/plugin-alias@^5.1.1":
|
||||
version "5.1.1"
|
||||
@ -4853,11 +4853,6 @@ lru-cache@^10.0.1, lru-cache@^10.2.0, lru-cache@^10.4.3:
|
||||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119"
|
||||
integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==
|
||||
|
||||
lru-cache@^11.1.0:
|
||||
version "11.1.0"
|
||||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-11.1.0.tgz#afafb060607108132dbc1cf8ae661afb69486117"
|
||||
integrity sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A==
|
||||
|
||||
lru-cache@^5.1.1:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920"
|
||||
@ -6141,13 +6136,13 @@ pretty-bytes@^6.1.1:
|
||||
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-6.1.1.tgz#38cd6bb46f47afbf667c202cfc754bffd2016a3b"
|
||||
integrity sha512-mQUvGU6aUFQ+rNvTIAcZuWGRT9a6f6Yrg9bHs4ImKF+HZCEK+plBvnAZYSIQztknZF2qnzNtr6F8s0+IuptdlQ==
|
||||
|
||||
prisma@^6.6.0:
|
||||
version "6.6.0"
|
||||
resolved "https://registry.yarnpkg.com/prisma/-/prisma-6.6.0.tgz#5443374b5a6968f37468d0d501ca1babb7aa8fcd"
|
||||
integrity sha512-SYCUykz+1cnl6Ugd8VUvtTQq5+j1Q7C0CtzKPjQ8JyA2ALh0EEJkMCS+KgdnvKW1lrxjtjCyJSHOOT236mENYg==
|
||||
prisma@^6.7.0:
|
||||
version "6.7.0"
|
||||
resolved "https://registry.yarnpkg.com/prisma/-/prisma-6.7.0.tgz#7890e352bde11f6ec3018802d3fc1bcbe0027bd2"
|
||||
integrity sha512-vArg+4UqnQ13CVhc2WUosemwh6hr6cr6FY2uzDvCIFwH8pu8BXVv38PktoMLVjtX7sbYThxbnZF5YiR8sN2clw==
|
||||
dependencies:
|
||||
"@prisma/config" "6.6.0"
|
||||
"@prisma/engines" "6.6.0"
|
||||
"@prisma/config" "6.7.0"
|
||||
"@prisma/engines" "6.7.0"
|
||||
optionalDependencies:
|
||||
fsevents "2.3.3"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user