1
0
Fork 0
mirror of synced 2024-07-12 17:56:07 +12:00
budibase/packages/server/middleware/routeHandlers/getRecord.js

16 lines
449 B
JavaScript
Raw Normal View History

const StatusCodes = require("../../utilities/statusCodes")
const { getRecordKey } = require("./helpers")
module.exports = async ctx => {
try {
ctx.body = await ctx.instance.recordApi.load(
getRecordKey(ctx.params.appname, ctx.request.path)
)
ctx.response.status = StatusCodes.OK
} catch (e) {
// need to be catching for 404s here
ctx.response.status = StatusCodes.INTERAL_ERROR
ctx.response.body = e.message
}
}