mirror of
https://github.com/FranP-code/countries.git
synced 2025-10-13 00:02:15 +00:00
Initial commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
37
index.js
Normal file
37
index.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import {ApolloServer, gql} from 'apollo-server';
|
||||
import {countries} from 'countries-list';
|
||||
|
||||
const typeDefs = gql`
|
||||
type Country {
|
||||
code: String
|
||||
name: String
|
||||
native: String
|
||||
phone: String
|
||||
continent: String
|
||||
currency: String
|
||||
languages: [String]
|
||||
emoji: String
|
||||
emojiU: String
|
||||
}
|
||||
|
||||
type Query {
|
||||
countries: [Country]
|
||||
}
|
||||
`;
|
||||
|
||||
const countriesArray = Object.keys(countries).map(code => ({
|
||||
code,
|
||||
...countries[code]
|
||||
}));
|
||||
|
||||
const resolvers = {
|
||||
Query: {
|
||||
countries: () => countriesArray
|
||||
}
|
||||
};
|
||||
|
||||
const server = new ApolloServer({typeDefs, resolvers});
|
||||
|
||||
server.listen().then(({url}) => {
|
||||
console.log(`🚀 Server ready at ${url}`);
|
||||
});
|
||||
4800
package-lock.json
generated
Normal file
4800
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
19
package.json
Normal file
19
package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"engines": {
|
||||
"node": "8"
|
||||
},
|
||||
"scripts": {
|
||||
"pretest": "eslint index.js",
|
||||
"test": "echo \"Error: no test specified\" && exit",
|
||||
"start": "nodemon -r esm index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@trevorblades/eslint-config": "^6.18.0",
|
||||
"apollo-server": "^2.1.0",
|
||||
"countries-list": "^2.3.2",
|
||||
"eslint": "^5.6.1",
|
||||
"esm": "^3.0.84",
|
||||
"graphql": "^14.0.2",
|
||||
"nodemon": "^1.18.4"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user