{"_id":"@el_saintt/adapter-nextjs","name":"@el_saintt/adapter-nextjs","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@el_saintt/adapter-nextjs","version":"1.0.0","description":"Next.js adapter for @el_saintt/core - App Router and Pages Router support","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs","types":"./dist/index.d.ts"},"./app":{"require":"./dist/app-router/index.js","import":"./dist/app-router/index.mjs","types":"./dist/app-router/index.d.ts"},"./pages":{"require":"./dist/pages-router/index.js","import":"./dist/pages-router/index.mjs","types":"./dist/pages-router/index.d.ts"}},"keywords":["portfolio","nextjs","adapter","app-router","pages-router"],"author":"","license":"MIT","repository":{"type":"git","url":"git+https://github.com/stElmitchay/crispy-goggles.git"},"bugs":{"url":"https://github.com/stElmitchay/crispy-goggles/issues"},"homepage":"https://github.com/stElmitchay/crispy-goggles#readme","dependencies":{"@el_saintt/core":"1.0.0"},"peerDependencies":{"next":"^13.0.0 || ^14.0.0 || ^15.0.0"},"devDependencies":{"@types/node":"^20.11.0","next":"^14.1.0","tsup":"^8.0.1","typescript":"^5.3.3","vitest":"^1.2.0"},"publishConfig":{"access":"public"},"scripts":{"build":"tsup src/index.ts src/app-router/index.ts src/pages-router/index.ts --format cjs,esm --dts","dev":"tsup src/index.ts src/app-router/index.ts src/pages-router/index.ts --format cjs,esm --dts --watch","test":"vitest run","test:watch":"vitest"},"gitHead":"223363c33555a40217d8b6530d225c417c63f32e","_id":"@el_saintt/adapter-nextjs@1.0.0","_integrity":"sha512-WCi8z6Jmj41H1Kl+zQkKFBeTf4dumWPyaaKEAY8oxsLHdqbT9jXBkTYVkX7gyRXlwBLU8mEkzL9sskgt6RC0hA==","_resolved":"/private/var/folders/60/fd86h0px5fg_3k_5k1s7h1dc0000gp/T/91acb9e246aad291e9db1f09d57b52af/el_saintt-adapter-nextjs-1.0.0.tgz","_from":"file:el_saintt-adapter-nextjs-1.0.0.tgz","_nodeVersion":"21.7.3","_npmVersion":"10.5.0","dist":{"integrity":"sha512-WCi8z6Jmj41H1Kl+zQkKFBeTf4dumWPyaaKEAY8oxsLHdqbT9jXBkTYVkX7gyRXlwBLU8mEkzL9sskgt6RC0hA==","shasum":"0bb0b20c5855826150794d594d57745e0b633f19","tarball":"https://registry.npmjs.org/@el_saintt/adapter-nextjs/-/adapter-nextjs-1.0.0.tgz","fileCount":22,"unpackedSize":73598,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGBC4y2o4ZPEv0WyjdX2V+GTK/hyW3KUelUPgaWIUXauAiBsd4abmyZ+AX71Pr4zk6ZQHzjdnIRqiBZ4lQinjNTGUg=="}]},"_npmUser":{"name":"el_saintt","email":"elmitchay@gmail.com"},"directories":{},"maintainers":[{"name":"el_saintt","email":"elmitchay@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/adapter-nextjs_1.0.0_1760111355344_0.45553197412917834"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-10T15:49:15.212Z","1.0.0":"2025-10-10T15:49:15.523Z","modified":"2025-10-10T15:49:15.832Z"},"maintainers":[{"name":"el_saintt","email":"elmitchay@gmail.com"}],"description":"Next.js adapter for @el_saintt/core - App Router and Pages Router support","homepage":"https://github.com/stElmitchay/crispy-goggles#readme","keywords":["portfolio","nextjs","adapter","app-router","pages-router"],"repository":{"type":"git","url":"git+https://github.com/stElmitchay/crispy-goggles.git"},"bugs":{"url":"https://github.com/stElmitchay/crispy-goggles/issues"},"license":"MIT","readme":"# @el_saintt/adapter-nextjs\n\nNext.js adapter for Portfolio API - Supports both App Router (Next.js 13+) and Pages Router.\n\n## Installation\n\n```bash\nnpm install @el_saintt/adapter-nextjs @el_saintt/core next\n```\n\n## Quick Start\n\n### App Router (Next.js 13+)\n\nCreate a catch-all route handler in `app/api/portfolio/[[...slug]]/route.ts`:\n\n```typescript\nimport { PortfolioClient } from '@el_saintt/core';\nimport { githubPlugin } from '@el_saintt/plugin-github';\nimport { createPortfolioHandlers } from '@el_saintt/adapter-nextjs/app';\nimport { NextRequest } from 'next/server';\n\n// Initialize client\nconst client = new PortfolioClient({\n  cache: {\n    provider: 'memory',\n    defaultTTL: 3600,\n  },\n  services: {\n    github: {\n      enabled: true,\n      credentials: {\n        username: process.env.GITHUB_USERNAME!,\n      },\n    },\n  },\n});\n\n// Register plugins\nclient.use(githubPlugin);\n\n// Create handlers\nconst handlers = createPortfolioHandlers({\n  client,\n  enableCors: true,\n});\n\n// Export route handlers\nexport async function GET(\n  request: NextRequest,\n  context: { params: { slug?: string[] } }\n) {\n  const slug = context.params.slug || [];\n\n  // Route to appropriate handler\n  if (slug[0] === 'services') {\n    if (!slug[1]) {\n      return handlers.getServices(request);\n    } else if (slug[2] === 'health') {\n      return handlers.getServiceHealth(request, { params: { service: slug[1] } });\n    } else {\n      return handlers.getService(request, { params: { service: slug[1] } });\n    }\n  } else if (slug[0] === 'content') {\n    if (!slug[1]) {\n      return handlers.getAllContent(request);\n    } else {\n      return handlers.getServiceContent(request, { params: { service: slug[1] } });\n    }\n  } else if (slug[0] === 'health') {\n    return handlers.getHealth(request);\n  } else if (slug[0] === 'validate') {\n    return handlers.validateConfig(request);\n  }\n\n  return new Response(JSON.stringify({ error: 'Not found' }), {\n    status: 404,\n    headers: { 'Content-Type': 'application/json' },\n  });\n}\n\n// Handle OPTIONS for CORS\nexport async function OPTIONS(request: NextRequest) {\n  return new Response(null, {\n    status: 204,\n    headers: {\n      'Access-Control-Allow-Origin': '*',\n      'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',\n      'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n    },\n  });\n}\n```\n\n### Pages Router\n\nCreate a catch-all API route in `pages/api/portfolio/[[...slug]].ts`:\n\n```typescript\nimport { PortfolioClient } from '@el_saintt/core';\nimport { githubPlugin } from '@el_saintt/plugin-github';\nimport { createPortfolioApiRoute } from '@el_saintt/adapter-nextjs/pages';\n\n// Initialize client\nconst client = new PortfolioClient({\n  cache: {\n    provider: 'memory',\n    defaultTTL: 3600,\n  },\n  services: {\n    github: {\n      enabled: true,\n      credentials: {\n        username: process.env.GITHUB_USERNAME!,\n      },\n    },\n  },\n});\n\n// Register plugins\nclient.use(githubPlugin);\n\n// Create and export handler\nexport default createPortfolioApiRoute({\n  client,\n  enableCors: true,\n});\n```\n\n## API Endpoints\n\nBoth routers create the same REST API endpoints:\n\n### Services\n\n**GET /api/portfolio/services**\n- List all configured services\n- Response: `{ success: true, data: { services: [...] } }`\n\n**GET /api/portfolio/services/:service**\n- Get information about a specific service\n- Example: `/api/portfolio/services/github`\n\n**GET /api/portfolio/services/:service/health**\n- Check health of a specific service\n- Example: `/api/portfolio/services/github/health`\n\n### Content\n\n**GET /api/portfolio/content**\n- Get all content from all services\n- Query params: `limit`, `offset`, `since`, `until`, `skipCache`\n\n**GET /api/portfolio/content/:service**\n- Get content from a specific service\n- Example: `/api/portfolio/content/github?limit=5`\n\n### Health & Validation\n\n**GET /api/portfolio/health**\n- Check health of all services\n\n**GET /api/portfolio/validate**\n- Validate configuration\n\n## Advanced Usage\n\n### Enable CORS\n\n```typescript\n// App Router\nconst handlers = createPortfolioHandlers({\n  client,\n  enableCors: true,\n  corsOrigins: ['https://example.com'], // Or ['*'] for all origins\n});\n\n// Pages Router\nexport default createPortfolioApiRoute({\n  client,\n  enableCors: true,\n  corsOrigins: ['https://example.com'],\n});\n```\n\n### Server-Side Data Fetching\n\n#### App Router (Server Components)\n\n```typescript\nimport { PortfolioClient } from '@el_saintt/core';\nimport { githubPlugin } from '@el_saintt/plugin-github';\n\n// In a Server Component\nexport default async function Page() {\n  const client = new PortfolioClient({ /* config */ });\n  client.use(githubPlugin);\n\n  const content = await client.fetch('github', { limit: 5 });\n\n  return (\n    <div>\n      {content.map(item => (\n        <div key={item.id}>{item.title}</div>\n      ))}\n    </div>\n  );\n}\n```\n\n#### Pages Router (getServerSideProps)\n\n```typescript\nimport { GetServerSideProps } from 'next';\nimport { PortfolioClient } from '@el_saintt/core';\nimport { githubPlugin } from '@el_saintt/plugin-github';\n\nexport const getServerSideProps: GetServerSideProps = async () => {\n  const client = new PortfolioClient({ /* config */ });\n  client.use(githubPlugin);\n\n  const content = await client.fetch('github', { limit: 5 });\n\n  return {\n    props: {\n      content,\n    },\n  };\n};\n```\n\n#### Pages Router (getStaticProps)\n\n```typescript\nimport { GetStaticProps } from 'next';\nimport { PortfolioClient } from '@el_saintt/core';\nimport { githubPlugin } from '@el_saintt/plugin-github';\n\nexport const getStaticProps: GetStaticProps = async () => {\n  const client = new PortfolioClient({ /* config */ });\n  client.use(githubPlugin);\n\n  const content = await client.fetch('github', { limit: 5 });\n\n  return {\n    props: {\n      content,\n    },\n    revalidate: 3600, // ISR: revalidate every hour\n  };\n};\n```\n\n## Response Format\n\nAll responses follow a consistent format:\n\n### Success Response\n\n```json\n{\n  \"success\": true,\n  \"data\": { ... },\n  \"meta\": {\n    \"timestamp\": \"2024-10-10T12:00:00.000Z\",\n    \"count\": 10,\n    \"service\": \"github\"\n  }\n}\n```\n\n### Error Response\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"message\": \"Service not found\",\n    \"code\": \"SERVICE_NOT_FOUND\",\n    \"details\": { ... }\n  },\n  \"meta\": {\n    \"timestamp\": \"2024-10-10T12:00:00.000Z\"\n  }\n}\n```\n\n## TypeScript Support\n\nFull TypeScript support with proper types:\n\n```typescript\nimport {\n  PortfolioResponse,\n  PortfolioAPIOptions,\n  createPortfolioHandlers,\n} from '@el_saintt/adapter-nextjs';\n\n// All exports are fully typed\n```\n\n## Environment Variables\n\n```env\n# Example .env.local\nGITHUB_USERNAME=your-username\nGITHUB_TOKEN=ghp_your_token_here\n\nMEDIUM_USERNAME=@your-username\n\nYOUTUBE_API_KEY=AIza_your_api_key\nYOUTUBE_CHANNEL_ID=UC_your_channel_id\n```\n\n## Examples\n\n- [App Router Example](./examples/app-router)\n- [Pages Router Example](./examples/pages-router)\n- [Server Components Example](./examples/server-components)\n- [ISR Example](./examples/isr)\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-dce24079fe890f582cf97230445735a8"}