-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
5 changed files
with
69 additions
and
13 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
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
File renamed without changes.
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,56 @@ | ||
import webpack from 'webpack'; | ||
import webpackMiddleware from 'webpack-dev-middleware'; | ||
import webpackConfig from '../../webpack.config.js'; | ||
import express from 'express'; | ||
import bodyParser from 'body-parser'; | ||
import fetch from 'node-fetch' | ||
import OlympicWinnersService from './olympicWinnersService'; | ||
|
||
const app = express(); | ||
app.use(webpackMiddleware(webpack(webpackConfig))); | ||
app.use(bodyParser.urlencoded({extended: false})); | ||
app.use(bodyParser.json()); | ||
|
||
app.post('/nodeOlympicWinners', function (req, res) { | ||
OlympicWinnersService.getData(req.body, (rows, lastRow) => { | ||
res.json({rows: rows, lastRow: lastRow}); | ||
}); | ||
}); | ||
|
||
app.post('/goOlympicWinnersMySQL', function (req, res) { | ||
console.log('---BODY---', req.body) | ||
console.log('') | ||
fetch('http://localhost:8080/mysql-olympic-winners', { | ||
method: 'post', | ||
body: JSON.stringify(req.body), | ||
headers: {"Content-Type": "application/json; charset=utf-8;"} | ||
}) | ||
.then(httpResponse => httpResponse.json()) | ||
.then(response => { | ||
res.json({rows: response.rows, lastRow: response.lastRow}); | ||
}) | ||
.catch(error => { | ||
console.error(error); | ||
}) | ||
}); | ||
|
||
app.post('/goOlympicWinnersPostgreSQL', function (req, res) { | ||
console.log('---BODY---', req.body) | ||
console.log('') | ||
fetch('http://localhost:8080/postgre-olympic-winners', { | ||
method: 'post', | ||
body: JSON.stringify(req.body), | ||
headers: {"Content-Type": "application/json; charset=utf-8;"} | ||
}) | ||
.then(httpResponse => httpResponse.json()) | ||
.then(response => { | ||
res.json({rows: response.rows, lastRow: response.lastRow}); | ||
}) | ||
.catch(error => { | ||
console.error(error); | ||
}) | ||
}); | ||
|
||
app.listen(4000, () => { | ||
console.log('Started on localhost:4000'); | ||
}); |
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