{"id":21801413,"url":"https://github.com/shreyasnayak/nodejs-faas","last_synced_at":"2025-03-21T06:47:13.122Z","repository":{"id":233458633,"uuid":"786828703","full_name":"shreyasnayak/nodejs-faas","owner":"shreyasnayak","description":" This project aims to achieve something similar to Function as a Service (FaaS) without the overhead of Docker or Kubernetes, with extremely low infrastructure requirements.","archived":false,"fork":false,"pushed_at":"2024-07-29T06:17:28.000Z","size":761,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T03:42:00.976Z","etag":null,"topics":["faas","fuction","function-as-a-service","lightweight","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shreyasnayak.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":"2024-04-15T11:37:43.000Z","updated_at":"2024-07-29T06:17:31.000Z","dependencies_parsed_at":"2024-07-29T07:12:43.183Z","dependency_job_id":null,"html_url":"https://github.com/shreyasnayak/nodejs-faas","commit_stats":null,"previous_names":["shreyasnayak/nodejs-faas"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shreyasnayak%2Fnodejs-faas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shreyasnayak%2Fnodejs-faas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shreyasnayak%2Fnodejs-faas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shreyasnayak%2Fnodejs-faas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shreyasnayak","download_url":"https://codeload.github.com/shreyasnayak/nodejs-faas/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244752335,"owners_count":20504254,"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":["faas","fuction","function-as-a-service","lightweight","nodejs"],"created_at":"2024-11-27T11:17:49.672Z","updated_at":"2025-03-21T06:47:13.099Z","avatar_url":"https://github.com/shreyasnayak.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NodeJS-FAAS\n\nThis project aims to provide a Function as a Service (FaaS) solution with minimal infrastructure requirements, avoiding the overhead of Kubernetes.\n\n## Why Choose NodeJS-FAAS?\n\nIn the modern era, event-driven, microservice-based architecture is gaining popularity. FaaS allows you to trigger code execution based on events. However, hosting FaaS on a Kubernetes cluster can be costly. NodeJS-FAAS offers a lightweight alternative, providing an efficient lambda function solution without the need for Kubernetes. It is not intended to replace solutions like OpenFaaS but to offer a simpler, more resource-efficient option.\n\n## How It Works\n\nNodeJS-FAAS uses the built-in Node.js VM module to execute code.\n\n## Setup Instructions\n\nYou can set up NodeJS-FAAS using Docker or Containerd.\n\n### Using Docker\n\nTo pull the Docker image:\n\n```sh\ndocker pull shreyasnayak21/nodejs-faas:1.2.0\n```\n\nTo run the Docker container:\n\n```sh\ndocker run -d -p 9256:9256 -e JWT_KEY=1X2A0p84VmmLF3NYz3uHPx1hLuhT2U24 -v functions:/opt/app/functions shreyasnayak21/nodejs-faas:1.2.0\n```\n\n### Using Containerd\n\nTo pull the image with Containerd:\n\n```sh\nnerdctl pull shreyasnayak21/nodejs-faas:1.2.0\n```\n\nTo run the container with Containerd:\n\n```sh\nnerdctl run -d -p 9256:9256 -e JWT_KEY=1X2A0p84VmmLF3NYz3uHPx1hLuhT2U24 -v functions:/opt/app/functions shreyasnayak21/nodejs-faas:1.2.0\n```\n\n### Using `pm2`\n\nYou can also run the source code using `pm2`:\n\n```sh\nnpm install\nnpm start\n```\n\nTo start the NodeJS-FAAS using `pm2`:\n\n```sh\npm2 start index.mjs --name NodeJS-FAAS\n```\n\n## Usage\n\nCurrently, NodeJS-FAAS provides an interface over an [HTTP API](openapi.json). You can create a lambda function or upload code in an `mjs` file to the instance and execute the function using the API. Future plans include adding NATS.io or Pub/Sub for function triggers.\n\n## Example Code\n\n### Calling the HTTP API\n\n```mjs\nconst axios = require('axios');\n\nfunction main(event, context, callback) {\n    if (event === \"get_nasa_image\") {\n        const { key } = context;\n        axios.get(`https://api.nasa.gov/planetary/apod?api_key=${key}`)\n            .then(response =\u003e {\n                if (callback) callback({\n                    explanation: response.data.explanation\n                });\n            })\n            .catch(error =\u003e {\n                if (callback) callback({\n                    error: error.message\n                });\n            });\n    }\n}\n\nmain(G_EVENT_NAME, G_CONTEXT, G_CALLBACK);\n```\n\n## Generating a Token\n\nTo generate a token, visit the [JWT Generator Website](https://jwt.io/). Use the JWT_KEY you provided for the container and input the following content in the body, adjusting the parameters as needed:\n\n```json\n{\n    \"expire_at\": \"1735713720\",\n    \"issued_at\": \"1721994397\",\n    \"issuer\": \"shreyas\",\n    \"namespace\": \"neo\"\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshreyasnayak%2Fnodejs-faas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshreyasnayak%2Fnodejs-faas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshreyasnayak%2Fnodejs-faas/lists"}