A11yWatch/a11ywatch-core

View on GitHub
src/core/controllers/history/index.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { historyCollection } from "../../../database";
import { websiteSearchParams } from "../../utils";

export const HistoryController = ({ user } = { user: null }) => ({
  getHistoryItem: async (params: {
    userId?: number;
    url?: string;
    domain?: string;
  }) => {
    const searchProps = websiteSearchParams(params);
    const history = await historyCollection.findOne(searchProps);

    return [history, historyCollection];
  },
  getHistory: async ({ userId }) => {
    return await historyCollection.find({ userId }).limit(100).toArray();
  },
});