{"id":21744049,"url":"https://github.com/telefonica/alfalfa","last_synced_at":"2026-03-02T23:31:39.869Z","repository":{"id":11310076,"uuid":"69255027","full_name":"Telefonica/alfalfa","owner":"Telefonica","description":"Opinionated startup for node services and applications to remove plumbing and boilerplate","archived":false,"fork":false,"pushed_at":"2022-12-11T01:16:30.000Z","size":5261,"stargazers_count":10,"open_issues_count":4,"forks_count":1,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-13T05:07:13.199Z","etag":null,"topics":["cdco"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Telefonica.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}},"created_at":"2016-09-26T13:53:08.000Z","updated_at":"2022-05-23T09:06:18.000Z","dependencies_parsed_at":"2023-01-13T16:27:01.015Z","dependency_job_id":null,"html_url":"https://github.com/Telefonica/alfalfa","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Telefonica%2Falfalfa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Telefonica%2Falfalfa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Telefonica%2Falfalfa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Telefonica%2Falfalfa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Telefonica","download_url":"https://codeload.github.com/Telefonica/alfalfa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665747,"owners_count":21142123,"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":["cdco"],"created_at":"2024-11-26T07:09:50.668Z","updated_at":"2026-03-02T23:31:39.819Z","avatar_url":"https://github.com/Telefonica.png","language":"TypeScript","readme":"![Alfalfa Logo][alfalfalogo]\n# alfalfa [![npm version](https://badge.fury.io/js/alfalfa.svg)](http://badge.fury.io/js/alfalfa) ![Typescript](https://img.shields.io/badge/TypeScript-.ts-blue.svg)\n\n*Opinionated startup for node applications. Get rid of boilerplate.*\n\n\u003e Alfalfa comes from Alpha. _Because this will become the very beginning of every Node.js service you create_\n\n## Usage\n\n```js\nimport alfalfa from 'alfalfa';\nimport express from 'express';\nimport http from 'http';\n\nconst app = express();\n\nlet app = express(); // use your favorite framework\nlet server = http.createServer(app); // your app will be exposed as an http server\nlet agent = new http.Agent({ keepAlive: true });\n\n// Create a startup way to bring up your service\nlet startup = alfalfa.Startup();\n\n// Check some preconditions before starting\n\n// Configure the runners you want to use\nstartup.use(alfalfa.AgentRunner({ agent }));\nstartup.use(alfalfa.ServerRunner({ server, port: 3000 }));\n\nstartup.bootstap('Service'); // Yeah! Create the process with title 'Service'\n```\n\nWhat's is going on here? Alfalfa bootstraps your app by starting each one of the runners defined.\nEach runner is a proven block that saves you from writing boilerplate and error-prone code again and again.\nThere are several runners available. More on this can be found in the [example folder](./example/).\n\nMoreover, alfafa also prints traces for monitoring the startup, and manages the operating system\nsignals and unhandled exceptions/rejections/warnings.\n\n```sh\nnode server.js\n\nHTTPServer listening on http://0.0.0.0:3001\nHTTPServer ready\nMyService ready\n\u003c-- Crtl-C\nStopping MyService. SIGINT received\nStopping HTTPServer\nStopping HTTPAgent\nMyService stopped\n````\n\n## Available Runners\n\n### ServerRunner\nStarts a node server in the specified port. Features:\n - Adds listeners to the server to print its lifecycle, allowing monitorization.\n - Adds support for a graceful shutdown, with a 9.5s grace period.\n\n### AgentRunner\nTracks a KeepAlived [http.Agent](https://nodejs.org/api/http.html#http_new_agent_options). Features:\n - Destroys the keep alived sokets when the service shutdows\n\n## LICENSE\n\nCopyright 2022 [Telefónica I+D](http://www.tid.es)\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n[alfalfalogo]: art/alfalfa-githubbanner.png\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelefonica%2Falfalfa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelefonica%2Falfalfa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelefonica%2Falfalfa/lists"}