import express from 'express';
import gapi from '../lib';

let app = express();

app.get("/*", (req, res) => {
  let id = req.query.id
  if(id == undefined) { 
    res.jsonp({error:"Package id not defined"});
    return;
  }
  gapi({id:id}).then( (info) => {
    res.jsonp(info);
  });
});

let server = app.listen(process.env.PORT || 5000, (err) => {
  console.log("Service running");
  if(err) console.log(err);
});


@@ -73,16 +73,268 @@
 ress();%0A
+app.use(function(req, res, next) %7B%0A  res.header(%22Access-Control-Allow-Origin%22, %22*%22);%0A  res.header('Access-Control-Allow-Credentials', true);%0A  res.header(%22Access-Control-Allow-Headers%22, %22Origin, X-Requested-With, Content-Type, Accept%22);%0A  next();%0A%7D);%0A%0A
 %0Aapp.get
@@ -419,16 +419,57 @@
 s.jsonp(
+req.query.callback + '('+ JSON.stringify(
 %7Berror:%22
@@ -493,16 +493,24 @@
 fined%22%7D)
+ + ');')
 ;%0A    re
@@ -567,20 +567,69 @@
 s.jsonp(
-info
+req.query.callback + '('+ JSON.stringify(info) + ');'
 );%0A  %7D);

update service