setting up dotenv and stuff

This commit is contained in:
talksik
2022-04-01 11:46:08 -04:00
parent 8a1163dc3f
commit ce0fb7a885
9 changed files with 101 additions and 263 deletions
+1 -42
View File
@@ -1,6 +1,5 @@
import express, { Application, Request, Response } from "express";
import { ContactService } from "../services/contact.service";
import Content from "@nirvana/core/models/content.model";
import GetConversationDetailsResponse from "@nirvana/core/responses/getConversationDetails.response";
import { ObjectId } from "mongodb";
@@ -15,47 +14,7 @@ export default function getConversationRoutes() {
router.use(express.json());
// get data for a one on one conversation
router.get("/:otherUserGoogleUserId", authCheck, getConversationDetails);
// router.get("/:otherUserGoogleUserId", authCheck, getConversationDetails);
return router;
}
async function getConversationDetails(req: Request, res: Response) {
try {
// google user Id of current user
const { userId } = res.locals;
const { otherUserGoogleUserId } = req.params;
// get the "other" user's details
const otherUser = await UserService.getUserByGoogleId(
otherUserGoogleUserId
);
if (!otherUser) {
res.status(404).send("No such user found");
return;
}
// find the relationship between us...if not there just null
const ourRelationship = await ContactService.getRelationship(
userId,
otherUserGoogleUserId
);
// todo: get latest content based on limit count
const latestContent: Content[] = [];
const resObj = new GetConversationDetailsResponse(
otherUser,
false,
ourRelationship ?? undefined,
latestContent
);
res.status(200).send(resObj);
} catch (error) {
console.log(error);
res.status(500).send(`something went wrong`);
}
}