{"size": 678, "ext": "js", "max_stars_repo_path": "src/routes/artworks/index.json.js", "max_stars_repo_name": "kali60420/lnft", "max_stars_repo_stars_event_min_datetime": "2021-05-20T23:54:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:05:33.000Z", "max_issues_repo_path": "src/routes/artworks/index.json.js", "max_issues_repo_name": "kali60420/lnft", "max_issues_repo_issues_event_min_datetime": "2021-07-22T23:22:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-31T05:45:25.000Z", "max_forks_repo_path": "src/routes/artworks/index.json.js", "max_forks_repo_name": "tokenocean/mintalio", "max_forks_repo_forks_event_min_datetime": "2021-05-21T12:23:34.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T04:04:41.000Z"}
{"max_stars_count": 61, "max_issues_count": 61, "max_forks_count": 20, "avg_line_length": 21.1875, "max_line_length": 79, "alphanum_fraction": 0.5516224189}
import { countArtworks, getLimited } from "$queries/artworks";
import { hbp } from "$lib/api";

export async function get({ headers, locals, query }) {
  let { q } = locals;
  let limit = parseInt(query.get("limit")) || 5000;
  let offset = 0;
  let where = {};
  let order_by = {
    created_at: "desc",
  };

  try {
    let { artworks_aggregate: a } = await q(countArtworks, { where });
    let { artworks } = await q(getLimited, { limit, offset, order_by, where });

    return {
      body: {
        artworks,
        count: a.aggregate.count,
      },
      headers,
    };
  } catch (e) {
    console.log(e);
    return {
      body: {},
      status: 500,
    };
  }
}
