title: Adding a new js file to my lambda function using Serverless
body: <p>I'm trying to create an API on AWS Lambda, and using Serverless framework for deployment.</p>
  
  <p>I'm a complete noob at it, so I'm not sure I'm doing the right thing. So here's the old favorite, hello world (index.js):</p>
  
  <pre><code>const serverless = require('serverless-http');
  const express = require('express');
  const app = express();
  const Promise = require('promise');
  
  app.get('/', function (req, res) {
      res.send('Hello World!')
  })
  </code></pre>
  
  <p>That works fine as is. But when I add the following:</p>
  
  <pre><code>const serverless = require('serverless-http');
  const express = require('express')
  const app = express()
  const Register = require('./controller/registryController');
  
  app.get('/', function (req, res) {
      res.send('Hello World!')
  })
  
  app.get('/createUserName', function (req, res) {
      var prom = Register.createUser();
      prom.then((message) =&gt; {
          res.status(201).json(message);
      })
      .catch((message) =&gt; {
          res.status(400).json(message);
      });
  })
  
  module.exports.handler = serverless(app);
  </code></pre>
  
  <p>I get:</p>
  
  <blockquote>
    <p>"Cannot find module './controller/registryController'"</p>
  </blockquote>
  
  <p>Which is strange, cause the file is right there, when I look in lambda. Here's its contents:</p>
  
  <pre><code>const dbConnMysql = require('./dbMngrMysql');
  
  var methods = {
      createUser: function() {
          return new Promise((resolve, reject) =&gt; {
              let connection = dbConnMysql.createConnection();
              dbConnMysql.startConnection(connection)
              .then((fulfilled) =&gt; {
                  let table = 'userNamePool';
                  return dbConnMysql.selectFrom(connection, table, null);
              })
              .then((fulfilled) =&gt; {
                  return dbConnMysql.closeConnection(connection).then(function() {
                      let result = fulfilled;
                      let response = {
                          "statusCode": 200,
                          "headers": {"my_header": "my_value"},
                          "body": JSON.stringify(result),
                          "isBase64Encoded": false
                      };
  
                      resolve(response);
                  });
              })
              .catch((error) =&gt; {
                  let response = {
                      "statusCode": 404,
                      "headers": {"my_header": "my_value"},
                      "body": JSON.stringify(error),
                      "isBase64Encoded": false
                  };
  
                  resolve(response);
              });
          });
      }
  };
  
  module.exports = methods;
  </code></pre>
  
  <p>Here's the project structure / directory:</p>
  
  <p><a href="https://i.stack.imgur.com/SxLgr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SxLgr.png" alt="enter image description here"></a></p>
  
  <p>And here's my serverless.yml for good measure:</p>
  
  <p>service: sample-api</p>
  
  <pre><code>provider:
    name: aws
    runtime: nodejs8.10
    stage: dev
    region: yapyap
    deploymentBucket: yadayada
    role: blahblahblah
  
  functions:
    app:
      handler: index.handler
      events:
        - http: ANY /
        - http: 'ANY {proxy+}'
    createUserName:
      handler: index.handler
      events:
        - http: 'GET /createUserName'
  </code></pre>
  
  <p>What am I doing wrong? Anything I can do to fix this?</p>