0.8.75 • Published 3 years ago

@rafterjs/lambda v0.8.75

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

3 years ago

0.8.73

3 years ago

0.8.75

3 years ago

0.8.70

3 years ago

0.8.72

3 years ago

0.8.71

3 years ago

0.8.69

3 years ago

0.8.68

3 years ago

0.8.67

3 years ago

0.8.66

3 years ago

0.8.63

3 years ago

0.8.65

3 years ago

0.8.64

3 years ago

0.8.62

3 years ago

0.8.61

3 years ago

0.8.60

3 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

4 years ago

0.8.51

4 years ago

0.8.53

4 years ago

0.8.50

4 years ago

0.8.49

4 years ago

0.8.45

4 years ago

0.8.47

4 years ago

0.8.46

4 years ago

0.8.48

4 years ago

0.8.44

4 years ago

0.8.43

4 years ago

0.8.41

4 years ago

0.8.40

4 years ago

0.8.42

4 years ago

0.8.39

4 years ago

0.8.37

4 years ago

0.8.34

4 years ago

0.8.36

4 years ago

0.8.35

4 years ago

0.8.33

4 years ago

0.8.32

4 years ago

0.8.32-alpha.0

4 years ago

0.8.30

4 years ago

0.8.31

4 years ago

0.8.23

4 years ago

0.8.22

4 years ago

0.8.25

4 years ago

0.8.24

4 years ago

0.8.21

4 years ago

0.8.20

4 years ago

0.8.27

4 years ago

0.8.26

4 years ago

0.8.29

4 years ago

0.8.28

4 years ago

0.8.19

4 years ago

0.8.12

4 years ago

0.8.9

4 years ago

0.8.11

4 years ago

0.8.8

4 years ago

0.8.14

4 years ago

0.8.13

4 years ago

0.8.10

4 years ago

0.8.16

4 years ago

0.8.15

4 years ago

0.8.18

4 years ago

0.8.17

4 years ago

0.8.7

4 years ago

0.8.6

4 years ago

0.8.5

4 years ago

0.8.4

4 years ago

0.8.3

4 years ago

0.8.2

4 years ago

0.8.1

4 years ago