1
0
Fork 0
mirror of synced 2024-07-06 23:10:57 +12:00
budibase/packages/server/middleware/routeHandlers/getRecord.js
2020-03-10 10:05:09 +00:00

16 lines
449 B
JavaScript

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
}
}