0.0.49 • Published 3 years ago

fast-serverless-framework v0.0.49

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Fast Serverless Framework

AWS - Node.js

Features

Installation

This library is published in the NPM registry and can be installed using any compatible package manager.

npm install fast-serverless-framework --save

# For Yarn, use the command below.
yarn add fast-serverless-framework

Installation from CDN

This module has an UMD bundle available through JSDelivr and Unpkg CDNs.

<!-- For UNPKG use the code below. -->
<script src="https://unpkg.com/fast-serverless-framework"></script>

<!-- For JSDelivr use the code below. -->
<script src="https://cdn.jsdelivr.net/npm/fast-serverless-framework"></script>

<script>
  // UMD module is exposed through the "FastServerlessFramework" global variable.
  console.log(FastServerlessFramework);
</script>

Tree structure

This project .

.
├── src
│   ├── index.js
│   ├── config.js
│   ├── modules
│   │   ├── users
│   │   │   └── consumers
│   │   │   │   └── example.js
│   │   │   └── endpoints
│   │   │   │   └── v1
│   │   │   │   │   └── example.js
│   │   │   └── schedules
│   │   │   │   └── example.js
├── .env
Directory / FileDescription
srcDescription
src/index.jsDescription
src/config.jsDescription
src/modules/users/consumersDescription
src/modules/users/endpoints/v1Description
src/modules/users/schedulesDescription
.envDescription

Usage

Initialization

src/index.js

FastServerlessFramework.init()

Config

src/config.js

module.exports = {
  project: '', // (required)
  bootstrap: () => {} // executed before any Consumers, Endpoints or Schedules
  endpoints: {
    beforeEach: [], // executed before any Endpoint
    afterEach: [] // executed after any Endpoint
  },
  aws: {
    id: '', // AWS ID Account (required)
    region: '', // AWS Region (required)
    lambdaRole: ''
  },
  stage: '', // (required)
  nodeVersion: '' // (required)
}

Consumers

src/modules/consumers/example.js

exports.handler = FastServerlessFramework.Consumers.register({
  topic: '',
  concurrency: 1,
  timeout: 900,
  fifo: false,
  handler () {}
})

Endpoints

src/modules/endpoits/v1/example.js

exports.handler = FastServerlessFramework.Endpoints.register({
  method: '',
  params: '',
  middlewares: []
  handler (req) {
    return {
      status: 200,
      message: 'OK'
    }
  }
})

Schedules

src/modules/schedules/example.js

exports.handler = FastServerlessFramework.Schedules.register({
  rate: '5 minutes',
  timeout: 900,
  handler () {}
})