0.8.75 • Published 4 years ago

@rafterjs/lambda v0.8.75

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
4 years ago

Rafter API Server

The @rafterjs/lambda server provides a simple wrapper around rafter that allows you to execute a single function but still maintain all the benefits that rafter provides including autoloading dependency injection. This is perfect for serverless and CLI applications.

Getting started

yarn add @rafterjs/lambda

Add rafter api to your project

Example structure

  • config
    • config.ts
  • lib
    • MessageController.ts
    • MessageDao.ts
  • index.ts

index.ts

This is the function entry point. So this would be the file that either your CLI or Serverless config would execute.

import { join } from 'path';
import { rafterLambda } from '@rafterjs/lambda';
import { messageController } from './lib/MessageController';

const paths = [join(__dirname, `/{lib,config}/**/`)];

/**
 * This is an example function that benefits from rafter auto dependency injection.
 * This means that you can reuse all the services and code you have written for an API or other apps within a
 * cron job, CLI app or serverless app.
 */
async function run(): Promise<void> {
  await rafterLambda({ paths }, messageController);
}

run();

./lib/MessageController.ts

This is essentially a factory. Rafter injects the dependencies in via the first function, and then returns a new function. The returned function is what rafter uses to execute.

export const messageController = (logger: ILogger) => (): void => {
  logger.info('Hey there, this is a lambda with dependency injection!');
};
0.8.74

4 years ago

0.8.73

4 years ago

0.8.75

4 years ago

0.8.70

4 years ago

0.8.72

4 years ago

0.8.71

4 years ago

0.8.69

4 years ago

0.8.68

4 years ago

0.8.67

4 years ago

0.8.66

4 years ago

0.8.63

4 years ago

0.8.65

4 years ago

0.8.64

4 years ago

0.8.62

4 years ago

0.8.61

4 years ago

0.8.60

4 years ago

0.8.56

4 years ago

0.8.55

4 years ago

0.8.58

4 years ago

0.8.57

4 years ago

0.8.54

4 years ago

0.8.59

4 years ago

0.8.52

5 years ago

0.8.51

5 years ago

0.8.53

5 years ago

0.8.50

5 years ago

0.8.49

5 years ago

0.8.45

5 years ago

0.8.47

5 years ago

0.8.46

5 years ago

0.8.48

5 years ago

0.8.44

5 years ago

0.8.43

5 years ago

0.8.41

5 years ago

0.8.40

5 years ago

0.8.42

5 years ago

0.8.39

5 years ago

0.8.37

5 years ago

0.8.34

5 years ago

0.8.36

5 years ago

0.8.35

5 years ago

0.8.33

5 years ago

0.8.32

5 years ago

0.8.32-alpha.0

5 years ago

0.8.30

5 years ago

0.8.31

5 years ago

0.8.23

5 years ago

0.8.22

5 years ago

0.8.25

5 years ago

0.8.24

5 years ago

0.8.21

5 years ago

0.8.20

5 years ago

0.8.27

5 years ago

0.8.26

5 years ago

0.8.29

5 years ago

0.8.28

5 years ago

0.8.19

5 years ago

0.8.12

5 years ago

0.8.9

5 years ago

0.8.11

5 years ago

0.8.8

5 years ago

0.8.14

5 years ago

0.8.13

5 years ago

0.8.10

5 years ago

0.8.16

5 years ago

0.8.15

5 years ago

0.8.18

5 years ago

0.8.17

5 years ago

0.8.7

5 years ago

0.8.6

5 years ago

0.8.5

5 years ago

0.8.4

5 years ago

0.8.3

5 years ago

0.8.2

5 years ago

0.8.1

5 years ago