adding route that works with creating user and such

This commit is contained in:
talksik
2022-03-17 22:45:53 -04:00
parent 4b2a7f7043
commit 013d2fcb16
10 changed files with 87 additions and 49 deletions
+9 -7
View File
@@ -1,5 +1,7 @@
import { GoogleUserInfo, User } from "@nirvana/core/models";
import { ObjectId } from "mongodb";
import { User } from "@nirvana/core/models";
import axios from "axios";
import { collections } from "./database.service";
export class UserService {
@@ -13,11 +15,11 @@ export class UserService {
return await collections.users?.insertOne(newUser);
}
static async getGoogleUserInfoWithAccessToken(accessToken: string) {
return await (
await fetch(
`https://www.googleapis.com/oauth2/v1/userinfo?access_token=${accessToken}`
)
).json();
static async getGoogleUserInfoWithAccessToken(
accessToken: string
): Promise<GoogleUserInfo> {
return await axios.get(
`https://www.googleapis.com/oauth2/v1/userinfo?access_token=${accessToken}`
);
}
}