Initial commit: MOPC platform with Docker deployment setup

Full Next.js 15 platform with tRPC, Prisma, PostgreSQL, NextAuth.
Includes production Dockerfile (multi-stage, port 7600), docker-compose
with registry-based image pull, Gitea Actions CI workflow, nginx config
for portal.monaco-opc.com, deployment scripts, and DEPLOYMENT.md guide.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-30 13:41:32 +01:00
commit a606292aaa
290 changed files with 70691 additions and 0 deletions

View File

@@ -0,0 +1,125 @@
import { NextRequest, NextResponse } from 'next/server'
import { LocalStorageProvider } from '@/lib/storage/local-provider'
import { getContentType } from '@/lib/storage'
import * as fs from 'fs/promises'
const provider = new LocalStorageProvider()
/**
* Handle GET requests for file downloads
*/
export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url)
const key = searchParams.get('key')
const action = searchParams.get('action')
const expires = searchParams.get('expires')
const sig = searchParams.get('sig')
// Validate required parameters
if (!key || !action || !expires || !sig) {
return NextResponse.json(
{ error: 'Missing required parameters' },
{ status: 400 }
)
}
// Verify signature and expiry
const isValid = LocalStorageProvider.verifySignature(
key,
action,
parseInt(expires),
sig
)
if (!isValid) {
return NextResponse.json(
{ error: 'Invalid or expired signature' },
{ status: 403 }
)
}
if (action !== 'download') {
return NextResponse.json(
{ error: 'Invalid action for GET request' },
{ status: 400 }
)
}
try {
const filePath = provider.getAbsoluteFilePath(key)
const data = await fs.readFile(filePath)
const contentType = getContentType(key)
return new NextResponse(data, {
headers: {
'Content-Type': contentType,
'Cache-Control': 'private, max-age=3600',
},
})
} catch (error) {
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
return NextResponse.json({ error: 'File not found' }, { status: 404 })
}
console.error('Error serving file:', error)
return NextResponse.json(
{ error: 'Internal server error' },
{ status: 500 }
)
}
}
/**
* Handle PUT requests for file uploads
*/
export async function PUT(request: NextRequest) {
const { searchParams } = new URL(request.url)
const key = searchParams.get('key')
const action = searchParams.get('action')
const expires = searchParams.get('expires')
const sig = searchParams.get('sig')
// Validate required parameters
if (!key || !action || !expires || !sig) {
return NextResponse.json(
{ error: 'Missing required parameters' },
{ status: 400 }
)
}
// Verify signature and expiry
const isValid = LocalStorageProvider.verifySignature(
key,
action,
parseInt(expires),
sig
)
if (!isValid) {
return NextResponse.json(
{ error: 'Invalid or expired signature' },
{ status: 403 }
)
}
if (action !== 'upload') {
return NextResponse.json(
{ error: 'Invalid action for PUT request' },
{ status: 400 }
)
}
try {
const contentType = request.headers.get('content-type') || 'application/octet-stream'
const data = Buffer.from(await request.arrayBuffer())
await provider.putObject(key, data, contentType)
return NextResponse.json({ success: true }, { status: 200 })
} catch (error) {
console.error('Error uploading file:', error)
return NextResponse.json(
{ error: 'Internal server error' },
{ status: 500 }
)
}
}