Fixing issue with app DB not being in context for fetch.
This commit is contained in:
parent
fece2b639d
commit
706749af49
|
@ -1,5 +1,5 @@
|
||||||
const { getAllApps } = require("@budibase/backend-core/db")
|
const { getAllApps } = require("@budibase/backend-core/db")
|
||||||
const { updateAppId } = require("@budibase/backend-core/context")
|
const { doInAppContext } = require("@budibase/backend-core/context")
|
||||||
import { search as stringSearch, addRev } from "./utils"
|
import { search as stringSearch, addRev } from "./utils"
|
||||||
import * as controller from "../application"
|
import * as controller from "../application"
|
||||||
import { Application } from "../../../definitions/common"
|
import { Application } from "../../../definitions/common"
|
||||||
|
@ -41,21 +41,23 @@ export async function create(ctx: any, next: any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function read(ctx: any, next: any) {
|
export async function read(ctx: any, next: any) {
|
||||||
updateAppId(ctx.params.appId)
|
await doInAppContext(ctx.params.appId, async () => {
|
||||||
await setResponseApp(ctx)
|
await setResponseApp(ctx)
|
||||||
await next()
|
await next()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function update(ctx: any, next: any) {
|
export async function update(ctx: any, next: any) {
|
||||||
ctx.request.body = await addRev(fixAppID(ctx.request.body, ctx.params))
|
ctx.request.body = await addRev(fixAppID(ctx.request.body, ctx.params))
|
||||||
updateAppId(ctx.params.appId)
|
await doInAppContext(ctx.params.appId, async () => {
|
||||||
await controller.update(ctx)
|
await controller.update(ctx)
|
||||||
await setResponseApp(ctx)
|
await setResponseApp(ctx)
|
||||||
await next()
|
await next()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function destroy(ctx: any, next: any) {
|
export async function destroy(ctx: any, next: any) {
|
||||||
updateAppId(ctx.params.appId)
|
await doInAppContext(ctx.params.appId, async () => {
|
||||||
// get the app before deleting it
|
// get the app before deleting it
|
||||||
await setResponseApp(ctx)
|
await setResponseApp(ctx)
|
||||||
const body = ctx.body
|
const body = ctx.body
|
||||||
|
@ -63,6 +65,7 @@ export async function destroy(ctx: any, next: any) {
|
||||||
// overwrite the body again
|
// overwrite the body again
|
||||||
ctx.body = body
|
ctx.body = body
|
||||||
await next()
|
await next()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
Loading…
Reference in New Issue