Skip to content

Commit

Permalink
Setting up staging
Browse files Browse the repository at this point in the history
  • Loading branch information
pratyush1712 authored May 12, 2024
2 parents 1a1f27a + 46313f0 commit 35411da
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
3 changes: 3 additions & 0 deletions spotify/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
"https://open.spotify.com/track/6Hmj7SrLRbreLVfVS7mV1S?si=0cebc1c168ac4673",
"https://open.spotify.com/track/7MQFT6sNd2S340HoX5pII6?si=cdb04ad9d0564042",
"https://open.spotify.com/track/2Ch7LmS7r2Gy2kc64wv3Bz?si=198167565cbf4663",
"https://open.spotify.com/track/6me7F0aaZjwDo6RJ5MrfBD?si=edb4b1ef64e245a3",
"https://open.spotify.com/track/2UREu1Y8CO4jXkbvqAtP7g?si=fe53e684746d4731",
"https://open.spotify.com/track/4bvHCjknZC3evn7NthBZVt?si=41cb65b179824c06",
"https://open.spotify.com/track/73SpzrcaHk0RQPFP73vqVR?si=afd067059b444ae8",
"https://open.spotify.com/track/5Qnrgqy1pAm9GyNQOgyVFz?si=8e16eb4f29f340b5",
"https://open.spotify.com/track/0AS63m1wHv9n4VVRizK6Hc?si=d70fb5e67f314b05",
"https://open.spotify.com/track/1FpVJ7HpZInE2GvhVE2TwT?si=6c00062680f54a38",
"https://open.spotify.com/track/0WFryfbNKPXVtVQlz5dZ8H?si=924e5247538d42fe",
"https://open.spotify.com/track/0yc6Gst2xkRu0eMLeRMGCX?si=cdd25b91418746ad",
"https://open.spotify.com/track/3ZCTVFBt2Brf31RLEnCkWJ?si=f6c291b7d7314dbb",
"https://open.spotify.com/track/6wsMVa2M6Ktea2UbnVoMvO?si=Cpy9XMjTSwKEQe9a",
Expand Down
21 changes: 18 additions & 3 deletions src/app/api/graphql/route.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { ApolloServer } from "@apollo/server";
import { startServerAndCreateNextHandler } from "@as-integrations/next";

import typeDefs from "@/graphql/schema";
import resolvers from "@/graphql/resolvers";
import { NextApiRequest } from "next";
import { Blogs, Videos } from "@/graphql/database/controllers";
import { BlogModel, VideoModel } from "@/graphql/database/models";
import mongoose from "mongoose";
import { cookies, headers } from "next/headers";
import { decode } from "next-auth/jwt";

const uri = process.env.MONGODB_URI;

Expand All @@ -24,11 +25,25 @@ connectDB();

const apolloServer = new ApolloServer({
typeDefs,
resolvers
resolvers,
introspection: process.env.NEXT_PUBLIC_VERCEL_ENV !== "production",
csrfPrevention: true
});

const handler = startServerAndCreateNextHandler(apolloServer, {
context: async (req: NextApiRequest) => {
context: async (req: Request) => {
if (req.method === "POST") {
const reqCookies = cookies().getAll();
const token = reqCookies.find(cookie => cookie.name === "next-auth.session-token")?.value;
const mutation = headers().get("mutation") === "true";
if (mutation) {
const decoded = await decode({ token, secret: process.env.NEXTAUTH_SECRET! });
if (decoded?.email! !== "[email protected]") {
throw new Error("You are not authorized to perform this action");
}
}
}

return {
dataSources: {
blogs: new Blogs({ modelOrCollection: BlogModel }),
Expand Down
10 changes: 8 additions & 2 deletions src/graphql/client/apolloProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@

import { ApolloLink, HttpLink } from "@apollo/client";
import { NextSSRApolloClient, ApolloNextAppProvider, NextSSRInMemoryCache, SSRMultipartLink } from "@apollo/experimental-nextjs-app-support/ssr";
import { setContext } from "@apollo/client/link/context";

function makeClient() {
const httpLink = new HttpLink({
uri: process.env.NEXT_PUBLIC_URL_SERVER_GRAPHQL,
fetchOptions: { cache: "no-store" },
credentials: "same-origin"
credentials: "include"
});

const authLink = setContext(async (request, { headers }) => {
const mutation = !request?.operationName?.includes("Get");
return { headers: { ...headers, mutation } };
});

return new NextSSRApolloClient({
ssrMode: typeof window === "undefined",
cache: new NextSSRInMemoryCache(),
link: typeof window === "undefined" ? ApolloLink.from([new SSRMultipartLink({ stripDefer: true }), httpLink]) : httpLink
link: typeof window === "undefined" ? ApolloLink.from([new SSRMultipartLink({ stripDefer: true }), httpLink]) : authLink.concat(httpLink)
});
}

Expand Down
3 changes: 3 additions & 0 deletions src/utils/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export const config = {
async signIn({ user }) {
if (closeFriendsEmails.has(user?.email!)) return true;
return false;
},
async session({ session }) {
return session;
}
},
secret: process.env.NEXTAUTH_SECRET
Expand Down
2 changes: 1 addition & 1 deletion src/utils/songs.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"image": "https://i.scdn.co/image/ab67616d0000b27349130b16d4190db1d6822e59", "name": "Never Say Never", "id": "5GYbkDveRD2I8M5ZJ14hWn", "artist": "Justin Bieber", "url": "https://open.spotify.com/track/5GYbkDveRD2I8M5ZJ14hWn?si=4babdfa3d5a24bd9"}, {"image": "https://i.scdn.co/image/ab67616d0000b27346557fdc7325844aa2177155", "name": "In The End - Mellen Gi Remix", "id": "5rAUZy2eDdegBxUVYxePK2", "artist": "Tommee Profitt", "url": "https://open.spotify.com/track/5rAUZy2eDdegBxUVYxePK2?si=f57fef9d11c04921"}, {"image": "https://i.scdn.co/image/ab67616d0000b2732a038d3bf875d23e4aeaa84e", "name": "Happier Than Ever", "id": "4RVwu0g32PAqgUiJoXsdF8", "artist": "Billie Eilish", "url": "https://open.spotify.com/track/4RVwu0g32PAqgUiJoXsdF8?si=c4e9c7b69d8f4080"}, {"image": "https://i.scdn.co/image/ab67616d0000b2737870762a58313ad6f981d664", "name": "Wake Up", "id": "6Hmj7SrLRbreLVfVS7mV1S", "artist": "Arcade Fire", "url": "https://open.spotify.com/track/6Hmj7SrLRbreLVfVS7mV1S?si=0cebc1c168ac4673"}, {"image": "https://i.scdn.co/image/ab67616d0000b273eadcdb5af2bc17655ba73304", "name": "What's Up Danger (with Black Caviar)", "id": "7MQFT6sNd2S340HoX5pII6", "artist": "Blackway", "url": "https://open.spotify.com/track/7MQFT6sNd2S340HoX5pII6?si=cdb04ad9d0564042"}, {"image": "https://i.scdn.co/image/ab67616d0000b2734718e2b124f79258be7bc452", "name": "Die For You", "id": "2Ch7LmS7r2Gy2kc64wv3Bz", "artist": "The Weeknd", "url": "https://open.spotify.com/track/2Ch7LmS7r2Gy2kc64wv3Bz?si=198167565cbf4663"}, {"image": "https://i.scdn.co/image/ab67616d0000b27343e531d5f69170aba281ef43", "name": "Monster", "id": "2UREu1Y8CO4jXkbvqAtP7g", "artist": "Skillet", "url": "https://open.spotify.com/track/2UREu1Y8CO4jXkbvqAtP7g?si=fe53e684746d4731"}, {"image": "https://i.scdn.co/image/ab67616d0000b273e452a6e11147f3e56aee6f5b", "name": "Aararaari Raaro", "id": "4bvHCjknZC3evn7NthBZVt", "artist": "Anirudh Ravichander", "url": "https://open.spotify.com/track/4bvHCjknZC3evn7NthBZVt?si=41cb65b179824c06"}, {"image": "https://i.scdn.co/image/ab67616d0000b273f7b7174bef6f3fbfda3a0bb7", "name": "No Time To Die", "id": "73SpzrcaHk0RQPFP73vqVR", "artist": "Billie Eilish", "url": "https://open.spotify.com/track/73SpzrcaHk0RQPFP73vqVR?si=afd067059b444ae8"}, {"image": "https://i.scdn.co/image/ab67616d0000b273ea3ef7697cfd5705b8f47521", "name": "Mercy", "id": "0AS63m1wHv9n4VVRizK6Hc", "artist": "Shawn Mendes", "url": "https://open.spotify.com/track/0AS63m1wHv9n4VVRizK6Hc?si=d70fb5e67f314b05"}, {"image": "https://i.scdn.co/image/ab67616d0000b273cb5ec46d6f1d2cf8d36d3663", "name": "Legends Never Die", "id": "1FpVJ7HpZInE2GvhVE2TwT", "artist": "League of Legends", "url": "https://open.spotify.com/track/1FpVJ7HpZInE2GvhVE2TwT?si=6c00062680f54a38"}, {"image": "https://i.scdn.co/image/ab67616d0000b27312b69bf576f5e80291f75161", "name": "Apocalypse", "id": "0yc6Gst2xkRu0eMLeRMGCX", "artist": "Cigarettes After Sex", "url": "https://open.spotify.com/track/0yc6Gst2xkRu0eMLeRMGCX?si=cdd25b91418746ad"}, {"image": "https://i.scdn.co/image/ab67616d0000b273f2248cf6dad1d6c062587249", "name": "everything i wanted", "id": "3ZCTVFBt2Brf31RLEnCkWJ", "artist": "Billie Eilish", "url": "https://open.spotify.com/track/3ZCTVFBt2Brf31RLEnCkWJ?si=f6c291b7d7314dbb"}, {"image": "https://i.scdn.co/image/ab67616d0000b273086334217996ebabea5bef33", "name": "Kyun Main Jaagoon", "id": "6wsMVa2M6Ktea2UbnVoMvO", "artist": "Shafqat Amanat Ali", "url": "https://open.spotify.com/track/6wsMVa2M6Ktea2UbnVoMvO?si=Cpy9XMjTSwKEQe9a"}, {"image": "https://i.scdn.co/image/ab67616d0000b27354e544672baa16145d67612b", "name": "Jo Bhi Main", "id": "2MmAYegcUty1DmG0Gw7AMh", "artist": "Mohit Chauhan", "url": "https://open.spotify.com/track/2MmAYegcUty1DmG0Gw7AMh?si=ce84c8e6c7764a1f"}, {"image": "https://i.scdn.co/image/ab67616d0000b2730f431c71dd2ac4dafc0c828f", "name": "Maa", "id": "4SuA85PaD8GFTPYwKNYDe1", "artist": "Shankar Mahadevan", "url": "https://open.spotify.com/track/4SuA85PaD8GFTPYwKNYDe1?si=cc19e466b89649fc"}, {"image": "https://i.scdn.co/image/ab67616d0000b273d304ba2d71de306812eebaf4", "name": "Night Changes", "id": "5O2P9iiztwhomNh8xkR9lJ", "artist": "One Direction", "url": "https://open.spotify.com/track/5O2P9iiztwhomNh8xkR9lJ?si=7c94c4e6cd6845aa"}, {"image": "https://i.scdn.co/image/ab67616d0000b273aefd88c6793b26679a570036", "name": "I Built A Friend (2020)", "id": "68XhCrBajUR64h6wv4eYYW", "artist": "Alec Benjamin", "url": "https://open.spotify.com/track/68XhCrBajUR64h6wv4eYYW?si=b5e9e237f299453c"}, {"image": "https://i.scdn.co/image/ab67616d0000b273e7f1ff44b74df429307f4164", "name": "Zindagi Kuch Toh Bata (Reprise)", "id": "6TGX01ExmdHyOG72fqUU3Q", "artist": "Pritam", "url": "https://open.spotify.com/track/6TGX01ExmdHyOG72fqUU3Q?si=420ea8fe1be74d1b"}, {"image": "https://i.scdn.co/image/ab67616d0000b2735a63efb352e4b9cf64b5b6e4", "name": "Manzar Hai Ye Naya", "id": "0Y0MPg9LRfajmMm6vOlj1o", "artist": "Shashwat Sachdev", "url": "https://open.spotify.com/track/0Y0MPg9LRfajmMm6vOlj1o?si=9dd4a7acaff8438c"}, {"image": "https://i.scdn.co/image/ab67616d0000b2730acb5a72549287bf33b51b71", "name": "Senorita", "id": "3TAhWtQnpoL5Vl9VQPl9fU", "artist": "Farhan Akhtar", "url": "https://open.spotify.com/track/3TAhWtQnpoL5Vl9VQPl9fU?si=1d4dbf5994f24fd6"}, {"image": "https://i.scdn.co/image/ab67616d0000b2736a942b2b8ec9c67ef5512287", "name": "Manja", "id": "6o1o5SVSqVPLKAnZxRQz4x", "artist": "Amit Trivedi", "url": "https://open.spotify.com/track/6o1o5SVSqVPLKAnZxRQz4x?si=f50e2794aeaa4707"}, {"image": "https://i.scdn.co/image/ab67616d0000b273118be9c812b6bc1d979827ae", "name": "Sajde", "id": "7kiZ6Zf66oX6yMovt3gC1a", "artist": "Shankar-Ehsaan-Loy", "url": "https://open.spotify.com/track/7kiZ6Zf66oX6yMovt3gC1a?si=8cf352c791db421e"}]
[{"image": "https://i.scdn.co/image/ab67616d0000b27349130b16d4190db1d6822e59", "name": "Never Say Never", "id": "5GYbkDveRD2I8M5ZJ14hWn", "artist": "Justin Bieber", "url": "https://open.spotify.com/track/5GYbkDveRD2I8M5ZJ14hWn?si=4babdfa3d5a24bd9"}, {"image": "https://i.scdn.co/image/ab67616d0000b27346557fdc7325844aa2177155", "name": "In The End - Mellen Gi Remix", "id": "5rAUZy2eDdegBxUVYxePK2", "artist": "Tommee Profitt", "url": "https://open.spotify.com/track/5rAUZy2eDdegBxUVYxePK2?si=f57fef9d11c04921"}, {"image": "https://i.scdn.co/image/ab67616d0000b2732a038d3bf875d23e4aeaa84e", "name": "Happier Than Ever", "id": "4RVwu0g32PAqgUiJoXsdF8", "artist": "Billie Eilish", "url": "https://open.spotify.com/track/4RVwu0g32PAqgUiJoXsdF8?si=c4e9c7b69d8f4080"}, {"image": "https://i.scdn.co/image/ab67616d0000b2737870762a58313ad6f981d664", "name": "Wake Up", "id": "6Hmj7SrLRbreLVfVS7mV1S", "artist": "Arcade Fire", "url": "https://open.spotify.com/track/6Hmj7SrLRbreLVfVS7mV1S?si=0cebc1c168ac4673"}, {"image": "https://i.scdn.co/image/ab67616d0000b273eadcdb5af2bc17655ba73304", "name": "What's Up Danger (with Black Caviar)", "id": "7MQFT6sNd2S340HoX5pII6", "artist": "Blackway", "url": "https://open.spotify.com/track/7MQFT6sNd2S340HoX5pII6?si=cdb04ad9d0564042"}, {"image": "https://i.scdn.co/image/ab67616d0000b2734718e2b124f79258be7bc452", "name": "Die For You", "id": "2Ch7LmS7r2Gy2kc64wv3Bz", "artist": "The Weeknd", "url": "https://open.spotify.com/track/2Ch7LmS7r2Gy2kc64wv3Bz?si=198167565cbf4663"}, {"image": "https://i.scdn.co/image/ab67616d0000b2731cc17bae5ee17cce117e198a", "name": "Evergreen", "id": "6me7F0aaZjwDo6RJ5MrfBD", "artist": "Richy Mitch & The Coal Miners", "url": "https://open.spotify.com/track/6me7F0aaZjwDo6RJ5MrfBD?si=edb4b1ef64e245a3"}, {"image": "https://i.scdn.co/image/ab67616d0000b27343e531d5f69170aba281ef43", "name": "Monster", "id": "2UREu1Y8CO4jXkbvqAtP7g", "artist": "Skillet", "url": "https://open.spotify.com/track/2UREu1Y8CO4jXkbvqAtP7g?si=fe53e684746d4731"}, {"image": "https://i.scdn.co/image/ab67616d0000b273e452a6e11147f3e56aee6f5b", "name": "Aararaari Raaro", "id": "4bvHCjknZC3evn7NthBZVt", "artist": "Anirudh Ravichander", "url": "https://open.spotify.com/track/4bvHCjknZC3evn7NthBZVt?si=41cb65b179824c06"}, {"image": "https://i.scdn.co/image/ab67616d0000b273f7b7174bef6f3fbfda3a0bb7", "name": "No Time To Die", "id": "73SpzrcaHk0RQPFP73vqVR", "artist": "Billie Eilish", "url": "https://open.spotify.com/track/73SpzrcaHk0RQPFP73vqVR?si=afd067059b444ae8"}, {"image": "https://i.scdn.co/image/ab67616d0000b273820e2ac14772ae3162c6d479", "name": "Fourth of July", "id": "5Qnrgqy1pAm9GyNQOgyVFz", "artist": "Sufjan Stevens", "url": "https://open.spotify.com/track/5Qnrgqy1pAm9GyNQOgyVFz?si=8e16eb4f29f340b5"}, {"image": "https://i.scdn.co/image/ab67616d0000b273ea3ef7697cfd5705b8f47521", "name": "Mercy", "id": "0AS63m1wHv9n4VVRizK6Hc", "artist": "Shawn Mendes", "url": "https://open.spotify.com/track/0AS63m1wHv9n4VVRizK6Hc?si=d70fb5e67f314b05"}, {"image": "https://i.scdn.co/image/ab67616d0000b273cb5ec46d6f1d2cf8d36d3663", "name": "Legends Never Die", "id": "1FpVJ7HpZInE2GvhVE2TwT", "artist": "League of Legends", "url": "https://open.spotify.com/track/1FpVJ7HpZInE2GvhVE2TwT?si=6c00062680f54a38"}, {"image": "https://i.scdn.co/image/ab67616d0000b273c820a9669147be3addd7f221", "name": "hotline (edit)", "id": "0WFryfbNKPXVtVQlz5dZ8H", "artist": "Billie Eilish", "url": "https://open.spotify.com/track/0WFryfbNKPXVtVQlz5dZ8H?si=924e5247538d42fe"}, {"image": "https://i.scdn.co/image/ab67616d0000b27312b69bf576f5e80291f75161", "name": "Apocalypse", "id": "0yc6Gst2xkRu0eMLeRMGCX", "artist": "Cigarettes After Sex", "url": "https://open.spotify.com/track/0yc6Gst2xkRu0eMLeRMGCX?si=cdd25b91418746ad"}, {"image": "https://i.scdn.co/image/ab67616d0000b273f2248cf6dad1d6c062587249", "name": "everything i wanted", "id": "3ZCTVFBt2Brf31RLEnCkWJ", "artist": "Billie Eilish", "url": "https://open.spotify.com/track/3ZCTVFBt2Brf31RLEnCkWJ?si=f6c291b7d7314dbb"}, {"image": "https://i.scdn.co/image/ab67616d0000b273086334217996ebabea5bef33", "name": "Kyun Main Jaagoon", "id": "6wsMVa2M6Ktea2UbnVoMvO", "artist": "Shafqat Amanat Ali", "url": "https://open.spotify.com/track/6wsMVa2M6Ktea2UbnVoMvO?si=Cpy9XMjTSwKEQe9a"}, {"image": "https://i.scdn.co/image/ab67616d0000b27354e544672baa16145d67612b", "name": "Jo Bhi Main", "id": "2MmAYegcUty1DmG0Gw7AMh", "artist": "Mohit Chauhan", "url": "https://open.spotify.com/track/2MmAYegcUty1DmG0Gw7AMh?si=ce84c8e6c7764a1f"}, {"image": "https://i.scdn.co/image/ab67616d0000b2730f431c71dd2ac4dafc0c828f", "name": "Maa", "id": "4SuA85PaD8GFTPYwKNYDe1", "artist": "Shankar Mahadevan", "url": "https://open.spotify.com/track/4SuA85PaD8GFTPYwKNYDe1?si=cc19e466b89649fc"}, {"image": "https://i.scdn.co/image/ab67616d0000b273d304ba2d71de306812eebaf4", "name": "Night Changes", "id": "5O2P9iiztwhomNh8xkR9lJ", "artist": "One Direction", "url": "https://open.spotify.com/track/5O2P9iiztwhomNh8xkR9lJ?si=7c94c4e6cd6845aa"}, {"image": "https://i.scdn.co/image/ab67616d0000b273aefd88c6793b26679a570036", "name": "I Built A Friend (2020)", "id": "68XhCrBajUR64h6wv4eYYW", "artist": "Alec Benjamin", "url": "https://open.spotify.com/track/68XhCrBajUR64h6wv4eYYW?si=b5e9e237f299453c"}, {"image": "https://i.scdn.co/image/ab67616d0000b273e7f1ff44b74df429307f4164", "name": "Zindagi Kuch Toh Bata (Reprise)", "id": "6TGX01ExmdHyOG72fqUU3Q", "artist": "Pritam", "url": "https://open.spotify.com/track/6TGX01ExmdHyOG72fqUU3Q?si=420ea8fe1be74d1b"}, {"image": "https://i.scdn.co/image/ab67616d0000b2735a63efb352e4b9cf64b5b6e4", "name": "Manzar Hai Ye Naya", "id": "0Y0MPg9LRfajmMm6vOlj1o", "artist": "Shashwat Sachdev", "url": "https://open.spotify.com/track/0Y0MPg9LRfajmMm6vOlj1o?si=9dd4a7acaff8438c"}, {"image": "https://i.scdn.co/image/ab67616d0000b2730acb5a72549287bf33b51b71", "name": "Senorita", "id": "3TAhWtQnpoL5Vl9VQPl9fU", "artist": "Farhan Akhtar", "url": "https://open.spotify.com/track/3TAhWtQnpoL5Vl9VQPl9fU?si=1d4dbf5994f24fd6"}, {"image": "https://i.scdn.co/image/ab67616d0000b2736a942b2b8ec9c67ef5512287", "name": "Manja", "id": "6o1o5SVSqVPLKAnZxRQz4x", "artist": "Amit Trivedi", "url": "https://open.spotify.com/track/6o1o5SVSqVPLKAnZxRQz4x?si=f50e2794aeaa4707"}, {"image": "https://i.scdn.co/image/ab67616d0000b273118be9c812b6bc1d979827ae", "name": "Sajde", "id": "7kiZ6Zf66oX6yMovt3gC1a", "artist": "Shankar-Ehsaan-Loy", "url": "https://open.spotify.com/track/7kiZ6Zf66oX6yMovt3gC1a?si=8cf352c791db421e"}]

0 comments on commit 35411da

Please sign in to comment.