-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from fga-eps-mds/develop
Develop
- Loading branch information
Showing
77 changed files
with
3,626 additions
and
0 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,3 @@ | ||
mkdocs/site/ | ||
|
||
extension/scripts/Chart.min.js |
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 @@ | ||
node_modules |
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,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/ |
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,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"] |
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,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" | ||
} | ||
} |
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,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 |
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,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) | ||
} | ||
) | ||
}) | ||
}) |
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 @@ | ||
node_modules |
Oops, something went wrong.