FROM node:6.9.5

RUN mkdir question && cd question

## installing express
RUN npm install express --save
RUN npm body-parser express --save

## moving to source dir
WORKDIR question

## generating new "app.js" file from scratch
RUN echo "var express = require('express');" >> app.js
RUN echo "var bodyParser = require('body-parser');" >> app.js
RUN echo "var app = express();" >> app.js
RUN echo "" >> app.js
RUN echo "app.use(bodyParser.json({limit: '30mb'}));" >> app.js #This line fixes
RUN echo "app.use(bodyParser.urlencoded({ extended: false }));" >> app.js
RUN echo " " >> app.js
RUN echo "app.post('/', function(request, response){" >> app.js
RUN echo "  console.log(request.body);" >> app.js
RUN echo "  response.send(request.body);" >> app.js
RUN echo "});" >> app.js
RUN echo "" >> app.js
RUN echo "app.listen(8080);" >> app.js


EXPOSE 8080
CMD node app.js