{"id":30945459,"url":"https://github.com/normal-coder/next-go-modules","last_synced_at":"2026-06-28T05:31:55.849Z","repository":{"id":310568515,"uuid":"1039626469","full_name":"normal-coder/next-go-modules","owner":"normal-coder","description":"Go Modules proxy middleware designed for Next.js 13+, with perfect Vercel support.","archived":false,"fork":false,"pushed_at":"2025-08-18T22:01:53.000Z","size":130,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-11T01:15:51.913Z","etag":null,"topics":["go-modules","go-proxy","next-middleware","nextjs","nextjs-middleware"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/next-go-modules","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/normal-coder.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2025-08-17T16:35:57.000Z","updated_at":"2025-08-18T22:01:56.000Z","dependencies_parsed_at":"2025-08-19T00:13:42.243Z","dependency_job_id":"c1eede12-b6f1-4687-8ce7-3926b2cbf32f","html_url":"https://github.com/normal-coder/next-go-modules","commit_stats":null,"previous_names":["normal-coder/next-go-modules"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/normal-coder/next-go-modules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/normal-coder%2Fnext-go-modules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/normal-coder%2Fnext-go-modules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/normal-coder%2Fnext-go-modules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/normal-coder%2Fnext-go-modules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/normal-coder","download_url":"https://codeload.github.com/normal-coder/next-go-modules/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/normal-coder%2Fnext-go-modules/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34878963,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-28T02:00:05.809Z","response_time":54,"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":["go-modules","go-proxy","next-middleware","nextjs","nextjs-middleware"],"created_at":"2025-09-10T23:10:31.608Z","updated_at":"2026-06-28T05:31:55.844Z","avatar_url":"https://github.com/normal-coder.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# next-go-modules\n\n![NPM Version](https://img.shields.io/npm/v/next-go-modules)\n[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n![Top language](https://img.shields.io/github/languages/top/normal-coder/next-go-modules)\n\n![social preview for next-go-modules](./images/next-go-modules.png)\n\nGo Modules proxy middleware designed for Next.js 13+, with perfect Vercel support.\n\n[English](./README.md) | [中文](./README.zh-cn.md)\n\n## Features\n\n- ✅ Out-of-the-box, simple configuration\n- ✅ Support for personalized Go Modules addresses with aliases\n- ✅ No Nginx dependency, perfect Vercel deployment support\n- ✅ Compatible with Next.js 13.0+ (App Router \u0026 Pages Router)\n- ✅ TypeScript support, configurable caching, debug mode\n- ✅ Cross-version compatibility (avoids Next.js type conflicts)\n\n## Installation\n\n```bash\n# npm\nnpm install next-go-modules\n\n# yarn\nyarn add next-go-modules\n\n# pnpm\npnpm add next-go-modules\n```\n\n## Quick Start\n\n### Option 1: Using CLI Tool (Recommended)\n\n```bash\n# Auto-generate all necessary files\nnpx next-go-modules init\n\n# Or if installed globally\nnext-go-modules init\n```\n\nThis will automatically create:\n- `config/go-modules.ts` - Module configuration file\n- `middleware.ts` - Next.js middleware\n- API route files (automatically detects App Router or Pages Router)\n\nThen simply edit `config/go-modules.ts` to add your Go modules configuration.\n\n\u003e [!NOTE]\n\u003e If your project already has a `middleware.ts` file, the CLI tool will provide integration guidance instead of overwriting the existing file.\n\n### Option 2: Manual Setup\n\n#### 1. Create your modules configuration\n\n```typescript\n// config/go-modules.ts\nimport { GoModulesConfig } from 'next-go-modules'\n\nexport const goModulesConfig: GoModulesConfig = {\n  modules: {\n    'my-go-tool': {\n      name: 'my-go-tool',\n      fullName: 'yourdomain.com/my-go-tool',\n      repo: 'https://github.com/yourusername/my-go-tool',\n      description: 'Your Go tool description',\n      install: 'go get -u yourdomain.com/my-go-tool',\n      version: 'v1.0.0',\n      aliases: ['tool'], // Optional aliases\n    },\n    // Add more modules here...\n  },\n}\n```\n\n#### 2. Create your middleware\n\n**Option A: Using the helper function (Recommended for Next.js 15)**\n\n```typescript\n// src/middleware.ts (if using src directory) or middleware.ts (project root)\nimport { createGoModulesMiddleware } from 'next-go-modules'\nimport { goModulesConfig } from './config/go-modules'\n\nconst goModulesMiddleware = createGoModulesMiddleware({\n  config: goModulesConfig,\n  debug: process.env.NODE_ENV === 'development',\n})\n\nexport default function middleware(request: any) {\n  return goModulesMiddleware(request)\n}\n\nexport const config = {\n  matcher: [\n    '/((?!api|_next/static|_next/image|favicon.ico|manifest.webmanifest|sitemap.xml).*)',\n  ],\n}\n```\n\n#### 3. Create your API route\n\n```typescript\n// app/api/go-modules/[...module]/route.ts (App Router)\nimport { createGoModulesApiRoute, createGoModulesHeadRoute } from 'next-go-modules'\nimport { goModulesConfig } from '../../../../config/go-modules'\n\nexport const GET = createGoModulesApiRoute(goModulesConfig)\nexport const HEAD = createGoModulesHeadRoute(goModulesConfig)\n```\n\nOr using Pages Router:\n\n```typescript\n// pages/api/go-modules/[...module].ts (Pages Router)\nimport { createGoModulesApiRoute } from 'next-go-modules'\nimport { goModulesConfig } from '../../../config/go-modules'\n\nexport default createGoModulesApiRoute(goModulesConfig)\n```\n\n## Usage\n\nNow your Go modules will be accessible at:\n\n- `/my-go-tool` - Main path\n- `/tool` - Alias path\n- `/my-go-tool?go-get=1` - With go-get parameter\n\nUsers can install your Go modules with:\n\n```bash\ngo get -u yourdomain.com/my-go-tool\n```\n\n## Configuration Options\n\n### GoModule\n\n```typescript\ninterface GoModule {\n  name: string // Module name\n  fullName: string // Full module path (e.g., 'example.com/module')\n  repo: string // Repository URL\n  description: string // Module description\n  install: string // Installation command\n  tags?: string[] // Optional tags\n  version?: string // Optional version\n  aliases?: string[] // Optional aliases\n}\n```\n\n### GoModulesConfig\n\n```typescript\ninterface GoModulesConfig {\n  modules: Record\u003cstring, GoModule\u003e\n  apiRoute?: string // Default: '/api/go-modules'\n  matcher?: string[] // Default: excludes static files\n  cacheControl?: string // Default: 'public, max-age=3600'\n}\n```\n\n### MiddlewareOptions\n\n```typescript\ninterface MiddlewareOptions {\n  config: GoModulesConfig\n  debug?: boolean // Enable debug logging\n}\n```\n\n## Advanced Usage\n\n### Custom API Route\n\n```typescript\nconst config: GoModulesConfig = {\n  modules: { /* your modules */ },\n  apiRoute: '/api/custom-go-modules',\n}\n```\n\n### Custom Cache Control\n\n```typescript\nconst config: GoModulesConfig = {\n  modules: { /* your modules */ },\n  cacheControl: 'public, max-age=7200', // 2 hours\n}\n```\n\n### Custom Matcher\n\n```typescript\nconst config: GoModulesConfig = {\n  modules: { /* your modules */ },\n  matcher: [\n    '/((?!api|_next|favicon.ico).*)',\n  ],\n}\n```\n\n### Debug Mode\n\n```typescript\nconst middleware = createGoModulesMiddleware({\n  config: goModulesConfig,\n  debug: true, // Enable console logging\n})\n```\n\n### Integration with Existing Middleware\n\nIf you already have middleware, you can use the compose function:\n\n```typescript\n// middleware.ts\nimport { composeMiddleware, createGoModulesMiddleware } from 'next-go-modules'\nimport { goModulesConfig } from './config/go-modules'\n\n// Your existing middleware\nfunction yourExistingMiddleware(request) {\n  // Your logic\n}\n\n// Go modules middleware\nconst goModulesMiddleware = createGoModulesMiddleware({\n  config: goModulesConfig,\n  debug: process.env.NODE_ENV === 'development',\n})\n\n// Compose middlewares\nexport default composeMiddleware(\n  goModulesMiddleware,\n  yourExistingMiddleware\n)\n```\n\n## API Reference\n\n### Core Functions\n\n- `getGoModule(modulePath, modules)` - Get module by path or alias\n- `getAllGoModules(modules)` - Get all modules\n- `getAllModulePaths(modules)` - Get all available paths\n- `generateGoModuleHTML(module)` - Generate HTML for module\n\n### Middleware Functions\n\n- `createGoModulesMiddleware(options)` - Create middleware function\n- `getGoModulesMiddlewareConfig(options)` - Get middleware config\n\n### API Route Functions\n\n- `createGoModulesApiRoute(config)` - Create GET handler\n- `createGoModulesHeadRoute(config)` - Create HEAD handler\n\n## Examples\n\n### Multiple Modules with Aliases\n\n```typescript\nconst config: GoModulesConfig = {\n  modules: {\n    'go-masker': {\n      name: 'go-masker',\n      fullName: 'normalcoder.com/go-masker',\n      repo: 'https://github.com/normal-coder/go-masker',\n      description: 'Data masking tool',\n      install: 'go get -u normalcoder.com/go-masker',\n      aliases: ['masker', 'data-masker'],\n    },\n    'go-validator': {\n      name: 'go-validator',\n      fullName: 'normalcoder.com/go-validator',\n      repo: 'https://github.com/normal-coder/go-validator',\n      description: 'Data validation tool',\n      install: 'go get -u normalcoder.com/go-validator',\n      aliases: ['validator', 'validate'],\n    },\n  },\n}\n```\n\nThis supports:\n- `/go-masker`, `/masker`, `/data-masker`\n- `/go-validator`, `/validator`, `/validate`\n\n## Deployment\n\n### Vercel\n\nThis package works seamlessly with Vercel deployment. No additional configuration needed.\n\n### Other Platforms\n\nThe middleware is compatible with any platform that supports Next.js middleware.\n\n## Development\n\n### Development Setup\n\n```bash\n# Clone repository\ngit clone https://github.com/normal-coder/next-go-modules.git\ncd next-go-modules\n\n# Install dependencies\npnpm install\n\n# Development mode\npnpm dev\n\n# Lint code\npnpm lint\n\n# Build\npnpm build\n```\n\n### Commit Convention\n\nThis project uses [Conventional Commits](https://conventionalcommits.org/):\n\n```bash\n# Use commitizen for interactive commits\npnpm commit\n\n# Or manually follow the format\ngit commit -m \"feat: add new feature\"\ngit commit -m \"fix: resolve issue\"\ngit commit -m \"docs: update readme\"\n```\n\n### Version Management\n\nUsing [Changesets](https://github.com/changesets/changesets) for version management:\n\n```bash\n# Add changeset\npnpm changeset\n\n# Version packages\npnpm version\n\n# Release to npm\npnpm release\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`pnpm commit`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Create a Pull Request\n\n## Acknowledgments\n\n- [Next.js](https://nextjs.org/) - React full-stack framework\n- [TypeScript](https://www.typescriptlang.org/)\n- [ESLint](https://eslint.org/)\n- [Husky](https://typicode.github.io/husky/)\n- [Changesets](https://github.com/changesets/changesets)\n- [Commitizen](https://commitizen-tools.github.io/commitizen/)\n\n## License\n\n[MIT License](./LICENSE) - see LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnormal-coder%2Fnext-go-modules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnormal-coder%2Fnext-go-modules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnormal-coder%2Fnext-go-modules/lists"}