-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bi 46 review 1 #25
Merged
Merged
Bi 46 review 1 #25
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3e9779c
changes made after review-1
meenalnimje 0d204c5
test error fixed
meenalnimje ed6783f
fixing testing error
meenalnimje 26bf75c
fixing error in testing
meenalnimje 8782dcb
fixing error of testing
meenalnimje 90d53f8
fixing errors in testing query url
meenalnimje 097944c
adding manual url
meenalnimje 7aca49e
prev code to fix the error
meenalnimje 4c5cf23
deployed link added
meenalnimje 77a39bf
Deployed link is added
meenalnimje e852ff9
vercal bot link added for test
meenalnimje 8e9a9bf
after 2nd code review
meenalnimje 380ae5d
switch statement is added for diffrent enviorments
meenalnimje 44dd677
absolute url in testing added
meenalnimje 2dce44c
solving bi-46 issues
meenalnimje 0a6110c
testing for apis
meenalnimje f6a3de9
new link added
meenalnimje 9593a08
cors added
meenalnimje f47f523
resolving error
meenalnimje 3c49fb3
test error resolved
meenalnimje 06f0941
prettier format checked
meenalnimje 7ffaf79
changes after 2nd review done
meenalnimje File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,19 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {} | ||
require('dotenv').config(); | ||
const nextConfig = { | ||
async headers() { | ||
return [ | ||
{ | ||
// matching all API routes | ||
source: "/api/:path*", | ||
headers: [ | ||
{ key: "Access-Control-Allow-Credentials", value: "true" }, | ||
{ key: "Access-Control-Allow-Origin", value: "*" }, | ||
{ key: "Access-Control-Allow-Methods", value: "GET,OPTIONS,PATCH,DELETE,POST,PUT" }, | ||
{ key: "Access-Control-Allow-Headers", value: "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" }, | ||
] | ||
} | ||
] | ||
} | ||
} | ||
|
||
module.exports = nextConfig |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import searchAlgorithm from '../utils/searchAlgorithm' | ||
describe('searchAlgorithm', () => { | ||
const colleges = [{ name: 'Massachusetts Institute of Technology (MIT)', country: 'United States', city: 'Cambridge' }] | ||
it('returns filtered results when input and data are provided', () => { | ||
const input = 'mass' | ||
|
||
const result = searchAlgorithm(input, colleges) | ||
|
||
expect(result).toEqual([{ name: 'Massachusetts Institute of Technology (MIT)', country: 'United States', city: 'Cambridge' }]) | ||
}) | ||
it('returns an empty array when either input is not provided', () => { | ||
const input = '' | ||
|
||
const result = searchAlgorithm(input, colleges) | ||
|
||
expect(result).toEqual([]) | ||
}) | ||
it('returns an empty array when either input doesnot match with the college name,city or country', () => { | ||
const input = 'xyw' | ||
|
||
const result = searchAlgorithm(input, colleges) | ||
|
||
expect(result).toEqual([]) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,16 +6,15 @@ import { gql } from 'graphql-tag' | |
import { startServerAndCreateNextHandler } from '@as-integrations/next' | ||
|
||
// The connection string for mongodb connection. | ||
const uri = process.env.MONGODB_URI || 'mongodb+srv://bacpactech:[email protected]' | ||
const uri = process.env.MONGODB_URI | ||
const client = new MongoClient(uri) | ||
|
||
async function getUniversityName(id) { | ||
try { | ||
const database = client.db('bacpac') | ||
const universities = database.collection('universities') | ||
const university = await universities.findOne({ id }) | ||
console.log('url', uri) | ||
return university.name | ||
const universityList = await universities.findOne({ id }) | ||
return universityList.name | ||
} catch (error) { | ||
console.log(error) | ||
} | ||
|
@@ -24,8 +23,8 @@ async function getUniversityList() { | |
try { | ||
const database = client.db('bacpac') | ||
const universities = database.collection('universities') | ||
const university = await universities.find().toArray() | ||
return university | ||
const universityList = await universities.find().toArray() | ||
return universityList | ||
} catch (error) { | ||
console.log('this is error from get all unversity list side', error) | ||
} | ||
|
@@ -57,7 +56,7 @@ const typeDefs = gql` | |
` | ||
|
||
let plugins = [] | ||
const graphQLref = process.env.GRAPHQL_REF || 'bacpac-nbq1vs@current' | ||
const graphQLref = process.env.GRAPHQL_REF | ||
//Next.js auto assigns NODE_ENV value as development for 'next dev' command, and production for other commands | ||
if (process.env.NODE_ENV === 'production') { | ||
plugins = [ | ||
|
@@ -75,7 +74,6 @@ const server = new ApolloServer({ | |
typeDefs, | ||
plugins, | ||
}) | ||
|
||
const handler = startServerAndCreateNextHandler(server) | ||
|
||
//Exports the handler function to be used as a Next.js API route handler. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { gql } from '@apollo/client' | ||
export const query = gql` | ||
query getUniversityList { | ||
universityList { | ||
id | ||
name | ||
score | ||
country | ||
city | ||
} | ||
} | ||
` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment such that:
// TODO: Figure out a way to _not_ use a deployed vercel instance for GraphQL