-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Amr Ebada
committed
Dec 30, 2019
1 parent
1868cd1
commit 59e1927
Showing
15 changed files
with
210 additions
and
11 deletions.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PORT= | ||
DB_URL= |
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,12 +1,11 @@ | ||
{ | ||
"parser": "babel-eslint", | ||
"extends": [ | ||
"airbnb-base", | ||
"plugin:prettier/recommended" | ||
], | ||
"plugins": [ ], | ||
"extends": ["airbnb-base", "plugin:prettier/recommended"], | ||
"plugins": [], | ||
"env": { | ||
"jest": true | ||
}, | ||
"rules": {} | ||
"rules": { | ||
"no-console": "off" | ||
} | ||
} |
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ coverage | |
dist | ||
node_modules | ||
*.log | ||
.env |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { config } from "dotenv"; | ||
|
||
config(); | ||
|
||
export default { | ||
PORT: process.env.PORT || 5000, | ||
DB_URL: process.env.DB_URL || "" | ||
}; |
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,13 +1,23 @@ | ||
import express from "express"; | ||
import graphQlHTTP from "express-graphql"; | ||
import schema from "./schemas/schema"; | ||
import dbInit from "./models/index"; | ||
import config from "./config"; | ||
|
||
const app = express(); | ||
const PORT = process.env.PORT || 5000; | ||
|
||
app.use("/graphql",graphQlHTTP({ | ||
app.use( | ||
"/graphql", | ||
graphQlHTTP({ | ||
schema, | ||
graphiql:true | ||
})); | ||
graphiql: true | ||
}) | ||
); | ||
|
||
app.listen(PORT,()=> console.log(`server running on port ${PORT}`)) | ||
dbInit() | ||
.then(() => { | ||
app.listen(config.PORT, () => { | ||
console.log(`server running on port ${config.PORT}`); | ||
}); | ||
}) | ||
.catch(err => console.error(err)); |
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,21 @@ | ||
/* eslint-disable new-cap */ | ||
import { Schema, model } from "mongoose"; | ||
|
||
const films = new Schema({ | ||
id: Schema.Types.Number, | ||
characters: [Schema.Types.Number], | ||
created: Schema.Types.String, | ||
director: Schema.Types.String, | ||
edited: Schema.Types.String, | ||
episode_id: Schema.Types.Number, | ||
opening_crawl: Schema.Types.String, | ||
planets: [Schema.Types.Number], | ||
producer: Schema.Types.String, | ||
release_date: Schema.Types.String, | ||
species: [Schema.Types.Number], | ||
starships: [Schema.Types.Number], | ||
title: Schema.Types.String, | ||
vehicles: [Schema.Types.Number] | ||
}); | ||
|
||
export default new model("films", films); |
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,16 @@ | ||
import { connect } from "mongoose"; | ||
import config from "../config"; | ||
|
||
export default () => { | ||
return new Promise((resolve, reject) => { | ||
connect( | ||
config.DB_URL, | ||
err => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
return resolve(); | ||
} | ||
); | ||
}); | ||
}; |
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,19 @@ | ||
/* eslint-disable new-cap */ | ||
import { Schema, model } from "mongoose"; | ||
|
||
const people = new Schema({ | ||
id: Schema.Types.Number, | ||
birth_year: Schema.Types.String, | ||
created: Schema.Types.String, | ||
edited: Schema.Types.String, | ||
eye_color: Schema.Types.String, | ||
gender: Schema.Types.String, | ||
hair_color: Schema.Types.String, | ||
height: Schema.Types.String, | ||
homeworld: Schema.Types.Number, | ||
mass: Schema.Types.String, | ||
name: Schema.Types.String, | ||
skin_color: Schema.Types.String | ||
}); | ||
|
||
export default new model("people", people); |
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,19 @@ | ||
/* eslint-disable new-cap */ | ||
import { Schema, model } from "mongoose"; | ||
|
||
const planets = new Schema({ | ||
id: Schema.Types.Number, | ||
climate: Schema.Types.String, | ||
created: Schema.Types.String, | ||
diameter: Schema.Types.String, | ||
edited: Schema.Types.String, | ||
gravity: Schema.Types.String, | ||
name: Schema.Types.String, | ||
orbital_period: Schema.Types.String, | ||
population: Schema.Types.String, | ||
rotation_period: Schema.Types.String, | ||
surface_water: Schema.Types.String, | ||
terrain: Schema.Types.String | ||
}); | ||
|
||
export default new model("planets", planets); |
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,21 @@ | ||
/* eslint-disable new-cap */ | ||
import { Schema, model } from "mongoose"; | ||
|
||
const species = new Schema({ | ||
id: Schema.Types.Number, | ||
average_height: Schema.Types.String, | ||
average_lifespan: Schema.Types.String, | ||
classification: Schema.Types.String, | ||
created: Schema.Types.String, | ||
designation: Schema.Types.String, | ||
edited: Schema.Types.String, | ||
eye_colors: Schema.Types.String, | ||
hair_colors: Schema.Types.String, | ||
homeworld: Schema.Types.Number, | ||
language: Schema.Types.String, | ||
name: Schema.Types.String, | ||
people: [Schema.Types.Number], | ||
skin_colors: Schema.Types.String | ||
}); | ||
|
||
export default new model("species", species); |
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 @@ | ||
/* eslint-disable new-cap */ | ||
import { Schema, model } from "mongoose"; | ||
|
||
const starships = new Schema({ | ||
id: Schema.Types.Number, | ||
MGLT: Schema.Types.String, | ||
hyperdrive_rating: Schema.Types.String, | ||
pilots: [Schema.Types.Number], | ||
starship_class: Schema.Types.String | ||
}); | ||
|
||
export default new model("starships", starships); |
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,20 @@ | ||
/* eslint-disable new-cap */ | ||
import { Schema, model } from "mongoose"; | ||
|
||
const transports = new Schema({ | ||
id: Schema.Types.Number, | ||
cargo_capacity: Schema.Types.String, | ||
consumables: Schema.Types.String, | ||
cost_in_credits: Schema.Types.String, | ||
created: Schema.Types.String, | ||
crew: Schema.Types.String, | ||
edited: Schema.Types.String, | ||
length: Schema.Types.String, | ||
manufacturer: Schema.Types.String, | ||
max_atmospering_speed: Schema.Types.String, | ||
model: Schema.Types.String, | ||
name: Schema.Types.String, | ||
passengers: Schema.Types.String | ||
}); | ||
|
||
export default new model("transports", transports); |
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,10 @@ | ||
/* eslint-disable new-cap */ | ||
import { Schema, model } from "mongoose"; | ||
|
||
const vehicles = new Schema({ | ||
id: Schema.Types.Number, | ||
pilots: [Schema.Types.Number], | ||
vehicle_class: Schema.Types.String | ||
}); | ||
|
||
export default new model("vehicles", vehicles); |