All files / apps/wp-editor/server/api/changesets/[id]/items/[key] [action].post.ts

0% Statements 0/15
0% Branches 0/10
0% Functions 0/2
0% Lines 0/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                                                                               
import type { ItemKey } from "../../../../../../shared/types/ItemKey.ts";
import {
    applyItem,
    dryRunItem,
    repull,
    restoreItem,
    review,
} from "../../../../../services/operations.ts";
 
export default defineEventHandler((event) =>
    refusing(async () => {
        const store = useStore(event);
        const id = getRouterParam(event, "id")!;
        const key = getRouterParam(event, "key") as ItemKey;
 
        switch (getRouterParam(event, "action")) {
            case "seen":
                return review.seen(store, id, key);
            case "confirm":
                return review.confirm(store, id, key);
            case "unconfirm":
                return review.unconfirm(store, id, key);
            case "reject":
                return review.reject(store, id, key);
            case "unreject":
                return review.unreject(store, id, key);
            case "apply":
                return applyItem(store, useWordPress(event), id, key);
            case "dry-run":
                return dryRunItem(store, useWordPress(event), id, key);
            case "restore":
                return restoreItem(store, useWordPress(event), id, key);
            case "repull":
                return repull(store, useWordPress(event), id, key);
            default:
                throw createError({ statusCode: 404 });
        }
    }),
);