Skip to content

Commit

Permalink
Merge pull request #69 from fga-eps-mds/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
lucasmidlhey authored Sep 30, 2019
2 parents 6fc0f75 + 4a74f1e commit 6f7f22e
Show file tree
Hide file tree
Showing 77 changed files with 3,626 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mkdocs/site/

extension/scripts/Chart.min.js
1 change: 1 addition & 0 deletions APIs/api_gateway/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
89 changes: 89 additions & 0 deletions APIs/api_gateway/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# 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
*.lcov

# nyc test coverage
.nyc_output

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

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

# node-waf configuration
.lock-wscript

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

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# 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
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/
13 changes: 13 additions & 0 deletions APIs/api_gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:alpine

RUN mkdir -p /usr/breakdown/gateway_api
WORKDIR /usr/breakdown/gateway_api

COPY package*.json ./
RUN npm install

COPY . .

EXPOSE 3000

CMD ["npm", "start"]
31 changes: 31 additions & 0 deletions APIs/api_gateway/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "api_gateway",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"test": "mocha"
},
"scripts": {
"start": "nodemon ./src/index.js",
"test": "DEV_ENV=development nodemon --exec \"mocha --recursive\" --timeout 30000 ./test/*.js --exit"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"cookie-parser": "^1.4.4",
"express": "^4.17.1",
"express-http-proxy": "^1.5.1",
"helmet": "^3.21.0",
"http": "0.0.0",
"morgan": "^1.9.1",
"nodemon": "^1.19.2",
"request": "^2.88.0"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^6.2.0",
"should": "^13.2.3"
}
}
40 changes: 40 additions & 0 deletions APIs/api_gateway/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
let http = require('http');
const express = require('express')
const httpProxy = require('express-http-proxy')
const app = express()
let cookieParser = require('cookie-parser');
let logger = require('morgan');
const helmet = require('helmet');

const commitsServiceProxy = httpProxy('commit_api:3001');
const issuesServiceProxy = httpProxy('issue_api:3002');
const pullrequestsServiceProxy = httpProxy('pullrequest_api:3003');
const branchesServiceProxy = httpProxy('branch_api:3004');

// Proxy request
app.get('/commits', (req, res, next) => {
commitsServiceProxy(req, res, next);
})

app.get('/issues', (req, res, next) => {
issuesServiceProxy(req, res, next);
})

app.get('/pullrequests', (req, res, next) => {
pullrequestsServiceProxy(req, res, next);
})

app.get('/branches', (req, res, next) => {
branchesServiceProxy(req, res, next);
})

app.use(logger('dev'));
app.use(helmet());
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());

let server = http.createServer(app);
server.listen(3000);

module.exports = app
147 changes: 147 additions & 0 deletions APIs/api_gateway/test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
const chai = require('chai')
const assert = chai.assert
const request = require('request')
const expect = chai.expect

describe('API Gateway integration tests', () => {
let urlBase = 'http://localhost:3000'
let urlParams = '?owner=fga-eps-mds&repository=2019.2-Git-Breakdown'

it('/commits: valid request', async () => {
await request.get( {
url : urlBase+'/commits'+urlParams
}, (error, response, body) => {
let _body = {}
try{
_body = JSON.parse(body)
}
catch(e){
_body = {}
}
if(response.status != undefined)
expect(response.status).to.equal(200)
}
)
})
it('/commits: invalid request', async () => {
await request.get( {
url : urlBase+'/commits'
}, (error, response, body) => {
let _body = {}
try{
_body = JSON.parse(body)
}
catch(e){
_body = {}
}
if(response.statusCode != undefined)
expect(response.statusCode).to.equal(400)
}
)
})

it('/issues: valid request', async () => {
await request.get( {
url : urlBase+'/issues'+urlParams
}, (error, response, body) => {
let _body = {}
try{
_body = JSON.parse(body)
}
catch(e){
_body = {}
}
if(response.status != undefined)
expect(response.status).to.equal(200)
if(_body.open != undefined){
expect(_body).to.have.property('open')
expect(_body).to.have.property('closed')
expect(_body).to.have.property('openPercent')
expect(_body).to.have.property('closedPercent')
}
}
)
})
it('/issues: invalid request', async () => {
await request.get( {
url : urlBase+'/issues'
}, (error, response, body) => {
let _body = {}
try{
_body = JSON.parse(body)
}
catch(e){
_body = {}
}
if(response.statusCode != undefined)
expect(response.statusCode).to.equal(400)
}
)
})

it('/pullrequests: valid request', async () => {
await request.get( {
url : urlBase+'/pullrequests'+urlParams
}, (error, response, body) => {
let _body = {}
try{
_body = JSON.parse(body)
}
catch(e){
_body = {}
}
if(response.status != undefined)
expect(response.status).to.equal(200)
}
)
})
it('/pullrequests: invalid request', async () => {
await request.get( {
url : urlBase+'/pullrequests'
}, (error, response, body) => {
let _body = {}
try{
_body = JSON.parse(body)
}
catch(e){
_body = {}
}
if(response.statusCode != undefined)
expect(response.statusCode).to.equal(400)
}
)
})

it('/branches: valid request', async () => {
await request.get( {
url : urlBase+'/branches'+urlParams
}, (error, response, body) => {
let _body = {}
try{
_body = JSON.parse(body)
}
catch(e){
_body = {}
}
if(response.status != undefined)
expect(response.status).to.equal(200)
}
)
})
it('/branches: invalid request', async () => {
await request.get( {
url : urlBase+'/branches'
}, (error, response, body) => {
let _body = {}
try{
_body = JSON.parse(body)
}
catch(e){
_body = {}
}
if(response.statusCode != undefined)
expect(response.statusCode).to.equal(400)
}
)
})
})
1 change: 1 addition & 0 deletions APIs/branches_request/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
Loading

0 comments on commit 6f7f22e

Please sign in to comment.