{"id":30741844,"url":"https://github.com/luizfbalves/nespress","last_synced_at":"2025-09-04T01:02:38.023Z","repository":{"id":271951132,"uuid":"915086141","full_name":"luizfbalves/nespress","owner":"luizfbalves","description":"Nespress is a wrapper around Express that allows you to use decorators to define routes. It also includes a simple way to register controllers and their routes.","archived":false,"fork":false,"pushed_at":"2025-07-23T15:58:28.000Z","size":175,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-02T18:55:39.643Z","etag":null,"topics":["bun","decorators","express","nestjs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luizfbalves.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-01-10T23:51:57.000Z","updated_at":"2025-07-23T15:42:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"ebbce98f-53a6-47aa-aa4e-c75ebf2364b0","html_url":"https://github.com/luizfbalves/nespress","commit_stats":null,"previous_names":["luizfbalves/nespress"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/luizfbalves/nespress","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizfbalves%2Fnespress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizfbalves%2Fnespress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizfbalves%2Fnespress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizfbalves%2Fnespress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luizfbalves","download_url":"https://codeload.github.com/luizfbalves/nespress/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizfbalves%2Fnespress/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273534568,"owners_count":25122679,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bun","decorators","express","nestjs","typescript"],"created_at":"2025-09-04T01:02:36.768Z","updated_at":"2025-09-04T01:02:37.922Z","avatar_url":"https://github.com/luizfbalves.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nespress 🚀\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"README.pt-br.md\"\u003e🇧🇷 Português Brasileiro\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/npm/v/nespress.svg\" alt=\"NPM version\" /\u003e\n  \u003cimg src=\"https://img.shields.io/badge/License-MIT-green.svg\" alt=\"MIT License\" /\u003e\n  \u003cimg alt=\"NPM Downloads\" src=\"https://img.shields.io/npm/dm/nespress\"\u003e\n  \u003cimg alt=\"GitHub commit activity\" src=\"https://img.shields.io/github/commit-activity/t/luizfbalves/nespress\"\u003e\n\u003c/p\u003e\n\n## 📖 About\n\n**Nespress** is an elegant wrapper for Express that allows you to use decorators to define routes, similar to NestJS. The project makes it easy to develop RESTful APIs with TypeScript, providing a simple and intuitive way to register controllers and their routes.\n\n\u003e **Note:** This package is under active development and may undergo changes. Beta version available for community testing and feedback.\n\n## ✨ Features\n\n- 🏷️ **Decorators** for defining routes and HTTP methods\n- 🔄 **Automatic registration** of controllers and routes\n- 💉 **Dependency injection** similar to NestJS\n- 🧩 **Modular and extensible** - easy to integrate with other packages\n- 📦 **Zero configuration** - start using in seconds\n- 🔒 **Strong typing** with TypeScript\n\n## 🚀 Installation\n\nChoose your favorite package manager:\n\n```bash\n# NPM\nnpm install nespress\n\n# Yarn\nyarn add nespress\n\n# Bun\nbun i nespress\n```\n\n### TypeScript Configuration\n\nMake sure to enable these options in your `tsconfig.json`:\n\n```json\n{\n  \"compilerOptions\": {\n    \"emitDecoratorMetadata\": true,\n    \"experimentalDecorators\": true\n  }\n}\n```\n\n## 📝 Basic Usage\n\n### Starting the server\n\n```typescript\nimport { Nespress } from 'nespress'\n\nconst app = new Nespress({ controllers: [] })\napp.start(3000)\n```\n\n### Creating a simple controller\n\n```typescript\nimport { Controller, Get, Post, BODY, QUERY, PARAM } from 'nespress/decorators'\n\n@Controller({ path: '/users', version: 1 })\nexport class UsersController {\n  @Get()\n  getAll() {\n    return {\n      statusCode: 200,\n      data: ['John', 'Mary', 'Peter'],\n    }\n  }\n\n  @Post()\n  create(@BODY body: any) {\n    return {\n      statusCode: 201,\n      message: 'User created',\n      data: body,\n    }\n  }\n\n  @Get('/:id')\n  getById(@PARAM('id') id: string) {\n    return {\n      statusCode: 200,\n      data: { id, name: 'User ' + id },\n    }\n  }\n\n  @Get('/search')\n  search(@QUERY('name') name: string) {\n    return {\n      statusCode: 200,\n      data: { name },\n    }\n  }\n}\n```\n\n### Registering the controller\n\n```typescript\nimport { Nespress } from 'nespress'\nimport { UsersController } from './controllers/users.controller'\n\nconst app = new Nespress({\n  controllers: [UsersController],\n})\n\napp.start(3000)\nconsole.log('Server running at http://localhost:3000')\n```\n\n### API documentation\n\nAfter registering your controllers you can generate an OpenAPI specification.\nSimply call `generateDocs()` on the `NespressCore` instance and access\n`/api-docs`:\n\n```typescript\nimport { NespressCore } from 'nespress/core'\n\nconst core = new NespressCore([UsersController])\ncore.generateDocs()\ncore.initialize(3000)\n```\n\n## 🧩 Dependency Injection\n\nNespress supports dependency injection in NestJS style:\n\n```typescript\nimport { Controller, Get, Injectable, INJECT } from 'nespress/decorators'\nimport { Nespress } from 'nespress'\n\n@Injectable()\nclass UserService {\n  private users = ['John', 'Mary', 'Peter']\n\n  getUsers() {\n    return this.users\n  }\n\n  getUserById(id: number) {\n    return this.users[id]\n  }\n}\n\n@Controller({ path: '/users', version: 1 })\nclass UserController {\n  @INJECT(UserService)\n  private userService!: UserService\n\n  @Get('/list')\n  getUsers() {\n    return {\n      statusCode: 200,\n      data: this.userService.getUsers(),\n    }\n  }\n}\n\nconst app = new Nespress({\n  controllers: [UserController],\n  providers: [UserService],\n})\n\napp.start(3000)\n```\n\n## 📌 Available Decorators\n\n### Controller Decorators\n\n- `@Controller(options)` - Defines a class as a controller\n- `@Injectable()` - Marks a class as Injectable\n- `@INJECT(Provider)` - Injects a provider into a property\n\n### HTTP Method Decorators\n\n- `@Get(path?)` - Defines a GET route\n- `@Post(path?)` - Defines a POST route\n- `@Put(path?)` - Defines a PUT route\n- `@Delete(path?)` - Defines a DELETE route\n- `@Patch(path?)` - Defines a PATCH route\n\n### Parameter Decorators\n\n- `@BODY` - Accesses the request body\n- `@PARAM(name?)` - Accesses a URL parameter\n- `@QUERY(name?)` - Accesses a query parameter\n- `@HEADERS(name?)` - Accesses request headers\n\n## 🧪 Advanced Examples\n\n### Middlewares\n\n```typescript\nimport { Controller, Get, Middleware } from 'nespress/decorators'\n\nfunction authMiddleware(req: Request, res: Response, next: NextFunction) {\n  if (req.headers.authorization) {\n    next()\n  } else {\n    res.status(401).json({ message: 'Unauthorized' })\n  }\n}\n\n@Controller({ path: '/admin' })\nclass AdminController {\n  @Get('/dashboard')\n  @Middleware(authMiddleware)\n  getDashboard() {\n    return {\n      statusCode: 200,\n      data: { message: 'Admin dashboard' },\n    }\n  }\n}\n```\n\n### Nested Controllers\n\n```typescript\n@Controller({ path: '/api', version: 1 })\nclass ApiController {\n  @Controller({ path: '/users' })\n  class UsersController {\n    @Get()\n    getUsers() {\n      return { statusCode: 200, data: ['John', 'Mary'] };\n    }\n  }\n}\n```\n\n## 🤝 Contributing\n\nContributions are welcome! Feel free to open issues or submit pull requests.\n\n1. Fork the project\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add: awesome implementation'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## 📃 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n---\n\n\u003cp align=\"center\"\u003eMade with ☕ and TypeScript.\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluizfbalves%2Fnespress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluizfbalves%2Fnespress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluizfbalves%2Fnespress/lists"}