Skip to content

OnedocLabs/dev-serverless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverless Framework AWS NodeJS Example

This template demonstrates how to deploy a NodeJS function running on AWS Lambda using the traditional Serverless Framework. The deployed function does not include any event definitions as well as any kind of persistence (database). For more advanced configurations check out the examples repo which includes integrations with SQS, DynamoDB or examples of functions that are triggered in cron-like manner. For details about configuration of specific events, please refer to our documentation.

Usage

Install dependencies

In order to install the dependencies, you need to run the following command:

npm install

Build

In order to build the service you need to run the following command:

npm run build

Local testing

In order to test the service locally you need to run the following command:

npx serverless invoke local --function generateDocument --data '{"name":"John Wick"}'

Deployment

In order to deploy the example, you need to run the following command:

$ serverless deploy

After running deploy, you should see output similar to:

Deploying aws-node-project to stage dev (us-east-1)

✔ Service deployed to stack aws-node-project-dev (112s)

functions:
  hello: aws-node-project-dev-hello (1.5 kB)

Invocation

After successful deployment, you can invoke the deployed function by using the following command:

serverless invoke --function generateDocument --data '{"name":"John Wick"}'

Which should result in response similar to the following:

{
  "statusCode": 200,
  "body": "...",
  "headers": {
    "Content-Type": "application/json"
  }
}

Local development

You can invoke your function locally by using the following command:

npx serverless invoke local --function generateDocument --data '{"name":"John Wick"}'

Which should result in response similar to the following:

{
  "statusCode": 200,
  "body": "...",
  "headers": {
    "Content-Type": "application/json"
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published