A11yWatch/a11ywatch-core

View on GitHub
src/core/controllers/issues/set/index.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { getIssue } from "../find";
import { SUCCESS } from "../../../../core/strings";

export const addIssue = async ({ userId, url, issue }: any) => {
  const [issueExist, collection] = await getIssue({ userId, url }, true);

  if (!issueExist) {
    const id = await collection.countDocuments({ userId, url });

    await collection.insertOne({
      userId,
      issue,
      id,
      url,
    });
  }

  return { code: 200, success: true, message: SUCCESS };
};