You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
811 B

import { app } from "@/global"
function success(data = null, message = null) {
app.currentContext.status = 200
ctx.set("Content-Type", "application/json")
return app.currentContext.body = { success: true, error: message, data }
}
function error(data = null, message = null) {
const ctx = app.currentContext
ctx.status = 500
ctx.set("Content-Type", "application/json")
return ctx.body = { success: false, error: message, data }
}
function response(statusCode, data = null, message = null) {
const ctx = app.currentContext
ctx.status = statusCode
ctx.set("Content-Type", "application/json")
return ctx.body = { success: true, error: message, data }
}
const R = {
success,
error,
response,
}
R.SUCCESS = 200
R.ERROR = 500
R.NOTFOUND = 404
export { R }