Skip to content

Commit

Permalink
full proxy request
Browse files Browse the repository at this point in the history
  • Loading branch information
meusebio.depaz committed Nov 23, 2016
1 parent 7ff4c1b commit cdfedc4
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bower_components
node_modules
.DS_Store
.idea
Expand Down
15 changes: 15 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = function (grunt) {
grunt.initConfig({
apidoc: {
myapp: {
src: 'src/',
dest: 'apidoc/'
}
}

})

grunt.loadNpmTasks('grunt-apidoc')

grunt.registerTask('build', ['apidoc'])
}
35 changes: 34 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
console.log('Hello World')
const express = require('express')
const request = require('request');
let app = express()

/**
* @api {get} / proxify get request to google
* @apiName GetUser
* @apiGroup User
*
*
* @apiSuccess {Object} full website
*/
app.get('/', function (req, res) {

request('http://www.google.com', (error, response, body) => {

if (error) {
res.send('KO')
return
}

res.send(body)

})
})

app.listen(3000, function () {
console.log(arguments)
console.log(JSON.stringify(arguments))
console.log('Example app listening on port 3000!')
})

console.log('Hello World, i\'ll run before the server!')

11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@
"private": true,
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1",
"doc_apidoc": "api-doc src -output /doc",
"doc_grunt": "grunt api-doc",
"custom": "node --version",
"standarize": "standard-format -w",
"test": "echo \"Error: no test specified\" && exit 1"
"standarize": "standard-format -w"
},
"author": "[email protected]",
"license": "MIT",
"dependencies": {
"express": "^4.14.0",
"request": "^2.79.0"
},
"devDependencies": {
"grunt": "^1.0.1",
"grunt-apidoc": "^0.11.0",
"grunt-cli": "^1.2.0",
"standard-format": "^2.2.3"
}
}
7 changes: 7 additions & 0 deletions proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var request = require('request');
request('http://www.google.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body) // Show the HTML for the Google homepage.
}
})

0 comments on commit cdfedc4

Please sign in to comment.