···204 // If the user is signed in, get an agent which communicates with their server
205 const agent = await getSessionAgent(req, res, ctx)
206 if (!agent) {
207- return res.status(401).json({ error: 'Session required' })
000208 }
209210 // Construct & validate their status record
···215 createdAt: new Date().toISOString(),
216 }
217 if (!Status.validateRecord(record).success) {
218- return res.status(400).json({ error: 'Invalid status' })
000219 }
220221 let uri
···231 uri = res.data.uri
232 } catch (err) {
233 ctx.logger.warn({ err }, 'failed to write record')
234- return res.status(500).json({ error: 'Failed to write record' })
000235 }
236237 try {
···256 )
257 }
258259- res.status(200).json({})
260 })
261 )
262
···204 // If the user is signed in, get an agent which communicates with their server
205 const agent = await getSessionAgent(req, res, ctx)
206 if (!agent) {
207+ return res
208+ .status(401)
209+ .type('html')
210+ .send('<h1>Error: Session required</h1>')
211 }
212213 // Construct & validate their status record
···218 createdAt: new Date().toISOString(),
219 }
220 if (!Status.validateRecord(record).success) {
221+ return res
222+ .status(400)
223+ .type('html')
224+ .send('<h1>Error: Invalid status</h1>')
225 }
226227 let uri
···237 uri = res.data.uri
238 } catch (err) {
239 ctx.logger.warn({ err }, 'failed to write record')
240+ return res
241+ .status(500)
242+ .type('html')
243+ .send('<h1>Error: Failed to write record</h1>')
244 }
245246 try {
···265 )
266 }
267268+ return res.redirect('/')
269 })
270 )
271