trying to add everything but models are messy with mongoose...just nonsense from higher perspective
This commit is contained in:
@@ -6,7 +6,6 @@ import { ObjectId } from "mongodb";
|
||||
import Relationship from "@nirvana/core/models/relationship.model";
|
||||
import { UserService } from "../services/user.service";
|
||||
import { authCheck } from "../middleware/auth";
|
||||
import { collections } from "../services/database.service";
|
||||
|
||||
export default function getConversationRoutes() {
|
||||
const router = express.Router();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import express, { Application, Request, Response } from "express";
|
||||
|
||||
import SearchResponse from "@nirvana/core/responses/search.response";
|
||||
import { User } from "@nirvana/core/models";
|
||||
import { UserService } from "../services/user.service";
|
||||
import { authCheck } from "../middleware/auth";
|
||||
|
||||
@@ -11,30 +10,30 @@ export default function getSearchRoutes() {
|
||||
router.use(express.json());
|
||||
|
||||
// get user details based on id token
|
||||
router.get("/", authCheck, handleSearch);
|
||||
// router.get("/", authCheck, handleSearch);
|
||||
|
||||
return router;
|
||||
}
|
||||
|
||||
async function handleSearch(req: Request, res: Response) {
|
||||
try {
|
||||
const { query } = req.query;
|
||||
// async function handleSearch(req: Request, res: Response) {
|
||||
// try {
|
||||
// const { query } = req.query;
|
||||
|
||||
if (!query) {
|
||||
res.status(400).send("No search query provided!");
|
||||
return;
|
||||
}
|
||||
// if (!query) {
|
||||
// res.status(400).send("No search query provided!");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// text search on users
|
||||
const users: User[] | null = await UserService.getUsersLikeEmailAndName(
|
||||
query as string
|
||||
);
|
||||
// // text search on users
|
||||
// const users: User[] | null = await UserService.getUsersLikeEmailAndName(
|
||||
// query as string
|
||||
// );
|
||||
|
||||
const resObj = new SearchResponse(users ?? []);
|
||||
// const resObj = new SearchResponse(users ?? []);
|
||||
|
||||
res.send(resObj);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
res.status(500).send(`something went wrong`);
|
||||
}
|
||||
}
|
||||
// res.send(resObj);
|
||||
// } catch (error) {
|
||||
// console.log(error);
|
||||
// res.status(500).send(`something went wrong`);
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { GoogleUserInfo, User } from "@nirvana/core/models";
|
||||
import express, { Application, Request, Response } from "express";
|
||||
|
||||
import GoogleUserInfo from "@nirvana/core/models/googleUserInfo.model";
|
||||
import { OAuth2Client } from "google-auth-library";
|
||||
import { ObjectID } from "bson";
|
||||
import { ObjectId } from "mongodb";
|
||||
import { User } from "@nirvana/core/models/user.model";
|
||||
import { UserService } from "../services/user.service";
|
||||
import { UserStatus } from "../../core/models/user.model";
|
||||
import { authCheck } from "../middleware/auth";
|
||||
import { collections } from "../services/database.service";
|
||||
|
||||
const client = new OAuth2Client(
|
||||
"423533244953-banligobgbof8hg89i6cr1l7u0p7c2pk.apps.googleusercontent.com"
|
||||
@@ -83,8 +83,6 @@ async function login(req: Request, res: Response) {
|
||||
// create user if not exists
|
||||
const insertResult = await UserService.createUserIfNotExists(newUser);
|
||||
|
||||
newUser._id = insertResult?.insertedId;
|
||||
|
||||
// create jwt token with new user info
|
||||
|
||||
insertResult
|
||||
|
||||
Reference in New Issue
Block a user