fixed undefined variable

This commit is contained in:
Martina 2021-04-19 18:12:26 -07:00
parent c2628fc497
commit 7de91e784b
2 changed files with 11 additions and 0 deletions

View File

@ -9,6 +9,7 @@ export default async ({ ids, sanitize = false, includeFiles = false }) => {
// const slateFiles = () =>
// DB.raw("json_agg(?? order by ?? asc) as ??", ["files", "slate_files.createdAt", "objects"]);
let query;
const slateFiles = () =>
DB.raw("coalesce(json_agg(?? order by ?? asc) filter (where ?? is not null), '[]') as ??", [
"files",

View File

@ -4,6 +4,8 @@ import * as Strings from "~/common/strings";
import * as Powergate from "~/node_common/powergate";
export default async (req, res) => {
console.log("INSIDE API/V1/GET");
console.log({ authorization: req.headers.authorization });
if (Strings.isEmpty(req.headers.authorization)) {
return res.status(404).send({
decorator: "NO_API_KEY_PROVIDED",
@ -16,6 +18,7 @@ export default async (req, res) => {
const key = await Data.getAPIKeyByKey({
key: parsed,
});
console.log({ key });
if (!key) {
return res.status(403).send({
@ -35,6 +38,8 @@ export default async (req, res) => {
id: key.ownerId,
});
console.log({ user });
if (!user) {
return res.status(404).send({ decorator: "API_KEY_OWNER_NOT_FOUND", error: true });
}
@ -52,6 +57,7 @@ export default async (req, res) => {
},
};
console.log({ reformattedUser });
let slates = await Data.getSlatesByUserId({
ownerId: user.id,
sanitize: true,
@ -59,6 +65,8 @@ export default async (req, res) => {
publicOnly: req.body.data && req.body.data.private ? false : true,
});
console.log({ slates });
if (!slates) {
return res.status(404).send({
decorator: "COULD_NOT_FETCH_SLATES",
@ -104,6 +112,8 @@ export default async (req, res) => {
};
});
console.log({ reformattedSlates });
return res
.status(200)
.send({ decorator: "V1_GET", slates: reformattedSlates, user: reformattedUser });