Code Monkey home page Code Monkey logo

serverless-loopback's Introduction

serverless-loopback

serverless MIT licensed Codacy Badge FOSSA Status

A collection of sample loopback applications deployed to AWS Lambda using serverless.

Overview

The following examples are available:

Using

Create a serverless service from this template by using the command:

serverless create --template-url https://github.com/botbits/serverless-loopback/examples/<SELECT_EXAMPLE>

Or clone the git repo:

git clone https://github.com/botbits/serverless-loopback

and cd examples to start checking your favorite example!

Contributing

Please feel free to contribute your examples of using loopback4 with other web frameworks under the examples folder.

License

MIT © BotBitsSM

serverless-loopback's People

Contributors

dependabot[bot] avatar marcelobern avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

serverless-loopback's Issues

Error running example

When running the sample pretty much as is (I did change to Oregon), I get the following error:

Serverless Error ---------------------------------------

  An error occurred: IamRoleLambdaExecution - API: iam:AttachRolePolicy User: arn:aws:iam::redacted:user/serverless-agent is not authorized to perform: iam:AttachRolePolicy on resource: role serverless-loopback-dev-us-west-2-lambdaRole.

What's weirder, is that I went to add "AttachRolePolicy" but couldn't find it in the list.

I get the same error if I run on east.

    == John ==

Loopback 4 example - convert lamdba-wrapper.js to Typescript equivalent.

Hi,
I've followed the loopback 4 example for this and I really like how you have the framework to play nicely with serverless framework when following the tutorial!

The thing I'm confused about is the lambda wrapper js file.

https://github.com/botbits/serverless-loopback/blob/master/examples/lb4-express/src/lambda-wrapper.js

Could it not have been better to rewrite it in Typescript in the following:

import {ExpressServer} from '../server';

import serverless from 'serverless-http';

import {ApplicationConfig} from '@loopback/core';

let app: Function;

async function main(options: ApplicationConfig) {
  const server = new ExpressServer(options);
  app = serverless(server.app);
  await server.boot();
  await server.start();
  console.log('Server is running at http://127.0.0.1:3000');
}

exports.handler = async function handler(
  request: Object,
  ...context: Object[]
) {
  if (app === undefined) {
    // Run the application
    const config = {
      rest: {
        port: +(process.env.PORT ? process.env.PORT : 3000),
        host: process.env.HOST ? process.env.HOST : 'localhost',
        openApiSpec: {
          // useful when used with OpenAPI-to-GraphQL to locate your application
          setServersFromRequest: true,
        },
        // Use the LB4 application as a route. It should not be listening.
        listenOnStart: false,
      },
    };
    await main(config).catch(err => {
      console.error('Cannot start the application.', err);
      process.exit(1);
    });
  }
  return app(request, ...context);
};

That way, you don't need to configure tsconfig.json to include raw JS files as part of the build process and you only have Typescript files to work with, not JS/Typescript files combo..

I'm just curious what's your rationale is keeping both JS and Typescript this way.

Can run, cleanup, run

While working on issue #4 I tried to run:

npm run sls-cleanup

then

npm run sls-deploy

but I got this error:

  Serverless Error ---------------------------------------


  An error occurred: IamRoleLambdaExecution - serverless-loopback-dev-us-west-2-lambdaRole already exists.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     OS:                     linux
     Node Version:           8.10.0
     Serverless Version:     1.42.3

Expected behavior:

Either the create should skip trying to create the role, OR the sls-cleanup should also clean up the extra role.

Is this a Botbits error or a serverless error? My guess is, both of these are the latter.

    == John ==

Samples for other serverless providers

Wanted to open this issue to gather user feedback about the need/interest of having this sample available for other providers other than AWS Lambda.

Please comment on this thread or +1 an existing ask so we can keep track of potential interest.

Thanks in advance!

Not working properly with [email protected]

The global app variable remains undefined on all calls but the LB4 starts in the background on the first request and all subsequent requests throw the error...

Cannot start the application. Error: listen EADDRINUSE: address already in use 127.0.0.1:3000

Was not happening when LB4 was < V2.

Loopback Server and AWS Lambda hard limit

Lovely work, botbits!

Just curious how one may handle a loopback server that is more than 250 megs due to dependencies and etc. AWS Lambda has a hard limit of 250 megs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.