0.8.75 • Published 2 years ago

@rafterjs/lambda v0.8.75

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
2 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

2 years ago

0.8.73

2 years ago

0.8.75

2 years ago

0.8.70

2 years ago

0.8.72

2 years ago

0.8.71

2 years ago

0.8.69

2 years ago

0.8.68

2 years ago

0.8.67

2 years ago

0.8.66

2 years ago

0.8.63

2 years ago

0.8.65

2 years ago

0.8.64

2 years ago

0.8.62

2 years ago

0.8.61

2 years ago

0.8.60

2 years ago

0.8.56

2 years ago

0.8.55

2 years ago

0.8.58

2 years ago

0.8.57

2 years ago

0.8.54

2 years ago

0.8.59

2 years ago

0.8.52

3 years ago

0.8.51

3 years ago

0.8.53

3 years ago

0.8.50

3 years ago

0.8.49

3 years ago

0.8.45

3 years ago

0.8.47

3 years ago

0.8.46

3 years ago

0.8.48

3 years ago

0.8.44

3 years ago

0.8.43

3 years ago

0.8.41

3 years ago

0.8.40

3 years ago

0.8.42

3 years ago

0.8.39

3 years ago

0.8.37

3 years ago

0.8.34

3 years ago

0.8.36

3 years ago

0.8.35

3 years ago

0.8.33

3 years ago

0.8.32

3 years ago

0.8.32-alpha.0

3 years ago

0.8.30

3 years ago

0.8.31

3 years ago

0.8.23

3 years ago

0.8.22

3 years ago

0.8.25

3 years ago

0.8.24

3 years ago

0.8.21

3 years ago

0.8.20

3 years ago

0.8.27

3 years ago

0.8.26

3 years ago

0.8.29

3 years ago

0.8.28

3 years ago

0.8.19

3 years ago

0.8.12

3 years ago

0.8.9

3 years ago

0.8.11

3 years ago

0.8.8

3 years ago

0.8.14

3 years ago

0.8.13

3 years ago

0.8.10

3 years ago

0.8.16

3 years ago

0.8.15

3 years ago

0.8.18

3 years ago

0.8.17

3 years ago

0.8.7

3 years ago

0.8.6

3 years ago

0.8.5

3 years ago

0.8.4

3 years ago

0.8.3

3 years ago

0.8.2

3 years ago

0.8.1

3 years ago