{"id":42361,"library":"zhi-gitlab-middleware","title":"zhi-gitlab-middleware","description":"zhi-gitlab-middleware is a middleware library for GitLab API, version 0.12.4. It provides a simple way to interact with GitLab's API through middleware patterns, allowing you to add custom logic before or after API calls. The library is built in TypeScript and ships with type definitions. It has no external dependencies, making it lightweight and easy to integrate into any Node.js project. Compared to other GitLab API clients, it focuses on middleware composition rather than a full-featured client, giving developers fine-grained control over API interactions. Release cadence is irregular.","status":"active","version":"0.12.4","language":"javascript","source_language":"en","source_url":"https://github.com/terwer/zhi","tags":["javascript","zhi","lib","typescript"],"install":[{"cmd":"npm install zhi-gitlab-middleware","lang":"bash","label":"npm"},{"cmd":"yarn add zhi-gitlab-middleware","lang":"bash","label":"yarn"},{"cmd":"pnpm add zhi-gitlab-middleware","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only library; CommonJS require will not work.","wrong":"const GitLabMiddleware = require('zhi-gitlab-middleware')","symbol":"GitLabMiddleware","correct":"import { GitLabMiddleware } from 'zhi-gitlab-middleware'"},{"note":"createMiddleware is a named export, not default.","wrong":"import createMiddleware from 'zhi-gitlab-middleware'","symbol":"createMiddleware","correct":"import { createMiddleware } from 'zhi-gitlab-middleware'"},{"note":"GitLabClient is a TypeScript type, use `import type` at compile time.","wrong":"import { GitLabClient } from 'zhi-gitlab-middleware'","symbol":"GitLabClient","correct":"import type { GitLabClient } from 'zhi-gitlab-middleware'"}],"quickstart":{"code":"import { GitLabMiddleware, createMiddleware } from 'zhi-gitlab-middleware'\n\n// Create a middleware instance\nconst middleware = new GitLabMiddleware({\n  baseUrl: 'https://gitlab.com',\n  token: process.env.GITLAB_TOKEN ?? ''\n})\n\n// Define a custom middleware\nconst logger = createMiddleware(async (req, next) => {\n  console.log('Requesting:', req.url)\n  const res = await next(req)\n  console.log('Response status:', res.status)\n  return res\n})\n\n// Use the middleware\nconst client = middleware.use(logger).getClient()\n\n// Example: get current user\nasync function main() {\n  const user = await client.users.current()\n  console.log('User:', user.name)\n}\n\nmain()","lang":"typescript","description":"Initializes GitLabMiddleware with token, adds logging middleware via createMiddleware, and fetches current user."},"warnings":[{"fix":"Update middleware to use the new function signature: `middleware.use((req, next) => ...)`","message":"Version 0.12.x changed the middleware API; `use` now expects a function instead of an object.","severity":"breaking","affected_versions":">=0.12.0 <0.12.4"},{"fix":"Replace `host` with `baseUrl` in the constructor options.","message":"The `GitLabMiddleware` constructor option `host` is deprecated; use `baseUrl` instead.","severity":"deprecated","affected_versions":">=0.10.0"},{"fix":"Implement custom middleware to check response status and refresh token if needed.","message":"The library does not handle token refresh automatically; expired tokens cause 401 errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure types are imported directly from the package: `import { GitLabClient } from 'zhi-gitlab-middleware'`","message":"TypeScript types are exported under `@types/zhi-gitlab-middleware`; do not use `@types/zhi-gitlab-middleware` as it may mismatch version.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'0.12.4':17 'add':35 'allow':32 'api':15,28,41,74,95 'built':46 'cadenc':98 'call':42 'client':75,87 'compar':70 'composit':80 'control':93 'custom':36 'definit':53 'depend':58 'develop':89 'easi':63 'extern':57 'featur':86 'fine':91 'fine-grain':90 'focus':77 'full':85 'full-featur':84 'gitlab':3,7,14,26,73 'give':88 'grain':92 'integr':65 'interact':24,96 'irregular':100 'javascript':101 'lib':103 'librari':12,44 'lightweight':61 'logic':37 'make':59 'middlewar':4,8,11,30,79 'node.js':68 'pattern':31 'project':69 'provid':19 'rather':81 'releas':97 'ship':50 'simpl':21 'type':52 'typescript':48,104 'version':16 'way':22 'zhi':2,6,102 'zhi-gitlab-middlewar':1,5","created_at":"2026-06-04T18:56:53.006111+00:00","updated_at":"2026-06-04T18:56:53.006111+00:00","problems":[{"fix":"Run `npm install zhi-gitlab-middleware` and ensure `tsconfig.json` includes `\"moduleResolution\": \"node\"`","cause":"Missing dependency or TypeScript not resolving types.","error":"Cannot find module 'zhi-gitlab-middleware' or its corresponding type declarations."},{"fix":"Ensure you are calling `use` on the `GitLabMiddleware` instance: `const middleware = new GitLabMiddleware(...); middleware.use(...)`","cause":"Using outdated API where `use` was a method on the client object, not the middleware instance.","error":"TypeError: middleware.use is not a function"},{"fix":"Check GitLab API docs; use `users.me()` instead of `users.current()` for GitLab API v4.","cause":"GitLab API version mismatch; `current` endpoint may be named differently in older versions.","error":"Property 'current' does not exist on type 'Users'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/terwer/zhi/tree/main/libs/zhi-gitlab-middleware","github":"https://github.com/terwer/zhi","docs":null,"changelog":null,"pypi":null,"npm":"zhi-gitlab-middleware","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}