Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .docker-compose.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
30 changes: 30 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-console":0,
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"never"
]
}
}
59 changes: 59 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,62 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# General
*.DS_Store
.AppleDouble
Expand Down
15 changes: 8 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
language: ruby
sudo: false
dist: trusty
cache: bundler
language: node_js
node_js:
- "node"
cache:
directories:
- "node_modules"
notifications:
email:
on_success: never
on_failure: always
slack:
secure: YCLQ9AqOPR4cnB+v9d+O6eX31IWDL43GyFcgHRCoUbfsccJoguo0vHqjzd36VdE+bp3PD9GJTEdiiDJGCPgQyq3vUP9VhiR4xbLdNSGth6+7Q0wZdoRHkG0qjXKgcFtEnAmjwgadHQ3Ymh9krZvzRlee5B92lPh2oocU1Lijw9Vw4e6cIco+Fr3Pjnx3eY1rSVUd45qv7bnzxHCT+my4lMcqgJXd9/OIHVL+RCigGcKeBSR7V79Fi/4fg7+e1fwaiwZKpRfF4cOtQ30K/x0M07Sbv01OHbn8CybUw1uax+6s+8nJXPCyWymxONexy54n/uMCAqr6ODNlKvJdeP0KqY+n3l913JCFZKVYfM6roxC70Mn4ZmT670Kxlc1ROLxmgruSTk5Cr3Pv+rSpC1F7p1Fv7gUi+Aia2uZec2n4gPmq482psubkRORW9f5aAtAQMzkdHYg8hs3QA0/XShpm+eksK6+/DAFP/eXQVNyDQysJlp7SD/GFjmusKIa4tJqD+jjWOFXtojyY7vT1RFIrMtUPAz4s5LMPLWiS4p0H6KCcJ3GpYEuZm5i4TJtQInec4lIgj/JLUSueIZy/kD+jY+nBXEzCyZPi1YFU/yQmx4+tBknKWJvQpFXI542bg7qEWD9IZUpGfIByRUVQvCo0xuhA/pCOVH8HQO0xTkBrPb0=
after_success:
- ./scripts/docker_build.sh
- ./scripts/docker_build.sh

1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ Changes will not be merged unless the build passes.
4. If the build succeeds, the pull request will be merged, and automatically
pushed to the staging server at [http://stage.spacexdata.com/v1/](http://stage.spacexdata.com/v1/) for a
final check before promoting changes to production at [https://api.spacexdata.com/v1/](https://api.spacexdata.com/v1/).

23 changes: 8 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
# Dockerfile with alpine based build

FROM ruby:2.4.1-alpine
FROM node:alpine

MAINTAINER Jake Meyer <[email protected]>

RUN apk update && apk upgrade
RUN apk add --update alpine-sdk
RUN apk add ruby-bundler

WORKDIR /app
ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock
RUN bundle install --system
ENV NODE_ENV=production

ADD . /app
RUN bundle install --system
RUN mkdir -p /home/nodejs/app
WORKDIR /home/nodejs/app

EXPOSE 9292
COPY . /home/nodejs/app
RUN npm install --production

CMD ["bundle", "exec", "puma", "-e", "production"]
EXPOSE 5000
CMD [ "npm", "start" ]
14 changes: 0 additions & 14 deletions Gemfile

This file was deleted.

72 changes: 0 additions & 72 deletions Gemfile.lock

This file was deleted.

2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: bundle exec puma -p $PORT -e production
web: npm start
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,12 @@ GET https://api.spacexdata.com/v1/launches/latest
See the [Contribution](https://github.com/r-spacex/SpaceX-API/blob/master/CONTRIBUTING.md) guide for detailed steps

## Technical Details
* API is using [Sinatra](http://www.sinatrarb.com/) web framework
* Uses [Travis CI](https://travis-ci.org/) for testing + deployment
* API is using [Node.js](https://nodejs.org/en/) with the [Express.js](https://expressjs.com/) framework
* Uses [Jest](https://facebook.github.io/jest/) and [Supertest](https://github.com/visionmedia/supertest) for unit/integration testing
* Uses [Travis CI](https://travis-ci.org/) for continuous integration/delivery
* All data stored in a [MongoDB Atlas](https://www.mongodb.com/cloud/atlas) 3 node replica set cluster
* Latest database dump included under [releases](https://github.com/r-spacex/SpaceX-API/releases)
* API deployed on a [Heroku](https://www.heroku.com/) pipeline with pull request, staging and production servers
* A [Docker](https://hub.docker.com/r/jakewmeyer/spacex-api/) image is avaiable for local development/deployment
```bash
docker pull jakewmeyer/spacex-api
```
* Deploy on your own Heroku app below:

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)

## FAQ's
* If you have any questions or corrections, please open an issue and we'll get it merged ASAP
Expand Down
13 changes: 0 additions & 13 deletions Rakefile

This file was deleted.

54 changes: 54 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

const express = require("express")
const morgan = require("morgan")
const cors = require("cors")
const compression = require("compression")
const helmet = require("helmet")
const config = require("./config.json")
const MongoClient = require("mongodb")
const Path = require("path")
const app = express()

// Define routes
const home = require("./routes/v1-home")
const info = require("./routes/v1-info")
const vehicles = require("./routes/v1-vehicles")
const launchpad = require("./routes/v1-launchpad")
const launches = require("./routes/v1-launches")
const upcoming = require("./routes/v1-upcoming")
const parts = require("./routes/v1-parts")

// Enable gzip helmet,
// HTTP logging, and CORS
app.use(compression())
app.use(helmet())
app.use(morgan("common"))
app.use(cors())

// Routes
app.use("/v1", home)
app.use("/v1/info", info)
app.use("/v1/vehicles", vehicles)
app.use("/v1/launchpads", launchpad)
app.use("/v1/launches", launches)
app.use("/v1/launches/upcoming", upcoming)
app.use("/v1/parts", parts)

// 404 Error Handler
app.use((req, res) => {
res.status(404).sendFile(Path.join(__dirname + "/pages/404.html"))
})

// Create MongoDB Connection
MongoClient.connect(config.url, (err, database) => {
if (err) return console.log(err)
global.db = database

app.set("port", (process.env.PORT || 5000))
app.listen(app.get("port"), "0.0.0.0", () => {
console.log("SpaceX API listening on port: " + app.get("port"))
app.emit("ready")
})
})

module.exports = app
26 changes: 5 additions & 21 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
{
"name": "SpaceX-API",
"description": "Open Source REST API for company, vehicle, launchpad, and launch data",
"repository": "https://github.com/r-spacex/SpaceX-API",
"logo": "https://upload.wikimedia.org/wikipedia/commons/0/08/Circle-icons-rocket.svg",
"scripts": {
},
"env": {
"LANG": {
"value": "en_US.UTF-8"
}
},
"formation": {
},
"addons": [
],
"buildpacks": [
{
"url": "heroku/ruby"
}
]
}
"name": "SpaceX-API",
"description": "Open Source REST API for company, vehicle, launchpad, and launch data",
"repository": "https://github.com/r-spacex/SpaceX-API",
"logo": "https://upload.wikimedia.org/wikipedia/commons/0/08/Circle-icons-rocket.svg"
}
4 changes: 4 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"test" : "success",
"url" : "mongodb://public:[email protected]:27017, spacex-api-shard-00-01-rzdz4.mongodb.net:27017,spacex-api-shard-00-02-rzdz4.mongodb.net:27017/spacex-api?ssl=true&replicaSet=spacex-api-shard-0&authSource=admin"
}
8 changes: 0 additions & 8 deletions config.ru

This file was deleted.

Loading