serverless / serverless/examples

Is it possible to share variable between functions? (nodejs)

Open
#568 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
11.5k
Forks
4.4k
Avg merge
2h 55m
Merged PRs (30d)
3

Description

Hello,

My serverless.yml

  hello:
    handler: handler.hello
    events:
      - http:
          path: hello
          method: get
          authorizer: authorizerFunc
  authorizerFunc:
    handler: handler.authorizerFunc

What I want is to set some value in auth.js and get the value in handler.js

auth.js

module.exports.authorizerFunc = (event, context, callback) => {
   //set some value
});

handler.js

module.exports.hello =  (event, context, callback) => {
 //get that value
});

Is it possible ?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading serverless.yml and the example snippets in auth.js and handler.js to understand how authorizerFunc and hello are invoked. This issue is an unanswered question rather than a defined change, so the desired behavior and a verifiable definition of done are not specified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend, cloud
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.