Skip to content

Commit

Permalink
fix(zerops): fix build backend + frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
BleedingDev committed Nov 30, 2024
1 parent 8f1ea9e commit a5c22da
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 38 deletions.
1 change: 0 additions & 1 deletion apps/coursition-new-rs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"dependencies": {
"react": "^19.0.0-rc.1",
"react-dom": "^19.0.0-rc.1",
"@preact/signals-react": "^2.2.0",
"@vidstack/react": "^1.12.12"
},
"devDependencies": {
Expand Down
21 changes: 9 additions & 12 deletions apps/coursition-new-rs/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { treaty } from '@elysiajs/eden'
import { Button, Input, Tabs, Textarea } from '@nmit-coursition/ui/design-system'
import { convertSubtitlesToBlob } from '@nmit-coursition/utils'
import { useSignal } from '@preact/signals-react'
import { useActionState } from 'react'
import { useActionState, useState } from 'react'
import { toast } from 'sonner'
import { z } from 'zod'
import { zfd } from 'zod-form-data'
Expand Down Expand Up @@ -44,19 +43,19 @@ const statusStates = [
]

export default function Index() {
const status = useSignal<'idle' | 'upload' | 'parse' | 'done'>('idle')
const [status, setStatus] = useState<'idle' | 'upload' | 'parse' | 'done'>('idle')

const handleSubmit = async (formData: FormData) => {
try {
status.value = 'upload'
setStatus('upload')

const rawFormData = Object.fromEntries(formData.entries())
const type = formData.has('file') ? 'file' : 'url'
const parsedData = fileSchema.parse({ type, ...rawFormData })

const videoSource = parsedData.type === 'file' ? URL.createObjectURL(parsedData.file) : parsedData.url

status.value = 'parse'
setStatus('parse')
const keywordsArray = parsedData.keywords ? parsedData.keywords.split(',').map((word) => `${word}:5`) : []
const output: ('text' | 'vtt' | 'srt')[] = ['text', 'srt', 'vtt']

Expand Down Expand Up @@ -88,11 +87,11 @@ export default function Index() {

if (error) throw new Error(error.value.description)
const { text, srt, vtt } = data
status.value = 'done'
setStatus('done')
return { raw: text, srt, vtt, videoSource }
} catch (error) {
toast.error(`Something went wrong. Reason: ${error instanceof Error ? error.message : 'Unknown.'}`)
status.value = 'idle'
setStatus('idle')
return initialState
}
}
Expand All @@ -102,7 +101,7 @@ export default function Index() {
return (
<div className='flex justify-center h-screen'>
<div className='p-4 max-w-2xl w-full'>
{status.value === 'idle' && (
{status === 'idle' && (
<>
<h1 className='text-2xl font-bold mb-4'>Upload media</h1>
<form className='space-y-4' action={formAction}>
Expand Down Expand Up @@ -157,10 +156,8 @@ export default function Index() {
</form>
</>
)}
{status.value !== 'idle' && status.value !== 'done' && (
<StatusDisplay states={statusStates} status={status.value} />
)}
{status.value === 'done' && (
{status !== 'idle' && status !== 'done' && <StatusDisplay states={statusStates} status={status} />}
{status === 'done' && (
<Tabs
listClassName='h-auto'
triggerClassName='text-lg m-1'
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"@infisical/sdk": "^3.0.3",
"@lemonsqueezy/lemonsqueezy.js": "^4.0.0",
"@mendable/firecrawl-js": "^1.8.4",
"@preact/signals-react": "^2.2.0",
"@prisma/client": "^5.22.0",
"@radix-ui/react-accordion": "^1.2.1",
"@radix-ui/react-checkbox": "^1.1.2",
Expand Down Expand Up @@ -108,5 +107,8 @@
"@nx/workspace": "20.1.2",
"nx": "20.1.2",
"@sinclair/typebox": "0.34.3"
},
"prisma": {
"schema": "./libs/db/src/schema.prisma"
}
}
19 changes: 0 additions & 19 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions zerops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ zerops:
- echo "Upgrading bun to 1.1.38"
- bun upgrade
buildCommands:
- pnpm install
- pnpm install --frozen-lockfile --prefer-offline --prod=false
- bun run postinstall
- bun run validateEnv
- bun x nx build:executable backend --verbose --skip-nx-cache
- ls apps/backend
- pnpm nx build:executable backend --verbose --skip-nx-cache
- ls node_modules/prisma
deployFiles:
- apps/backend/dist
- node_modules/.prisma
- node_modules
cache:
- node_modules
- package.json
Expand All @@ -47,7 +47,7 @@ zerops:
- echo "Installing yt-dlp"
- curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/bin/yt-dlp
- chmod a+rx /usr/bin/yt-dlp # Make executable
start: apps/backend/dist/main
start: PRISMA_QUERY_ENGINE_LIBRARY=./node_modules/prisma; apps/backend/dist/main

deploy:
readinessCheck:
Expand Down

1 comment on commit a5c22da

@vercel
Copy link

@vercel vercel bot commented on a5c22da Nov 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

web – ./apps/legacy_nmit

web-git-master-naucmeits-projects.vercel.app
naucme.it
web-naucmeits-projects.vercel.app

Please sign in to comment.