Merge pull request #24 from Yiling-J/refactor-data-folder-10365341915644708364
Refactor data storage to `data/` folder and remove env files
This commit is contained in:
15 files changed
+38
-37
No files matched your search
@@ -1 +0,0 @@
|
||||
DATABASE_URL="file:./data/dev.db"
|
||||
+1
-4
@@ -6,8 +6,5 @@ out
|
||||
*.log
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
!.env.test
|
||||
data/files/*
|
||||
!data/files/.gitkeep
|
||||
data/
|
||||
*.db
|
||||
Whitespace-only changes.
+3
-3
@@ -1,8 +1,8 @@
|
||||
import 'dotenv/config'
|
||||
import { defineConfig, env } from 'prisma/config'
|
||||
import { defineConfig } from 'prisma/config'
|
||||
import path from 'node:path'
|
||||
|
||||
export default defineConfig({
|
||||
datasource: {
|
||||
url: env('DATABASE_URL'),
|
||||
url: `file:${path.join(process.cwd(), 'data', 'data.db')}`,
|
||||
},
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
import { PrismaLibSql } from '@prisma/adapter-libsql'
|
||||
import { PrismaClient } from './generated/prisma/client'
|
||||
|
||||
const adapter = new PrismaLibSql({ url: process.env.DATABASE_URL || 'file:./dev.db' })
|
||||
const adapter = new PrismaLibSql({ url: 'file:./data/data.db' })
|
||||
|
||||
export const prisma = new PrismaClient({ adapter })
|
||||
Vendored
+7
@@ -1,4 +1,11 @@
|
||||
/// <reference types="bun-types" />
|
||||
|
||||
declare module '*.html' {
|
||||
const content: string
|
||||
export default content
|
||||
}
|
||||
|
||||
declare module '*.webp' {
|
||||
const content: string
|
||||
export default content
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
import { Hono } from 'hono'
|
||||
import { serveStatic } from 'hono/bun'
|
||||
import { cors } from 'hono/cors'
|
||||
import { existsSync, mkdirSync } from 'node:fs'
|
||||
import asset from './api/asset'
|
||||
import character from './api/character'
|
||||
import equipment from './api/equipment'
|
||||
@@ -13,6 +14,11 @@ import pose from './api/pose'
|
||||
import setting from './api/setting'
|
||||
import index from './ui/index.html'
|
||||
|
||||
// Ensure data directories exist
|
||||
if (!existsSync('data/files')) {
|
||||
mkdirSync('data/files', { recursive: true })
|
||||
}
|
||||
|
||||
const app = new Hono()
|
||||
|
||||
// Enable CORS
|
||||
|
||||
@@ -19,7 +19,9 @@ export const BUILTIN_EXPRESSIONS: ExpressionItem[] = Array.from({ length: 9 }, (
|
||||
)
|
||||
|
||||
export class ExpressionService {
|
||||
async listExpressions(options: { page?: number; limit?: number } = {}): Promise<ExpressionItem[]> {
|
||||
async listExpressions(
|
||||
options: { page?: number; limit?: number } = {},
|
||||
): Promise<ExpressionItem[]> {
|
||||
const { page = 1, limit = 20 } = options
|
||||
const skip = (page - 1) * limit
|
||||
|
||||
|
||||
@@ -3,10 +3,7 @@ import { ulid } from 'ulidx'
|
||||
import { Prisma } from '../generated/prisma/client'
|
||||
|
||||
export class OutfitService {
|
||||
async listOutfits(
|
||||
options: { page?: number; limit?: number } = {},
|
||||
equipmentId?: string,
|
||||
) {
|
||||
async listOutfits(options: { page?: number; limit?: number } = {}, equipmentId?: string) {
|
||||
const { page = 1, limit = 20 } = options
|
||||
const skip = (page - 1) * limit
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@ import { Backpack, Frame, Settings, Smile, Users } from 'lucide-react'
|
||||
import logo from 'public/logo.webp'
|
||||
import { Link, useLocation } from 'react-router-dom'
|
||||
import {
|
||||
Sidebar,
|
||||
SidebarContent,
|
||||
SidebarFooter,
|
||||
SidebarGroup,
|
||||
SidebarGroupContent,
|
||||
SidebarMenu,
|
||||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
Sidebar,
|
||||
SidebarContent,
|
||||
SidebarFooter,
|
||||
SidebarGroup,
|
||||
SidebarGroupContent,
|
||||
SidebarMenu,
|
||||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
} from './ui/sidebar'
|
||||
|
||||
// Menu items.
|
||||
|
||||
@@ -428,10 +428,7 @@ export const CreateLookDialog: React.FC<CreateLookDialogProps> = ({
|
||||
))}
|
||||
</div>
|
||||
{/* Loading Indicator */}
|
||||
<div
|
||||
ref={poseRef}
|
||||
className="h-10 w-full flex items-center justify-center p-4"
|
||||
>
|
||||
<div ref={poseRef} className="h-10 w-full flex items-center justify-center p-4">
|
||||
{posesLoading && <Loader2 className="w-8 h-8 animate-spin text-stone-400" />}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
|
||||
@@ -19,7 +19,11 @@ export const LoadOutfitDialog: React.FC<LoadOutfitDialogProps> = ({
|
||||
onOpenChange,
|
||||
onSelect,
|
||||
}) => {
|
||||
const { items: outfits, loading, ref } = useInfiniteScroll<OutfitItem>({
|
||||
const {
|
||||
items: outfits,
|
||||
loading,
|
||||
ref,
|
||||
} = useInfiniteScroll<OutfitItem>({
|
||||
fetchData: async (page, limit) => {
|
||||
const res = await client.outfits.$get({
|
||||
query: {
|
||||
|
||||
@@ -87,11 +87,7 @@ export default function Characters() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
<CreateCharacterDialog
|
||||
open={createOpen}
|
||||
onOpenChange={setCreateOpen}
|
||||
onSuccess={reset}
|
||||
/>
|
||||
<CreateCharacterDialog open={createOpen} onOpenChange={setCreateOpen} onSuccess={reset} />
|
||||
<style>{`@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }`}</style>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -107,11 +107,7 @@ export default function Expressions() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
<CreateExpressionDialog
|
||||
open={createOpen}
|
||||
onOpenChange={setCreateOpen}
|
||||
onSuccess={reset}
|
||||
/>
|
||||
<CreateExpressionDialog open={createOpen} onOpenChange={setCreateOpen} onSuccess={reset} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user