Add date and bring back group name in exported filename (#54)

This commit is contained in:
Sebastien Castiel
2024-01-23 16:41:07 -05:00
parent 1bd3f99d38
commit 89ee5ae247
3 changed files with 45 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
import { getPrisma } from '@/lib/prisma'
import contentDisposition from 'content-disposition'
import { NextResponse } from 'next/server'
export async function GET(
@@ -30,10 +31,13 @@ export async function GET(
})
if (!group)
return NextResponse.json({ error: 'Invalid group ID' }, { status: 404 })
const date = new Date().toISOString().split('T')[0]
const filename = `Spliit Export - ${group.name} - ${date}`
return NextResponse.json(group, {
headers: {
'content-type': 'application/json',
'content-disposition': `attachment; filename="Spliit Export.json"`,
'content-disposition': contentDisposition(`${filename}.json`),
},
})
}