Merge branch 'openapi' into worker

This commit is contained in:
ccbikai 2025-05-22 19:41:38 +08:00
commit cf7751a392
16 changed files with 98 additions and 39 deletions

View file

@ -1,6 +1,6 @@
<script setup>
import { ChartTooltip } from '@/components/ui/chart'
import { VisSingleContainer, VisTopoJSONMap, VisTopoJSONMapSelectors } from '@unovis/vue'
import { ChartTooltip } from '@/components/ui/chart'
const id = inject('id')
const time = inject('time')

View file

@ -1,11 +1,11 @@
<script setup>
import { DependencyType } from '@/components/ui/auto-form/interface'
import { LinkSchema, nanoid } from '@@/schemas/link'
import { toTypedSchema } from '@vee-validate/zod'
import { Shuffle, Sparkles } from 'lucide-vue-next'
import { useForm } from 'vee-validate'
import { toast } from 'vue-sonner'
import { z } from 'zod'
import { DependencyType } from '@/components/ui/auto-form/interface'
const props = defineProps({
link: {

View file

@ -1,7 +1,7 @@
<script setup>
import heroImg from '@/assets/images/hero.svg?raw'
import { AreaChart } from 'lucide-vue-next'
import { GitHubIcon } from 'vue3-simple-icons'
import heroImg from '@/assets/images/hero.svg?raw'
const { title, description, github } = useAppConfig()
</script>

View file

@ -1,6 +1,6 @@
<script lang="ts" setup>
import { cn } from '@/lib/utils'
import { computed, onMounted, ref, useSlots } from 'vue'
import { cn } from '@/lib/utils'
const props = withDefaults(defineProps<{
class?: string

View file

@ -1,4 +1,5 @@
import { type ClassValue, clsx } from 'clsx'
import type { ClassValue } from 'clsx'
import { clsx } from 'clsx'
import { twMerge } from 'tailwind-merge'
export function cn(...inputs: ClassValue[]) {

View file

@ -1,4 +1,5 @@
import { type DateValue, fromAbsolute, toCalendarDate } from '@internationalized/date'
import type { DateValue } from '@internationalized/date'
import { fromAbsolute, toCalendarDate } from '@internationalized/date'
export function getTimeZone() {
if (typeof Intl === 'undefined')

View file

@ -10,6 +10,9 @@
},
"aliases": {
"components": "@/components",
"utils": "@/utils"
"utils": "@/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"composables": "@/composables"
}
}

View file

@ -17,7 +17,7 @@ const locales: LocaleObject[] = [
code: 'zh-TW',
file: 'zh-TW.json',
name: '繁體中文',
emoji: '🇹🇼',
emoji: '🇹🇼',
},
{
code: 'fr-FR',

View file

@ -53,8 +53,6 @@ export default defineNuxtConfig({
},
},
sourcemap: false,
future: {
compatibilityVersion: 4,
},

View file

@ -45,12 +45,12 @@
"vaul-vue": "^0.4.1",
"vee-validate": "^4.15.0",
"virtua": "^0.41.2",
"vue-sonner": "^1.3.2",
"vue-sonner": "^2.0.0",
"vue3-simple-icons": "^13.2.0",
"zod": "^3.25.7"
"zod": "^3.25.20"
},
"devDependencies": {
"@antfu/eslint-config": "^4.13.1",
"@antfu/eslint-config": "^4.13.2",
"@nuxt/eslint": "^1.4.1",
"@nuxt/eslint-config": "^1.4.1",
"@nuxthub/core": "^0.8.27",
@ -62,13 +62,13 @@
"clsx": "^2.1.1",
"eslint": "^9.27.0",
"lint-staged": "^16.0.0",
"nuxt": "^3.17.3",
"nuxt": "^3.17.4",
"shadcn-nuxt": "^2.1.0",
"simple-git-hooks": "^2.13.0",
"tailwind-merge": "^3.3.0",
"tailwindcss-animate": "^1.0.7",
"vue-tsc": "^2.2.10",
"wrangler": "^4.15.2"
"wrangler": "^4.16.1"
},
"simple-git-hooks": {
"pre-commit": "npm run lint-staged"

View file

@ -1,5 +1,29 @@
import { LinkSchema } from '@@/schemas/link'
defineRouteMeta({
openAPI: {
description: 'Create a new short link',
requestBody: {
required: true,
content: {
'application/json': {
// Need: https://github.com/nitrojs/nitro/issues/2974
schema: {
type: 'object',
required: ['url'],
properties: {
url: {
type: 'string',
description: 'The URL to shorten',
},
},
},
},
},
},
},
})
export default eventHandler(async (event) => {
const link = await readValidatedBody(event, LinkSchema.parse)

View file

@ -1,3 +1,14 @@
defineRouteMeta({
openAPI: {
description: 'Get the location of the user',
responses: {
200: {
description: 'The location of the user',
},
},
},
})
export default eventHandler((event) => {
const { request: { cf } } = event.context.cloudflare
return {

View file

@ -1,3 +1,17 @@
defineRouteMeta({
openAPI: {
description: 'Verify the site token',
responses: {
200: {
description: 'The site token is valid',
},
default: {
description: 'The site token is invalid',
},
},
},
})
export default eventHandler(() => {
return {
name: 'Sink',

View file

@ -1,5 +1,4 @@
import type { H3Event } from 'h3'
import { getFlag } from '@/utils/flag'
import { parseAcceptLanguage } from 'intl-parse-accept-language'
import { UAParser } from 'ua-parser-js'
import {
@ -13,6 +12,7 @@ import {
Vehicles,
} from 'ua-parser-js/extensions'
import { parseURL } from 'ufo'
import { getFlag } from '@/utils/flag'
function toBlobNumber(blob: string) {
return +blob.replace(/\D/g, '')

30
wrangler.jsonc Normal file
View file

@ -0,0 +1,30 @@
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "sink",
"main": "dist/server/index.mjs",
"assets": {
"binding": "ASSETS",
"directory": "dist/public"
},
"compatibility_date": "2025-05-08",
"compatibility_flags": [
"nodejs_compat"
],
"keep_vars": true,
"upload_source_maps": true,
"ai": {
"binding": "AI"
},
"analytics_engine_datasets": [
{
"binding": "ANALYTICS",
"dataset": "sink"
}
],
"kv_namespaces": [
{
"binding": "KV",
"id": "ef93d42dc4b34969bab404d2e80f8dd3" // IMPORTANT: Change this to your KV namespace ID
}
]
}

View file

@ -1,23 +0,0 @@
name = "sink"
main = "dist/server/index.mjs"
compatibility_date = "2025-05-08"
compatibility_flags = [ "nodejs_compat" ]
keep_vars = true
[dev]
port = 3000
[assets]
directory = "dist/public"
binding = "ASSETS"
[ai]
binding = "AI"
[[kv_namespaces]]
binding = "KV"
id = "ef93d42dc4b34969bab404d2e80f8dd3"
[[analytics_engine_datasets]]
binding = "ANALYTICS"
dataset = "sink"