Skip to content

Commit

Permalink
change: directory structure
Browse files Browse the repository at this point in the history
- 将来のnuxt4の仕様に則り、ディレクトリ構造を変更
- sharedディレクトリの作成
  • Loading branch information
Liry24 committed Mar 6, 2025
1 parent cadbabc commit ddb0c1d
Show file tree
Hide file tree
Showing 125 changed files with 72 additions and 84 deletions.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script lang="ts" setup>
import type { ItemCategory, SetupItem } from '#types';
import { twMerge } from 'tailwind-merge';
import { VueDraggable } from 'vue-draggable-plus';
Expand Down Expand Up @@ -29,8 +28,8 @@ const addItem = async (id: number) => {
if (!data)
return useToast().add(
getErrors().editSetup.addItemFailed.client.title,
getErrors().editSetup.addItemFailed.client.description
getErrors().editSetup.addItemFailed.client!.title,
getErrors().editSetup.addItemFailed.client!.description
);
const d: SetupItem = { ...data, note: '', unsupported: false };
Expand All @@ -40,8 +39,8 @@ const addItem = async (id: number) => {
if (target.some((i) => i.id === id))
useToast().add(
getErrors().publishSetup.sameItems.client.title,
getErrors().publishSetup.sameItems.client.description
getErrors().publishSetup.sameItems.client!.title,
getErrors().publishSetup.sameItems.client!.description
);
else {
target.push(d);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@ const pasteFromClipboard = async () => {
const addItemFromURL = async () => {
if (!inputUrl.value)
return useToast().add(
getErrors().editSetup.emptyUrl.client.title,
getErrors().editSetup.emptyUrl.client.description
getErrors().editSetup.emptyUrl.client!.title,
getErrors().editSetup.emptyUrl.client!.description
);
try {
new URL(inputUrl.value);
} catch {
return useToast().add(
getErrors().editSetup.invalidUrl.client.title,
getErrors().editSetup.invalidUrl.client.description
getErrors().editSetup.invalidUrl.client!.title,
getErrors().editSetup.invalidUrl.client!.description
);
}
const url = new URL(inputUrl.value);
if (url.hostname.split('.').slice(-2).join('.') !== 'booth.pm')
return useToast().add(
getErrors().editSetup.invalidUrl.client.title,
getErrors().editSetup.invalidUrl.client.description
getErrors().editSetup.invalidUrl.client!.title,
getErrors().editSetup.invalidUrl.client!.description
);
const id = url.pathname.split('/').slice(-1)[0];
if (!id || !Number.isInteger(Number(id)))
return useToast().add(
getErrors().editSetup.invalidUrl.client.title,
getErrors().editSetup.invalidUrl.client.description
getErrors().editSetup.invalidUrl.client!.title,
getErrors().editSetup.invalidUrl.client!.description
);
emit('add', Number(id));
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ onMounted(async () => {
query: { id: props.item.id },
});
if (response.data) item.value = response.data;
if (response.data)
item.value = {
...response.data,
note: '',
unsupported: false,
};
if (!response.data) item.value.outdated = true;
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion components/ui/footer.vue → app/components/ui/footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const modal_feedback = ref(false);
to="https://liria.work"
new-tab
label="Liria"
icon="avatio:liria"
icon="liria"
variant="link"
class="gap-1 text-sm font-[Montserrat] font-semibold"
/>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions composables/setup.ts → app/composables/setup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { ApiResponse } from '#types';

export const useDeleteSetup = async (id: number) => {
const { error } = await $fetch<ApiResponse<{ id: number }>>('/api/setup', {
method: 'DELETE',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 9 additions & 9 deletions pages/setup/edit.vue → app/pages/setup/edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,30 @@ const itemsFlatten = computed(() => [
]);
const errorCheck = (options: { toast?: boolean } = { toast: true }) => {
const returnError = (message: string) => {
const returnError = (message: string | undefined) => {
publishing.value = false;
if (options.toast) useToast().add(message);
if (options.toast && message) useToast().add(message);
return true;
};
if (!title.value?.length)
return returnError(getErrors().publishSetup.noTitle.client.title);
return returnError(getErrors().publishSetup.noTitle.client?.title);
if (title.value.length > setupLimits().title)
return returnError(getErrors().publishSetup.tooLongTitle.client.title);
return returnError(getErrors().publishSetup.tooLongTitle.client?.title);
if (description.value.length > setupLimits().description)
return returnError(
getErrors().publishSetup.tooLongDescription.client.title
getErrors().publishSetup.tooLongDescription.client?.title
);
if (tags.value.length > setupLimits().tags)
return returnError(getErrors().publishSetup.tooManyTags.client.title);
return returnError(getErrors().publishSetup.tooManyTags.client?.title);
if (!itemsFlatten.value.length)
return returnError(getErrors().publishSetup.noItems.client.title);
return returnError(getErrors().publishSetup.noItems.client?.title);
if (itemsFlatten.value.length > setupLimits().items)
return returnError(getErrors().publishSetup.tooManyItems.client.title);
return returnError(getErrors().publishSetup.tooManyItems.client?.title);
return false;
};
Expand Down Expand Up @@ -112,7 +112,7 @@ const PublishSetup = async () => {
publishing.value = false;
return useToast().add(
'投稿に失敗しました',
response.error!.client.title || '不明なエラー'
response.error!.client?.title || '不明なエラー'
);
}
Expand Down
File renamed without changes.
10 changes: 6 additions & 4 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,18 @@ export default defineNuxtConfig({
},
fonts: { families: [{ name: 'Murecho', provider: 'google' }] },
icon: {
customCollections: [{ prefix: 'avatio', dir: './public/icons/avatio' }],

customCollections: [{ prefix: 'avatio', dir: './app/assets/icons' }],
clientBundle: {
icons: [
'lucide:search',
'lucide:settings',
'lucide:plus',
'lucide:x',
'lucide:check',
'svg-spinners:ring-resize',
'lucide:bookmark',
'lucide:sun',
'lucide:moon',
'lucide:palette',
],
scan: true,
includeCustomCollections: true,
Expand Down Expand Up @@ -252,7 +254,7 @@ export default defineNuxtConfig({
flowType: 'pkce',
},
},
types: './types/database.ts',
types: './shared/types/database.d.ts',
},
turnstile: { siteKey: import.meta.env.NUXT_TURNSTILE_SITE_KEY },
});
Expand Down
18 changes: 0 additions & 18 deletions pages/confirm.vue

This file was deleted.

1 change: 0 additions & 1 deletion server/api/image.delete.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { serverSupabaseUser } from '#supabase/server';
import { createStorage } from 'unstorage';
import s3Driver from 'unstorage/drivers/s3';
import type { ApiResponse } from '~/types';

const runtime = useRuntimeConfig();

Expand Down
1 change: 0 additions & 1 deletion server/api/image.put.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import sharp from 'sharp';
import { createStorage } from 'unstorage';
import s3Driver from 'unstorage/drivers/s3';
import { serverSupabaseUser } from '#supabase/server';
import type { ApiResponse } from '~/types';

export interface RequestBody {
image: string;
Expand Down
3 changes: 0 additions & 3 deletions server/api/item/booth.get.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { serverSupabaseClient } from '#supabase/server';
import type { H3Event } from 'h3';
import type { Item, ApiResponse, ItemCategory } from '~/types';
import type { Booth } from '~/types/booth';
import specificItemCategory from '~/utils/specificItemCategory';

interface fetchedItem extends Omit<Item, 'updated_at'> {
tags: string[];
Expand Down
17 changes: 13 additions & 4 deletions server/api/setup.delete.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { serverSupabaseClient, serverSupabaseUser } from '#supabase/server';
import type { ApiResponse } from '~/types';

export interface RequestBody {
id: number;
Expand All @@ -12,7 +11,11 @@ export default defineEventHandler(
if (!user) throw new Error();
} catch {
return {
error: { status: 403, message: 'Forbidden.' },
error: {
status: 403,
message: 'Forbidden.',
client: { title: 'アクセス拒否' },
},
data: null,
};
}
Expand All @@ -29,7 +32,10 @@ export default defineEventHandler(

if (!setupData)
return {
error: { status: 404, message: 'Failed to get setup.' },
error: {
status: 404,
message: 'Failed to get setup.',
},
data: null,
};

Expand All @@ -40,7 +46,10 @@ export default defineEventHandler(

if (error)
return {
error: { status: 1, message: 'Failed to delete setup.' },
error: {
status: 1,
message: 'Failed to delete setup.',
},
data: null,
};

Expand Down
7 changes: 5 additions & 2 deletions server/api/setup.get.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { serverSupabaseClient } from '#supabase/server';
import type { ApiResponse, SetupClient, SetupDB } from '~/types';

export interface RequestQuery {
id: number;
Expand Down Expand Up @@ -78,10 +77,14 @@ export default defineEventHandler(
if (!data)
return {
data: null,
error: { status: 404, message: 'Failed to get setup.' },
error: {
status: 404,
message: 'Failed to get setup.',
},
};

// アイテムをカテゴリごとに動的にグループ化
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const groupedItems: Record<string, any[]> = {};
for (const i of data.items) {
if (!i.data) continue;
Expand Down
3 changes: 0 additions & 3 deletions server/api/setup.put.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { serverSupabaseClient, serverSupabaseUser } from '#supabase/server';
import type { ApiResponse, ItemCategory } from '~/types';
import getErrors, { type ErrorType } from '~/utils/getErrors';
import setupLimits from '~/utils/setupLimits';

export interface RequestBody {
name: string;
Expand Down
2 changes: 0 additions & 2 deletions server/api/setups/bookmarks.get.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { serverSupabaseClient, serverSupabaseUser } from '#supabase/server';
import type { ApiResponse, SetupClient, SetupDB } from '~/types';
import setupMoldingClient from '~/utils/setupMoldingClient';

interface RequestQuery {
userId: string;
Expand Down
6 changes: 3 additions & 3 deletions server/api/setups/latest.get.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { serverSupabaseClient } from '#supabase/server';
import type { ApiResponse, SetupClient } from '~/types';
import setupMoldingClient from '~/utils/setupMoldingClient';

interface RequestQuery {
page: number;
Expand Down Expand Up @@ -54,6 +52,7 @@ export default defineEventHandler(
verified
),
nsfw,
likes,
source
),
note,
Expand All @@ -80,7 +79,8 @@ export default defineEventHandler(
query.page * query.perPage,
query.page * query.perPage + (query.perPage - 1)
)
.order('created_at', { ascending: false });
.order('created_at', { ascending: false })
.returns<SetupDB[]>();

if (!data || !count)
return {
Expand Down
5 changes: 2 additions & 3 deletions server/api/setups/user.get.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { serverSupabaseClient } from '#supabase/server';
import type { ApiResponse, SetupClient } from '~/types';
import setupMoldingClient from '~/utils/setupMoldingClient';

interface RequestQuery {
userId: string;
Expand Down Expand Up @@ -81,7 +79,8 @@ export default defineEventHandler(
query.page * query.perPage,
query.page * query.perPage + (query.perPage - 1)
)
.order('created_at', { ascending: false });
.order('created_at', { ascending: false })
.returns<SetupDB[]>();

if (!data || !count)
return {
Expand Down
1 change: 0 additions & 1 deletion server/api/shopVerification/verify.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
serverSupabaseUser,
} from '#supabase/server';
import type { H3Event } from 'h3';
import boothSubDomain from '~/utils/boothSubDomain';

// レスポンス型の定義
interface VerificationResponse {
Expand Down
File renamed without changes.
Loading

0 comments on commit ddb0c1d

Please sign in to comment.