Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions next/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"react-query": "^3.39.2",
"rehype-slug": "^6.0.0",
"remark-gfm": "^4.0.0",
"swiper": "^8.4.5"
"swiper": "^8.4.5",
"uuid": "^13.0.0"
},
"devDependencies": {
"cypress": "^14.4.0",
Expand Down
5 changes: 5 additions & 0 deletions next/pages/api/datasets/getDataset.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import axios from "axios";
import { capitalize } from 'lodash';
import { validate as isUuid } from "uuid";

const API_URL = `${process.env.NEXT_PUBLIC_API_URL}/api/v1/graphql`;

export default async function getDataset(id, locale = 'pt') {
if (!id || !isUuid(id)) {
return null;
}

try {
const res = await axios({
url: API_URL,
Expand Down
8 changes: 7 additions & 1 deletion next/pages/api/tables/getTable.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from "axios";
import { cleanGraphQLResponse } from "../../../utils";
import { capitalize } from 'lodash';
import { validate as isUuid } from "uuid";

const API_URL= `${process.env.NEXT_PUBLIC_API_URL}/api/v1/graphql`

Expand Down Expand Up @@ -146,7 +147,12 @@ async function getTable(id, locale='pt') {
}

export default async function handler(req, res) {
const { id: id, locale } = req.query;
const { id, locale } = req.query;

if (!id || !isUuid(id)) {
return res.status(400).json({ error: "Invalid or missing ID in Table", success: false });
}

const result = await getTable(id, locale);

if(result.errors) return res.status(500).json({error: result.errors, success: false})
Expand Down
6 changes: 6 additions & 0 deletions next/pages/api/tables/getTableColumns.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from "axios";
import { validate as isUuid } from "uuid";

async function getTableColumns(id) {
const API_URL = `${process.env.NEXT_PUBLIC_API_URL}/tables/${id}/columns/`;
Expand All @@ -18,6 +19,11 @@ async function getTableColumns(id) {

export default async function handler(req, res) {
const { id } = req.query;

if (!id || !isUuid(id)) {
return res.status(400).json({ error: "Invalid or missing ID", success: false });
}

const result = await getTableColumns(id);

if (result === "err") return res.status(500).json({ error: "err", success: false });
Expand Down