{"id":21579733,"url":"https://github.com/hieuunguyeen/serverless-header-function","last_synced_at":"2025-03-18T07:43:05.382Z","repository":{"id":79694518,"uuid":"72111523","full_name":"hieuunguyeen/serverless-header-function","owner":"hieuunguyeen","description":"[sls@0.5x] Run a js file locally for every registered Serverless actions","archived":false,"fork":false,"pushed_at":"2017-01-26T10:12:23.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-08T18:35:36.969Z","etag":null,"topics":["lambda","serverless"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hieuunguyeen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-27T13:34:00.000Z","updated_at":"2018-02-08T14:38:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"45be5572-d7ef-44cf-8363-39a9fc88efb5","html_url":"https://github.com/hieuunguyeen/serverless-header-function","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"b07e8f80a17ce43ac51e0619fcccd3c9a01ebfac"},"previous_names":["blackevil245/serverless-header-function"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hieuunguyeen%2Fserverless-header-function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hieuunguyeen%2Fserverless-header-function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hieuunguyeen%2Fserverless-header-function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hieuunguyeen%2Fserverless-header-function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hieuunguyeen","download_url":"https://codeload.github.com/hieuunguyeen/serverless-header-function/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244181274,"owners_count":20411601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lambda","serverless"],"created_at":"2024-11-24T13:14:14.747Z","updated_at":"2025-03-18T07:43:05.354Z","avatar_url":"https://github.com/hieuunguyeen.png","language":"JavaScript","readme":"# Serverless header function\n\nRun a js file locally for every registered Serverless actions\n\n[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)\n\n\u003e Not compatible with Serverless 1.0.0 and above\n\n### Installation\nMake sure you have Node.js v4.0+ and Serverless Framework installed\nInstall plugin in the root level of your Serverless project\n\n`npm install --save-dev serverless-header-function`\n\nAppend the plugin's name to serverless plugins list in `s-project.json`\n```\nplugins: [\n  \"serverless-header-function\"\n]\n```\n\n### Current supports:\n1. Running a function by a hook\n3. Serially execute multiple functions. TODO: Support Async\n\n### Usage:\n1. List all js path file relative to project root in `s-project.json` under `custom.headerfunctions`, the disired hook and params.\n```\ncustom: {\n    headerfunctions: [\n      {\n        path: 'lib/func-a.js',\n        hook: 'function-pre-run',\n        params: []\n      },\n      {\n        path: 'src/a/b/c/function-bcde.js',\n        hook: 'function-post-deploy',\n        params: ['a', 1, null, true]\n      }\n    ]\n}\n```\n2. Hooks are in the format of `target-hook-action`. `target` and `hook` input are mandatory. Currently supported input are:\n```\ntarget: enum['function','endpoint', 'event']\nhook: enum['pre', 'post']\naction: enum['run', 'deploy'] // only function support `run` action\nparams: array\n```\n3. Params will be digested in `require(path).apply(params)` manner. Therefore in the header function file, retrieve params by calling lexical `arguments`\n4. The second last of the params will be the **Serverless** object which contains Serverless classes and actions\n5. The last of the params will be the **context** object which contains information about the serverless action\n6. Exports the file as a single function without input parameter\n`module.exports = function () { console.log(a,b) }`\n7. Profit!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhieuunguyeen%2Fserverless-header-function","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhieuunguyeen%2Fserverless-header-function","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhieuunguyeen%2Fserverless-header-function/lists"}