diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..87ab44c
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020 Jarrod Thibodeau
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/README.md b/README.md
index c3ea954..c6fced9 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,543 @@
-# TODO
+# mcgqlapi
-- Complete README and Docs
-- Write a test for a product that does not exist
-- Figure out what do about titles that do not have reviews yet
-- Release!
\ No newline at end of file
+The unofficial API for [Metacritic](https://metacritic.com)
+
+## Table of Contents
+- [Endpoint](#endpoint)
+- [Queries](#queries)
+ - [game](#game)
+ - [games](#games)
+ - [movie](#movie)
+ - [movies](#movies)
+ - [tvshow](#tvshow)
+ - [tvshows](#tvshows)
+ - [album](#album)
+ - [albums](#albums)
+- [Soon to be added](#soon-to-be-added)
+- [FAQ](#faq)
+- [Find a bug?](#find-a-bug)
+- [Want to contribute?](#want-to-contribute)
+- [Donate](#donate)
+
+## Endpoint
+All queries need to be directed to `https://mcgqlapi.com`.
+
+You can mess around with the API [here](https://mcgqlapi.com) to get a feel for things.
+
+If you do not want to use the playground above, I recommend using something like [Altair](https://altair.sirmuel.design/)
+
+## Queries
+### game
+**Retrieve a game from Metacritic**
+
+**Input (Game type)**
+
+
+ Field |
+ Type |
+ Description |
+
+
+ title |
+ String (required) |
+ The title of the game |
+
+
+ platform |
+ String (required) |
+
+ The platform the game is on. Supported platforms are...
+
+ - pc
+ - ios
+ - dreamcast
+ - gameboy advance
+ - ds
+ - 3ds
+ - nintendo 64
+ - gamecube
+ - wii
+ - wii u
+ - switch
+ - playstation
+ - playstation 2
+ - playstation 3
+ - playstation 4
+ - psp
+ - playstation vita
+ - xbox
+ - xbox 360
+ - xbox one
+ |
+
+
+
+**Returnable Fields (GameInfo type)**
+
+
+ Field |
+ Type |
+ Description |
+
+
+ url |
+ String |
+ The Metacritic URL associated to the product |
+
+
+ title |
+ String |
+ Title of the product |
+
+
+ platform |
+ String |
+ Platform the product is on |
+
+
+ criticScore |
+ Int |
+ The Metacritic score of the product |
+
+
+ developer |
+ String |
+ The developer of the game |
+
+
+ publisher |
+ [String] |
+ The publisher(s) of the game |
+
+
+ genres |
+ [String] |
+ The genres of the product |
+
+
+ numOfCriticReviews |
+ Int |
+ The num of overall critic reviews on the product |
+
+
+ numOfPositiveCriticReviews |
+ Int |
+ The number of critic reviews that were positive |
+
+
+ numOfMixedCriticReviews |
+ Int |
+ The number of critic reviews that were mixed |
+
+
+ numOfNegativeCriticReviews |
+ Int |
+ The number of critic reviews that were negative |
+
+
+ productImage |
+ String |
+ A URL to an image of the product |
+
+
+
+## games
+**Retrieve a list of games from Metacritic**
+
+**Input**
+
+
+ Type |
+ Description |
+
+
+ [Game] (required) |
+ A list of Game types, please refer to the game query input |
+
+
+
+**Returnable Values**
+
+
+ Type |
+ Description |
+
+
+ [GameInfo] |
+ A list of GameInfo types, please refer to the game query return values |
+
+
+
+
+## movie
+**Retrieve a movie from Metacritic**
+
+**Input (Movie type)**
+
+
+ Field |
+ Type |
+ Description |
+
+
+ title |
+ String (required) |
+ The title of the movie |
+
+
+ year |
+ String (required) |
+ The year the movie was released. This is required due to the nature of remakes |
+
+
+
+**Returnable Values (MovieInfo type)**
+
+
+ Field |
+ Type |
+ Description |
+
+
+ url |
+ String |
+ The Metacritic URL associated to the product |
+
+
+ title |
+ String |
+ Title of the product |
+
+
+ criticScore |
+ Int |
+ The Metacritic score of the product |
+
+
+ year |
+ String |
+ The year the movie was released |
+
+
+ director |
+ [String] |
+ The director(s) of the movie |
+
+
+ genres |
+ [String] |
+ The genres of the product |
+
+
+ cast |
+ String |
+ A list of actors/actresses in the movie |
+
+
+ rating |
+ String |
+ The movie rating from the MPAA (Motion Picture Association of America) |
+
+
+ runtime |
+ String |
+ How long the movie is |
+
+
+ summary |
+ String |
+ A small blurb about what the movie is about |
+
+
+ numOfCriticReviews |
+ Int |
+ The num of overall critic reviews on the product |
+
+
+ numOfPositiveCriticReviews |
+ Int |
+ The number of critic reviews that were positive |
+
+
+ numOfMixedCriticReviews |
+ Int |
+ The number of critic reviews that were mixed |
+
+
+ numOfNegativeCriticReviews |
+ Int |
+ The number of critic reviews that were negative |
+
+
+ productImage |
+ String |
+ A URL to an image of the product |
+
+
+
+## movies
+**Retrieve a list of movies from Metacritic**
+
+**Input**
+
+
+ Type |
+ Description |
+
+
+ [Movie] (required) |
+ A list of Movie types, please refer to the movie query input |
+
+
+
+**Returnable Values**
+
+
+ Type |
+ Description |
+
+
+ [MovieInfo] |
+ A list of MovieInfo types, please refer to the movie query return values |
+
+
+
+## tvshow
+**Retrieve a tvshow from Metacritic**
+
+**Input (TVShow type)**
+
+
+ Field |
+ Type |
+ Description |
+
+
+ title |
+ String (required) |
+ The title of the game |
+
+
+ season |
+ String |
+ The particular season of the show, if no season is provided, then an overview of the show (all seasons) will be grabbed |
+
+
+
+**Returnable Values (TVShowInfo type)**
+
+
+ Field |
+ Type |
+ Description |
+
+
+ url |
+ String |
+ The Metacritic URL associated to the product |
+
+
+ title |
+ String |
+ Title of the product |
+
+
+ criticScore |
+ Int |
+ The Metacritic score of the product |
+
+
+ genres |
+ [String] |
+ The genres of the product |
+
+
+ summary |
+ String |
+ Small blurb about what the show/season is about |
+
+
+ numOfCriticReviews |
+ Int |
+ The num of overall critic reviews on the product |
+
+
+ numOfPositiveCriticReviews |
+ Int |
+ The number of critic reviews that were positive |
+
+
+ numOfMixedCriticReviews |
+ Int |
+ The number of critic reviews that were mixed |
+
+
+ numOfNegativeCriticReviews |
+ Int |
+ The number of critic reviews that were negative |
+
+
+ productImage |
+ String |
+ A URL to an image of the product |
+
+
+
+## tvshows
+**Retrieve a list of tv shows from Metacritic**
+
+**Input**
+
+
+ Type |
+ Description |
+
+
+ [TVShow] (required) |
+ A list of TVShow types, please refer to the tvshow query input |
+
+
+
+**Returnable Values**
+
+
+ Type |
+ Description |
+
+
+ [TVShowInfo] |
+ A list of TVShowInfo types, please refer to the tvshow query return values |
+
+
+
+## album
+**Retrieve a album from Metacritic**
+
+**Input (Album type)**
+
+
+ Field |
+ Type |
+ Description |
+
+
+ album |
+ String (required) |
+ The title of the album |
+
+
+ artist |
+ String (required) |
+ The artist of the album |
+
+
+
+**Returnable Values (AlbumInfo type)**
+
+
+ Field |
+ Type |
+ Description |
+
+
+ url |
+ String |
+ The Metacritic URL associated to the product |
+
+
+ title |
+ String |
+ Title of the product |
+
+
+ criticScore |
+ Int |
+ The Metacritic score of the product |
+
+
+ publisher |
+ String |
+ The publisher of the album |
+
+
+ genres |
+ [String] |
+ The genres of the product |
+
+
+ numOfCriticReviews |
+ Int |
+ The num of overall critic reviews on the product |
+
+
+ numOfPositiveCriticReviews |
+ Int |
+ The number of critic reviews that were positive |
+
+
+ numOfMixedCriticReviews |
+ Int |
+ The number of critic reviews that were mixed |
+
+
+ numOfNegativeCriticReviews |
+ Int |
+ The number of critic reviews that were negative |
+
+
+ productImage |
+ String |
+ A URL to an image of the product |
+
+
+
+## albums
+**Retrieve a list of albums from Metacritic**
+
+**Input**
+
+
+ Type |
+ Description |
+
+
+ [Album] (required) |
+ A list of Album types, please refer to the album query input |
+
+
+
+**Returnable Values**
+
+
+ Type |
+ Description |
+
+
+ [AlbumInfo] |
+ A list of AlbumInfo types, please refer to the album query return values |
+
+
+
+## Soon to be added
+Features to be added down the road
+- Support to get information based on a person/company
+- Support getting the individual reviews for a specific product
+
+## FAQ
+**Why is the first request slow?**
+
+If it's the first time a particular product is being requested, it will go to Metacritic to get the information, which is why it's slow. However, after the first request is done, any subsequent request will be significantly faster.
+
+**When will the new features be implemented?**
+
+I will hope to add new stuff in the year of 2020 barring there isn't a swarm of issues once release happens
+
+## Find a bug?
+Feel free to make a new issue in the issues tab of the repository. I will try my best to be as responsive as possible.
+
+## Want to contribute?
+Feel free to submit a PR if you think you have a good contribution to the API! Whether it be a new feature or a bug fix, any help is highly appreciated.
+
+## Donate
+If you would like to show your support or help server costs, feel free to donate to me [here](paypal.me/jarrodthibodeau).
\ No newline at end of file
diff --git a/src/actions/get-info.js b/src/actions/get-info.js
index af1d0ab..baf2130 100644
--- a/src/actions/get-info.js
+++ b/src/actions/get-info.js
@@ -56,8 +56,8 @@ module.exports = async function getInfo(url, input, type) {
}
if (isNaN(details.criticScore)) {
- logger.error(`Product not found`, input);
- throw new Error(`Product not found for: ${JSON.stringify(input, 2)}, ${type}`);
+ logger.error(`Product has no reviews or does not exist`, input);
+ throw new Error(`Product has no reviews or does not exist for: ${JSON.stringify(input, 2)}, ${type}`);
}
if (process.env.SAVE_TO_DB == 'true') {
@@ -70,7 +70,7 @@ module.exports = async function getInfo(url, input, type) {
return details;
} catch (err) {
- logger.error('Error getting info', err);
+ logger.error('Error getting info ', err);
throw new Error(err);
}
};
diff --git a/src/helpers/validation.js b/src/helpers/validation.js
index 4549257..144c931 100644
--- a/src/helpers/validation.js
+++ b/src/helpers/validation.js
@@ -3,6 +3,7 @@ function isGamePlatformValid(platform) {
'pc',
'ios',
'dreamcast',
+ 'gameboy advance',
'ds',
'3ds',
'nintendo 64',
diff --git a/src/schema.js b/src/schema.js
index 41f5bae..b63d6a6 100644
--- a/src/schema.js
+++ b/src/schema.js
@@ -14,17 +14,17 @@ module.exports = gql`
type GameInfo {
url: String!
- title: String
- platform: String
- criticScore: Int
- developer: String
- publisher: [String]
- genres: [String]
- numOfCriticReviews: Int
- numOfPositiveCriticReviews: Int
- numOfMixedCriticReviews: Int
- numOfNegativeCriticReviews: Int
- productImage: String
+ title: String!
+ platform: String!
+ criticScore: Int!
+ developer: String!
+ publisher: [String!]
+ genres: [String!]
+ numOfCriticReviews: Int!
+ numOfPositiveCriticReviews: Int!
+ numOfMixedCriticReviews: Int!
+ numOfNegativeCriticReviews: Int!
+ productImage: String!
}
input Game {
@@ -34,16 +34,16 @@ module.exports = gql`
type AlbumInfo {
url: String!
- album: String
- artist: String
- criticScore: Int
- publisher: String
- genres: [String]
- numOfCriticReviews: Int
- numOfPositiveCriticReviews: Int
- numOfMixedCriticReviews: Int
- numOfNegativeCriticReviews: Int
- productImage: String
+ album: String!
+ artist: String!
+ criticScore: Int!
+ publisher: String!
+ genres: [String!]
+ numOfCriticReviews: Int!
+ numOfPositiveCriticReviews: Int!
+ numOfMixedCriticReviews: Int!
+ numOfNegativeCriticReviews: Int!
+ productImage: String!
}
input Album {
@@ -53,20 +53,20 @@ module.exports = gql`
type MovieInfo {
url: String!
- title: String
- criticScore: Int
- year: String
- director: [String]
- genres: [String]
- cast: [String]
- rating: String
- runtime: String
- summary: String
- numOfCriticReviews: Int
- numOfPositiveCriticReviews: Int
- numOfMixedCriticReviews: Int
- numOfNegativeCriticReviews: Int
- productImage: String
+ title: String!
+ criticScore: Int!
+ year: String!
+ director: [String!]
+ genres: [String!]
+ cast: [String!]
+ rating: String!
+ runtime: String!
+ summary: String!
+ numOfCriticReviews: Int!
+ numOfPositiveCriticReviews: Int!
+ numOfMixedCriticReviews: Int!
+ numOfNegativeCriticReviews: Int!
+ productImage: String!
}
input Movie {
@@ -76,16 +76,16 @@ module.exports = gql`
type TVShowInfo {
url: String!
- title: String
- season: String
- criticScore: Int
- genres: [String]
- summary: String
- numOfCriticReviews: Int
- numOfPositiveCriticReviews: Int
- numOfMixedCriticReviews: Int
- numOfNegativeCriticReviews: Int
- productImage: String
+ title: String!
+ season: String!
+ criticScore: Int!
+ genres: [String!]
+ summary: String!
+ numOfCriticReviews: Int!
+ numOfPositiveCriticReviews: Int!
+ numOfMixedCriticReviews: Int!
+ numOfNegativeCriticReviews: Int!
+ productImage: String!
}
input TVShow {
diff --git a/test/integration/tv/tvshow-test.js b/test/integration/tv/tvshow-test.js
index 00fb12b..df3b6f6 100644
--- a/test/integration/tv/tvshow-test.js
+++ b/test/integration/tv/tvshow-test.js
@@ -61,7 +61,7 @@ describe('TV Show', () => {
tvshow.criticScore.should.be.a('number');
});
- it('should rertieve an overview of a tv season if a season is not passed in', async () => {
+ it('should retrieve an overview of a tv season if a season is not passed in', async () => {
const tvShowQuery = gql`
query($input: TVShow!) {
tvshow(input: $input) {