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.
14 lines
449 B
14 lines
449 B
export default function ToastMiddlewares() {
|
|
return function toast(ctx, next) {
|
|
if (ctx.toast) return next()
|
|
// error success info
|
|
ctx.toast = function (type, message) {
|
|
ctx.cookies.set("toast", JSON.stringify({ type: type, message: encodeURIComponent(message) }), {
|
|
maxAge: 1,
|
|
httpOnly: false,
|
|
path: "/",
|
|
})
|
|
}
|
|
return next()
|
|
}
|
|
}
|
|
|