All files / Bandstand/src/app/api/push/test route.ts

0% Statements 0/14
0% Branches 0/1
0% Functions 0/1
0% Lines 0/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18                                   
export const dynamic = 'force-dynamic'
 
import {requireUser} from '@/lib/guard'
import {route} from '@/lib/route'
import {sendToUser} from '@/lib/push'
 
/** "Send a test": a notification to every device you have turned on. */
export const POST = route(async () => {
  const {user} = await requireUser()
  const sent = await sendToUser(user.id, {
    title: 'Notifications are on',
    body: 'You’ll hear about changes to charts, setlists, rehearsals and proposals here.',
    url: '/account#notifications',
    tag: 'test',
  })
  return Response.json({sent})
})