BrickUp API Service for Docker version.

app.js 751B

123456789101112131415161718192021222324252627282930313233343536
  1. var path = require('path');
  2. var koa = require('koa');
  3. var bodyParser = require('koa-bodyparser');
  4. var cors = require('koa-cors');
  5. var serve = require('koa-static');
  6. var url = require('url');
  7. var allowedDomains = [
  8. 'brickup.io',
  9. 'localhost:3001'
  10. ];
  11. var app = koa();
  12. app.use(cors({ origin: function(req) {
  13. if (!req.header.referer)
  14. return 'http://brickup.io';
  15. var info = url.parse(req.header.referer);
  16. var index = allowedDomains.indexOf(info.host);
  17. if (index > -1) {
  18. return info.protocol + '//' + info.host;
  19. }
  20. return 'http://brickup.io';
  21. }}));
  22. app.use(serve(__dirname + '/public'));
  23. app.use(bodyParser());
  24. app.use(require('./apis/builder').routes());
  25. app.listen(3050, function() {
  26. console.log('Server is runnning at 3035 port');
  27. });