Skip to content

Commit

Permalink
fix[backend]:Remove unnecessary lines and store the base URL in env
Browse files Browse the repository at this point in the history
  • Loading branch information
Kholoudxs55kh committed Jul 24, 2024
1 parent 71c781b commit 16bd07d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
5 changes: 0 additions & 5 deletions src/controllers/api.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const claimPost = async (
let rawClaim: any = turnFalsyPropsToUndefined(req.body);
rawClaim = poormansNormalizer(rawClaim);
rawClaim.effectiveDate = new Date(rawClaim.effectiveDate);
console.log("======== ", rawClaim);
claim = await claimDao.createClaim(userId, rawClaim);
claimData = await claimDao.createClaimData(claim.id, rawClaim.name);
claimImages = await claimDao.createImages(
Expand All @@ -38,7 +37,6 @@ export const claimPost = async (
}

res.status(201).json({ claim, claimData, claimImages });
// res.status(201).json(claim);
};

export const claimGetById = async (
Expand Down Expand Up @@ -75,11 +73,8 @@ export const getAllClaims = async (
const claims = await prisma.claim.findMany();
const claimsData = [];
for (const claim of claims) {
// console.log(claim.id);
const data = await claimDao.getClaimData(claim.id as any);
const images = await claimDao.getClaimImages(claim.id as any);
// console.log(data);
// console.log(claim);
claimsData.push({ data, claim, images });
}
const count = await prisma.claim.count({});
Expand Down
11 changes: 3 additions & 8 deletions src/dao/api.dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ interface ReportI {
export class ClaimDao {
createClaim = async (userId: any, rawClaim: any) => {
const { name, images, ...rest } = rawClaim;
console.log("======== ", rest);
const createdClaim = await prisma.claim.create({
data: {
issuerId: `http://trustclaims.whatscookin.us/users/${userId}`,
issuerId: `${process.env.BASE_URL}/users/${userId}`,
issuerIdType: "URL",
...rest,
},
Expand All @@ -51,7 +50,7 @@ export class ClaimDao {
const image = await prisma.image.create({
data: {
claimId: claimId,
owner: `http://trustclaims.whatscookin.us/users/${userId}`,
owner: `${process.env.BASE_URL}/users/${userId}`,
...img,
},
});
Expand Down Expand Up @@ -82,7 +81,6 @@ export class ClaimDao {

const claimImages = await this.getClaimImages(id);

console.log(claimData);
return { claim, claimData, claimImages };
};

Expand Down Expand Up @@ -124,12 +122,9 @@ export class ClaimDao {
claimData.push({ data, claim, images });
}

console.log(claimData);

const count = await prisma.claim.count({ where: query });

return { claimData, count };
// return { claims, count };
};

getAllClaims = async (page: number, limit: number) => {
Expand Down Expand Up @@ -305,7 +300,7 @@ export class NodeDao {
edgesTo: {
some: {
claim: {
issuerId: `http://trustclaims.whatscookin.us/users/${userId}`,
issuerId: `${process.env.BASE_URL}/users/${userId}`,
issuerIdType: 'URL',
...rawClaim,
},
Expand Down

0 comments on commit 16bd07d

Please sign in to comment.