{"id":14983142,"url":"https://github.com/spaghiajoeojo/express-beans","last_synced_at":"2025-10-29T21:30:48.427Z","repository":{"id":156782595,"uuid":"625044359","full_name":"spaghiajoeojo/express-beans","owner":"spaghiajoeojo","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-05T13:45:04.000Z","size":635,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-09-28T08:41:27.506Z","etag":null,"topics":["dependency-injection","express","expressjs","ioc-container","java","mvc","mvc-framework","nodejs","spring-boot","spring-mvc","typescript"],"latest_commit_sha":null,"homepage":"https://spaghiajoeojo.github.io/express-beans/","language":"TypeScript","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/spaghiajoeojo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-04-07T23:07:18.000Z","updated_at":"2024-07-08T20:15:50.000Z","dependencies_parsed_at":"2023-10-16T11:01:36.179Z","dependency_job_id":"6b09cdc3-8ff4-455d-8d9e-0ee1fbc8e1a5","html_url":"https://github.com/spaghiajoeojo/express-beans","commit_stats":{"total_commits":41,"total_committers":3,"mean_commits":"13.666666666666666","dds":0.5365853658536586,"last_synced_commit":"f86915e2d7b3d20bac6a604627114c6f532a3319"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaghiajoeojo%2Fexpress-beans","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaghiajoeojo%2Fexpress-beans/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaghiajoeojo%2Fexpress-beans/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaghiajoeojo%2Fexpress-beans/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spaghiajoeojo","download_url":"https://codeload.github.com/spaghiajoeojo/express-beans/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219857296,"owners_count":16556070,"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":["dependency-injection","express","expressjs","ioc-container","java","mvc","mvc-framework","nodejs","spring-boot","spring-mvc","typescript"],"created_at":"2024-09-24T14:06:47.854Z","updated_at":"2025-10-29T21:30:48.414Z","avatar_url":"https://github.com/spaghiajoeojo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ExpressBeans\nExpressBeans is the IoC Container (Inversion of Control Container) that you didn't know you needed.\nIf you love Node.js and the Spring Boot way of code organization this lightweight framework is for you.\nExpressBeans is an almost zero dependency framework (it wraps Express.js) to offer an easy-to-use way of building your next Express project.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/logo.svg\" alt=\"\"\u003e\n\u003c/p\u003e\n\n![GitHub](https://img.shields.io/github/license/spaghiajoeojo/express-beans)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/spaghiajoeojo/express-beans/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/spaghiajoeojo/express-beans/?branch=main)\n![GitHub package.json dependency version (prod)](https://img.shields.io/github/package-json/dependency-version/spaghiajoeojo/express-beans/express)\n![GitHub package.json dependency version (dev)](https://img.shields.io/github/package-json/dependency-version/spaghiajoeojo/express-beans/dev/typescript)\n[![Build Status](https://scrutinizer-ci.com/g/spaghiajoeojo/express-beans/badges/build.png?b=main)](https://scrutinizer-ci.com/g/spaghiajoeojo/express-beans/build-status/main)\n\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=express-beans\u0026metric=coverage)](https://sonarcloud.io/summary/new_code?id=express-beans)\n[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=express-beans\u0026metric=bugs)](https://sonarcloud.io/summary/new_code?id=express-beans)\n[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=express-beans\u0026metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=express-beans)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=express-beans\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=express-beans)\n\n## Get started\nTry ExpressBeans with the official generator:\n```console\nnpm create express-beans-server\n```\n\n## Documentation\nAPI docs and types available in [documentation](https://spaghiajoeojo.github.io/express-beans/).\n\n## Usage\nAll you need is create an ExpressBeans application and provide your `RouterBean` classes:\n```ts\nExpressBeans.createApp({\n  routerBeans: [\n    ExampleRouter,\n  ],\n});\n\n/* ======== OR ======== */\n\nconst application = new ExpressBeans({\n  routerBeans: [\n    ExampleRouter,\n  ],\n});\n```\n\nIf you need also direct access to `express` application:\n```ts\nconst application = new ExpressBeans({\n  routerBeans: [\n    ExampleRouter,\n  ],\n});\nconst expressApp = application.getApp();\n```\n\n## Typescript 5\nNew decorators are here and ExpressBeans implements some simple decorators to achieve dependency injection and endpoint registration.\n\n### Example\n\n```ts\nimport { Request, Response } from 'express';\nimport { InjectBean, Route, RouterBean } from 'express-beans';\nimport { ExampleService } from '../services/ExampleService';\n\n@RouterBean('/example')\nexport class ExampleRouter {\n\n  @InjectBean(ExampleService)\n  private exampleService: ExampleService;\n\n  @Route('GET', '/hello')\n  getHello(_req: Request, res: Response) {\n    res.end(this.exampleService.example());\n  }\n}\n```\nThis will create a new router that expose an endpoint `GET /example/hello` and\n`exampleService` will be the instance of the class declared as it follow:\n```ts\nimport { Bean } from 'express-beans';\n\n@Bean\nexport class ExampleService {\n\n  private msg: string;\n\n  constructor() {\n    this.msg = 'hello world!';\n  }\n\n  example() {\n    return this.msg;\n  }\n}\n```\n## Installation\n\n```console\nnpm install express-beans\n```\n \n## Beans Lifecycle\n\nThe lifecycle of the beans is the following:\n\n- `start`: The application starts, and tasks registered for this phase are executed.\n- `register`: Beans and router beans are registered.\n- `routing`: Routes are registered.\n- `init`: The application is initialized, and tasks registered for this phase are executed.\n- `run`: The application is running, and tasks registered for this phase are executed.\n- `exit`: The application is shutting down, and tasks registered for this phase are executed.\n\n## Hooks\n\n### Setup\nYou can use the `@Setup` hook to add a function that will be executed right after the application is initialized.\n\n```ts\n@Setup\nmySetupFunction() {\n  // do something\n}\n```\nEvery request received will be served only after the application is initialized and `@Setup` functions are executed.\nprocess.emit('beforeExit', Number(code)\n### Shutdown\nYou can use the `@Shutdown` hook to add a function that will be executed right before the application is shutdown.\n\n### Order\nYou can use the `@Order` hook to set the execution order of a hook. The default order is 0, negative orders are executed before positive ones in the same phase.\n\n```ts\n@Shutdown\nmyShutdownFunction() {\n  // do something\n}\n```\n\n## Springboot like annotations\nIf you want to use Springboot like annotations you can use the following aliases:\n\n- `@PostConstruct` -\u003e `@Setup`\n- `@PreDestroy` -\u003e `@Shutdown`\n- `@Component` -\u003e `@Bean`\n- `@Service` -\u003e `@Bean`\n- `@Controller` -\u003e `@RouterBean`\n- `@Mapping` -\u003e `@Route`\n- `@Autowired` -\u003e `@InjectBean`\n\n## Contribute\nPull requests or issues/feature requests are welcome!\n\n\n## License\n[MIT](https://github.com/spaghiajoeojo/express-beans/blob/main/LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspaghiajoeojo%2Fexpress-beans","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspaghiajoeojo%2Fexpress-beans","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspaghiajoeojo%2Fexpress-beans/lists"}