node.jsaws-lambdanode-twitter

How can i use node packages in claudiajs for use it in aws lambda


How can I use node packages in claudiajs. I tried to use node-twitter-api and node-twitter in it but getting blank response. promise will require or not i have no idea about it in lambda. if any one has any examples or documents that may have multiple node packages used with claudiajs for lambda. reference: http://claudia.js , https://vimeo.com/156232471

  var ApiBuilder = require('claudia-api-builder'),
  api = new ApiBuilder();
  var twitterAPI = require('node-twitter-api');
  var Promise = require("bluebird");
  api.get("/request-token", function(request) {
        'use strict';
         new Promise(function(resolve) {
             var twitter = new twitterAPI({
                consumerKey: "ckey",
                consumerSecret: "cskey",
                callback: 'http://localhost:3000/access-token'
             });
             var res;
             twitter.getRequestToken(function(err, requestToken, requestSecret) {      
                 if (err)
                     res = err;
                 else {
                     var _requestSecret = requestSecret;
                     var url = "https://twitter.com/oauth/authenticate?oauth_token" + requestToken;
                     res = url;        
                     //res.redirect(url);
                 }
             });
             return res;
         });
  });

Solution

  • You can use packages just by including into package.json, using the normal javascript NPM commands (eg npm install <package-name> -S, check out https://claudiajs.com/tutorials/packaging.html for more information), but based on your code this doesn't seem to be the problem.