{"id":24176555,"url":"https://github.com/suchlab/lanza","last_synced_at":"2026-05-06T06:31:20.093Z","repository":{"id":65346728,"uuid":"576765609","full_name":"suchlab/lanza","owner":"suchlab","description":"Launch-ready server tools to create APIs","archived":false,"fork":false,"pushed_at":"2023-06-07T14:46:52.000Z","size":853,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-05T05:37:47.852Z","etag":null,"topics":["api","event-bus","express","mysql","server"],"latest_commit_sha":null,"homepage":"https://npmjs.com/lanza","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/suchlab.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":"2022-12-10T22:46:48.000Z","updated_at":"2022-12-11T01:32:52.000Z","dependencies_parsed_at":"2024-10-06T12:38:59.706Z","dependency_job_id":"3b8e5d01-f9ce-4045-bbc1-2c4f7549c547","html_url":"https://github.com/suchlab/lanza","commit_stats":{"total_commits":18,"total_committers":3,"mean_commits":6.0,"dds":"0.38888888888888884","last_synced_commit":"d392feb2c08b949cea7757b42c1f43beb99751f8"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/suchlab/lanza","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suchlab%2Flanza","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suchlab%2Flanza/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suchlab%2Flanza/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suchlab%2Flanza/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/suchlab","download_url":"https://codeload.github.com/suchlab/lanza/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suchlab%2Flanza/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267961971,"owners_count":24172534,"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-07-30T02:00:09.044Z","response_time":70,"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":["api","event-bus","express","mysql","server"],"created_at":"2025-01-13T03:16:26.876Z","updated_at":"2026-05-06T06:31:15.053Z","avatar_url":"https://github.com/suchlab.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lanza\n![CI](https://github.com/suchlab/lanza/actions/workflows/ci.yaml/badge.svg)\n\nLanza is a launch-ready server tools package to create APIs\n\n# Server\n\n```js\nimport { Server } from 'lanza';\n\nconst server = new Server();\nawait server.start();\n```\n\nWithout any configuration this server already has:\n- Initialized in the 8000 port\n- /health endpoint\n- 404 errors\n- Error handler (no app crashes)\n- Disabled `x-powered-by` header\n- Incoming JSON requests parsed\n- CORS\n\n## Installation\nYou will have to install the `lanza` package:\n\n```\nnpm install lanza\n```\n\n## Options\n| Option | Default | Description |\n|---|---|---|\n| hostname | ` ` | Hostname for the API |\n| port | `8000` | Port to access the API |\n| cors | `true` | CORS enabled to accept requests from anywhere |\n| versions | `[]` | API versions. Check below for more details |\n| healthCheck | `null` | Custom /health endpoint response |\n| error404 | `null` | Custom 404 error response |\n| maxBodySize | `200mb` | Max body size the API can receive |\n| rawBody | `false` | Option to store the unparsed request in `req.rawBody`  |\n| logger | `null` | Custom logger to log errors |\n| appMiddlewares | `null` | Express' application-level middlewares |\n\n## Versions\nYou can use various API versions in Lanza. You have to pass the array of versions to the `versions` option of the server.\n\n| Option | Description |\n|---|---|\n| path | Path for the versions (e.g. `/v1`) |\n| routes | Array of routes. Check below for more details |\n| middlewares | Array of conditional middlewares for the routes. Check below for more details |\n\n## Routes\n| Option | Description |\n|---|---|\n| path | Path of the resource without the version path (e.g. `/users`) |\n| method | Method of the request (e.g. `post`) |\n| handler | Function that will handle the request |\n| dto | Function that will get your response and transform it before returning it to the client |\n\n## Middlewares\n| Option | Description |\n|---|---|\n| condition | Function to check if the path fulfills the condition to execute the middleware |\n| handler | Function that will act as a middleware |\n\n\u003e Note: The order of the middlewares matter\n\n## Responses\nThere is no need to use `res.status(200).send(...)` anymore (although you still can).\n\nYou can directly return booleans, text, and objects and Lanza will handle the responses for you:\n\n| Type | Response |\n|---|---|\n| boolean | `{ \"success\": true }` or `{ \"success\": false }` |\n| string | Will return the string |\n| JSON | Will return the JSON with its content type |\n\n## Errors\nIf an error occurs and it is thrown, Lanza will return the error in a specific format:\n```json\n{\n  \"error\": {\n    \"message\": \"Custom error message\"\n  }\n}\n```\n\n## Example\n```js\nimport { Server } from 'lanza';\n\nconst server = new Server({\n  port: 8008,\n  rawBody: true,\n  versions: [\n    {\n      path: '/v1',\n      middlewares: [\n        {\n          condition: (route) =\u003e !!route.executeMiddleware,\n          handler: (req, _res, next) =\u003e {\n            req.middlewareExecuted = true;\n            next();\n          }\n        }\n      ],\n      routes: [\n        {\n          method: 'get',\n          path: '/test',\n          executeMiddleware: true,\n          handler: (req) =\u003e {\n            console.log(req.middlewareExecuted);\n            return true;\n          }\n        }\n      ],\n    }\n  ]\n});\n\nawait server.start();\n```\n\nMaking a request to `/test` would log a `true` and the client would receive a `{ \"success\": true }`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuchlab%2Flanza","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuchlab%2Flanza","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuchlab%2Flanza/lists"}