1.0.7 • Published 7 months ago

@yomo/sfn v1.0.7

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

@yomo/sfn

Usage Guide

Step 1: Create a .env File

In the root of your project, create a .env file and add the following variables. You can find these values in the serverless page of your dashboard.

YOMO_SFN_NAME=sfn_name
YOMO_SFN_ZIPPER=zipper.vivgrid.com:9000
YOMO_SFN_CREDENTIAL=your_credential

Step 2: Install Dependencies

Run the following command to install the necessary dependencies:

pnpm install @yomo/sfn
pnpm install -D typescript

Step 3: Create app.ts File

Create a file named app.ts and add the following code:

export const description = 'this function is used for getting the weather'

export const tag = 0x33

export type Argument = {
  unit: string
  location: 'fahrenheit' | 'celsius'
}

async function getWeather(unit: string, location: string) {
  return { location: location, temperature: '22', unit: unit }
}
export async function handler(args: Argument) {
  const result = await getWeather(args.unit, args.location)
  return result
}

For the type declaration of Argument, you can refer to typescript-json-schema. We will generate properties based on the Argument you provide.

We also provide you with some examples

export type Argument = {
  unit: string
  location: string
}
// translation
{
  type: 'object',
  properties: {
    unit: {
      type: 'string'
    },
    location: {
      type: 'string'
    }
  },
  required: ['unit', 'location']
}
export type Argument = {
  unit: string
  location: 'fahrenheit' | 'celsius'
}
// translation
{
  type: 'object',
  properties: {
    unit: {
      type: 'string'
    },
    location: {
      type: 'string',
      enum: ['fahrenheit', 'celsius']
    }
  },
  required: ['unit', 'location']
}
export type Argument = {
  unit: string
  /**
   * location description.
   */
  location?: string
}
// translation
{
  type: 'object',
  properties: {
    unit: {
      type: 'string'
    },
    location: {
      type: 'string',
      description: 'location description.'
    }
  },
  required: ['unit']
}

Step 4: Test Your Function

yomo run app.ts
1.0.7

7 months ago

1.0.6

8 months ago

1.0.5

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.0

12 months ago