{"_id":"@ajayos/server","_rev":"6-59accbba49a6ad7b8e478ca30eaa139b","name":"@ajayos/server","dist-tags":{"latest":"3.0.0"},"versions":{"1.0.0":{"name":"@ajayos/server","version":"1.0.0","keywords":["Ajayos","ajay","server","express","nodejs"],"author":{"name":"Ajay o s"},"license":"Apache-2.0","_id":"@ajayos/server@1.0.0","maintainers":[{"name":"ajayos","email":"ajayosakhub@gmail.com"}],"homepage":"https://github.com/Ajayos/Server#readme","bugs":{"url":"https://github.com/Ajayos/Server/issues"},"dist":{"shasum":"bcc73d31201cecf5ac733299e81d00a38c8dd5cf","tarball":"https://registry.npmjs.org/@ajayos/server/-/server-1.0.0.tgz","fileCount":10,"integrity":"sha512-+u5T0g/GqXJkXGq8Uv6cJiilF5lnEyTe6n6qjnLvvvo4iGFm2MnqYDfdDTQmv6FcRkWIVXuUdo1C8YN127JX/w==","signatures":[{"sig":"MEUCIDu2qNPgxA4FrDXKYNvAa3u7nPUVIQQtNF1HODuma5bhAiEA05WjX/JczCsZVfa94PBYu4Bb62r7PP8zvi7h7Zu2YfQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":55431},"main":"index.js","gitHead":"6eeedfb9812860e129a371d153910352b2689d3c","scripts":{"test":"node example.js"},"_npmUser":{"name":"ajayos","email":"ajayosakhub@gmail.com"},"repository":{"url":"git+https://github.com/Ajayos/Server.git","type":"git"},"_npmVersion":"9.6.7","description":"hi","directories":{},"_nodeVersion":"18.17.0","dependencies":{"os":"^0.1.2","cors":"^2.8.5","http":"^0.0.1-security","axios":"^1.4.0","dotenv":"^16.3.1","express":"^4.18.2","body-parser":"^1.20.2","@ajayos/nodelog":"^1.0.2"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/server_1.0.0_1690729175115_0.43825387977065455","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@ajayos/server","version":"1.0.1","keywords":["Ajayos","ajay","server","express","nodejs","http"],"author":{"name":"Ajay o s"},"license":"Apache-2.0","_id":"@ajayos/server@1.0.1","maintainers":[{"name":"ajayos","email":"ajayosakhub@gmail.com"}],"homepage":"https://github.com/Ajayos/Server#readme","bugs":{"url":"https://github.com/Ajayos/Server/issues"},"dist":{"shasum":"a6b049b93f78ee4233e4bcacf018b2d5173688d1","tarball":"https://registry.npmjs.org/@ajayos/server/-/server-1.0.1.tgz","fileCount":10,"integrity":"sha512-5h7vJwLavzjzYc1pkHaOiUwt82Gn0SJMHCeHaS7JzOh53jcYIXbDPZzkbPbMZ4ogmcciqcMmIuhQMPkNQaNkGQ==","signatures":[{"sig":"MEUCIQCntb1BCjL/QnAfrzVHym+B1p9s8fSxBFY71YxiUuZMQgIgHcqYlcyTrJZ/YM0gYAX1lm66yRgBKGYZ0wjgtp+6LpQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":52704},"main":"index.js","gitHead":"5ce2b2a68f64382f23e10d8667f019d91ad3cb38","scripts":{"test":"node example.js"},"_npmUser":{"name":"ajayos","email":"ajayosakhub@gmail.com"},"repository":{"url":"git+https://github.com/Ajayos/Server.git","type":"git"},"_npmVersion":"9.6.7","description":"hi","directories":{},"_nodeVersion":"18.17.0","dependencies":{"os":"^0.1.2","cors":"^2.8.5","http":"^0.0.1-security","axios":"^1.4.0","dotenv":"^16.3.1","express":"^4.18.2","body-parser":"^1.20.2","@ajayos/nodelog":"^1.0.2"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/server_1.0.1_1690730498445_0.06200336010316332","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@ajayos/server","version":"1.0.2","keywords":["Ajayos","ajay","server","express","nodejs","http"],"author":{"name":"Ajay o s"},"license":"Apache-2.0","_id":"@ajayos/server@1.0.2","maintainers":[{"name":"ajayos","email":"ajayosakhub@gmail.com"}],"homepage":"https://github.com/Ajayos/Server#readme","bugs":{"url":"https://github.com/Ajayos/Server/issues"},"dist":{"shasum":"6802a62a986a7c9c502b47261fdb2070f88c217a","tarball":"https://registry.npmjs.org/@ajayos/server/-/server-1.0.2.tgz","fileCount":10,"integrity":"sha512-/pnzsKf09FF84qZNQjAjH4d4DaobGyt5YmDXlTBLRFbrWwIzeqw6ASGuMvQ+staJEi/i+5k2wj1hlgt1JCD0Bw==","signatures":[{"sig":"MEUCIG8xmgyntKcA/wTyNuj9ruSnGmIP4/XaVbfe3JiuJNZhAiEAw8yGDwxoBXVug4eBpM/JhQI5tqi0zbyuGi22RMY6mPc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":52828},"main":"index.js","gitHead":"71577144f6ca4b504fc1bf1be4e5f5361de57da2","scripts":{"test":"node example.js"},"_npmUser":{"name":"ajayos","email":"ajayosakhub@gmail.com"},"repository":{"url":"git+https://github.com/Ajayos/Server.git","type":"git"},"_npmVersion":"9.6.7","description":"A powerful and flexible HTTP server package built on top of Express, providing various server functionalities and utilities.","directories":{},"_nodeVersion":"18.17.0","dependencies":{"os":"^0.1.2","cors":"^2.8.5","http":"^0.0.1-security","axios":"^1.4.0","dotenv":"^16.3.1","express":"^4.18.2","body-parser":"^1.20.2","@ajayos/nodelog":"^1.0.2"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/server_1.0.2_1690732590621_0.12033170547390126","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"@ajayos/server","version":"2.0.0","keywords":["Ajayos","ajay","server","express","nodejs","http"],"author":{"name":"Ajay o s"},"license":"Apache-2.0","_id":"@ajayos/server@2.0.0","maintainers":[{"name":"ajayos","email":"ajayosakhub@gmail.com"}],"homepage":"https://github.com/Ajayos/Server#readme","bugs":{"url":"https://github.com/Ajayos/Server/issues"},"dist":{"shasum":"f4962c97f856dea97ce69b96eeaa59d3d8b57ef5","tarball":"https://registry.npmjs.org/@ajayos/server/-/server-2.0.0.tgz","fileCount":5,"integrity":"sha512-NB1FKj54zsinhcymwzuybCmKysNhhQBxEJzT76lyDy1w7Mj/R6xnikaXHdowCWUVK0NWGu3NWIqU2ca0IZXKtA==","signatures":[{"sig":"MEUCIQCppif5a1VbE2xi0hzNzG3yDJL+SIsyGawB1v/7OV4eWQIgPeONflV410kLkdB1sJch+rr+9zg8xkqer/XcgTJODV8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":162188},"main":"index.js","types":"index.d.ts","gitHead":"26ecf7242dd4f073e8f3c55d43b4c5ff6282fca6","scripts":{"test":"node example.js"},"_npmUser":{"name":"ajayos","email":"ajayosakhub@gmail.com"},"repository":{"url":"git+https://github.com/Ajayos/Server.git","type":"git"},"_npmVersion":"10.7.0","description":"A powerful and flexible HTTP server package built on top of Express, providing various server functionalities and utilities.","directories":{},"_nodeVersion":"18.20.4","dependencies":{"os":"^0.1.2","cors":"^2.8.5","http":"^0.0.1-security","axios":"^1.4.0","dotenv":"^16.3.1","express":"^4.18.2","body-parser":"^1.20.2","cookie-parser":"^1.4.7","@ajayos/nodelog":"^1.0.2"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/server_2.0.0_1728881908330_0.15901854046847586","host":"s3://npm-registry-packages"}},"2.0.1":{"name":"@ajayos/server","version":"2.0.1","keywords":["Ajayos","ajay","server","express","nodejs","http"],"author":{"name":"Ajay o s"},"license":"Apache-2.0","_id":"@ajayos/server@2.0.1","maintainers":[{"name":"ajayos","email":"ajayosakhub@gmail.com"}],"homepage":"https://github.com/Ajayos/Server#readme","bugs":{"url":"https://github.com/Ajayos/Server/issues"},"dist":{"shasum":"fd8f2bf388c0f686190d0d47328f39fb41e78351","tarball":"https://registry.npmjs.org/@ajayos/server/-/server-2.0.1.tgz","fileCount":5,"integrity":"sha512-l9kNaFhSq3UqnTrNUsQfBZqHwwl9DtLUXVwOyTDAyH+CHLwU4VamyIdcz24peJbGe94WOsaB+sl4ehLWRvwjPg==","signatures":[{"sig":"MEUCIQCVa+y9lkbaPCI+IHuHBIhRQ4yif02MdCbt04TC70oCeQIgOMuFRjwH3p9PLvYj52Vt0x0WFtPIN3pjPixBzo6mUuE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":162512},"main":"index.js","types":"index.d.ts","gitHead":"c9008ade426233b7fc566bbe305cce06dd7d2d74","scripts":{"test":"node example.js"},"_npmUser":{"name":"ajayos","email":"ajayosakhub@gmail.com"},"repository":{"url":"git+https://github.com/Ajayos/Server.git","type":"git"},"_npmVersion":"10.7.0","description":"A powerful and flexible HTTP server package built on top of Express, providing various server functionalities and utilities.","directories":{},"_nodeVersion":"18.20.4","dependencies":{"os":"^0.1.2","cors":"^2.8.5","http":"^0.0.1-security","axios":"^1.4.0","dotenv":"^16.3.1","helmet":"^8.0.0","express":"^4.18.2","body-parser":"^1.20.2","cookie-parser":"^1.4.7","@ajayos/nodelog":"^1.0.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-node":"^10.9.2","typedoc":"^0.26.9","typescript":"^5.5.4","@types/cors":"^2.8.17","@types/node":"^20.14.12","@types/express":"^4.17.21","@types/cookie-parser":"^1.4.7"},"_npmOperationalInternal":{"tmp":"tmp/server_2.0.1_1728883039465_0.8082808190988839","host":"s3://npm-registry-packages"}},"3.0.0":{"name":"@ajayos/server","version":"3.0.0","description":"A lightweight Express-based HTTP/HTTPS server wrapper with built-in middleware, lifecycle hooks, logging, and utility helpers.","license":"Apache-2.0","author":{"name":"Ajay O S"},"type":"module","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"dev":"tsx src/index.ts","build":"tsup","clean":"rm -rf dist","prepare":"npm run build","docs":"typedoc","test":"jest","test:watch":"jest --watch","test:ci":"jest --runInBand"},"engines":{"node":">=18"},"keywords":["ajayos","server","express","http-server","https-server","backend","api","middleware","cors","helmet","body-parser","cookie-parser","logging","nodejs","typescript","framework","web-server"],"homepage":"https://github.com/Ajayos/server#readme","bugs":{"url":"https://github.com/Ajayos/server/issues"},"repository":{"type":"git","url":"git+https://github.com/Ajayos/server.git"},"dependencies":{"axios":"^1.4.0","body-parser":"^1.20.2","compression":"^1.8.1","connect-timeout":"^1.9.1","cookie-parser":"^1.4.7","cors":"^2.8.5","dotenv":"^16.3.1","express":"^4.18.2","express-rate-limit":"^8.2.1","helmet":"^8.0.0","morgan":"^1.10.1","picocolors":"^1.1.1"},"devDependencies":{"@types/compression":"^1.8.1","@types/connect-timeout":"^1.9.0","@types/cookie-parser":"^1.4.7","@types/cors":"^2.8.17","@types/express":"^4.17.21","@types/jest":"^30.0.0","@types/morgan":"^1.9.10","@types/node":"^20.19.30","jest":"^29.7.0","ts-jest":"^29.4.6","ts-node":"^10.9.2","tsup":"^8.0.0","tsx":"^4.7.0","typedoc":"^0.26.9","typescript":"^5.5.4"},"gitHead":"f40c2719b1d14f536749941961aa18dccf3c0443","_id":"@ajayos/server@3.0.0","_nodeVersion":"22.19.0","_npmVersion":"11.7.0","dist":{"integrity":"sha512-HutUkVq9zuhhjH4bSvsCjnNFiUkx9JIV++a1nUE6VMrKJhHAyw1kpXTwJ5ynxTYep1fYafg/f0dHv/GzMVo+8Q==","shasum":"16cda9a6261b321a8e3dfa5698d13c21e0d7a3a7","tarball":"https://registry.npmjs.org/@ajayos/server/-/server-3.0.0.tgz","fileCount":7,"unpackedSize":65535,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCi/DVz9v5m0sFeqRcZEirB5GLWygmuyuVkfPmAld4JtQIgAOUIwhJjdxkHlHyZaJAvJLOpM3Czubr+brrFAIy5aFc="}]},"_npmUser":{"name":"ajayos","email":"ajayosakhub@gmail.com"},"directories":{},"maintainers":[{"name":"ajayos","email":"ajayosakhub@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/server_3.0.0_1769447233027_0.7030089841936942"},"_hasShrinkwrap":false}},"time":{"created":"2023-07-30T14:59:35.039Z","modified":"2026-01-26T17:07:13.302Z","1.0.0":"2023-07-30T14:59:35.323Z","1.0.1":"2023-07-30T15:21:38.621Z","1.0.2":"2023-07-30T15:56:30.746Z","2.0.0":"2024-10-14T04:58:28.545Z","2.0.1":"2024-10-14T05:17:19.758Z","3.0.0":"2026-01-26T17:07:13.182Z"},"bugs":{"url":"https://github.com/Ajayos/server/issues"},"author":{"name":"Ajay O S"},"license":"Apache-2.0","homepage":"https://github.com/Ajayos/server#readme","keywords":["ajayos","server","express","http-server","https-server","backend","api","middleware","cors","helmet","body-parser","cookie-parser","logging","nodejs","typescript","framework","web-server"],"repository":{"type":"git","url":"git+https://github.com/Ajayos/server.git"},"description":"A lightweight Express-based HTTP/HTTPS server wrapper with built-in middleware, lifecycle hooks, logging, and utility helpers.","maintainers":[{"name":"ajayos","email":"ajayosakhub@gmail.com"}],"readme":"# @ajayos/server\n\n> A flexible, plugin-driven Express server wrapper with first-class TypeScript support, built-in middleware, and optional HTTPS.\n\n[![npm version](https://img.shields.io/npm/v/@ajayos/server.svg)](https://www.npmjs.com/package/@ajayos/server)\n[![license](https://img.shields.io/npm/l/@ajayos/server.svg)](./LICENSE)\n\n---\n\n## ✨ Overview\n\n`@ajayos/server` is a **thin, powerful wrapper around Express** that helps you:\n\n- Start HTTP or HTTPS servers easily\n- Enable common middleware using **simple config flags**\n- Extend behavior using a **plugin system**\n- Use flexible constructors (`port`, `config`, callbacks)\n- Keep server bootstrap code clean and readable\n\nDesigned to be:\n\n- ✅ Simple by default\n- 🔌 Plugin-driven when needed\n- 🧠 TypeScript-first\n- 🚀 Production-ready\n\n---\n\n## 📦 Installation\n\n```bash\nnpm install @ajayos/server\n```\n\n---\n\n## 🚀 Quick Start\n\n```ts\nimport SERVER from \"@ajayos/server\";\n\nconst app = new SERVER(3000);\n\napp.get(\"/\", (_req, res) => {\n  res.send(\"Hello World\");\n});\n\napp.start();\n```\n\n---\n\n## 🔧 Flexible Constructors\n\nAll of the following are valid:\n\n```ts\nnew SERVER(3000);\nnew SERVER(3000, () => console.log(\"started\"));\nnew SERVER(3000, { cors: true });\n\nnew SERVER({ port: 3000 });\nnew SERVER({ port: 3000 }, () => console.log(\"started\"));\n```\n\n---\n\n## ⚙️ Server Configuration\n\n```ts\ninterface ServerConfig {\n  port?: number;\n\n  https?: {\n    key: string | Buffer;\n    cert: string | Buffer;\n  };\n\n  // Built-in middleware flags\n  cors?: boolean | object;\n  helmet?: boolean | object;\n  bodyParser?: boolean | object;\n  compression?: boolean | object;\n  morgan?: boolean | string;\n  rateLimit?: boolean | object;\n  timeout?: boolean | object;\n  static?: string;\n\n  // Plugins\n  plugins?: ServerPlugin[];\n\n  // Lifecycle hooks\n  onServerStart?: () => void;\n  onServerError?: (error: any) => void;\n}\n```\n\n---\n\n## 🔐 HTTPS Support\n\n```ts\nimport fs from \"fs\";\nimport SERVER from \"@ajayos/server\";\n\nnew SERVER({\n  port: 8443,\n  https: {\n    key: fs.readFileSync(\"./key.pem\"),\n    cert: fs.readFileSync(\"./cert.pem\"),\n  },\n}).start();\n```\n\n---\n\n## 🔌 Plugins System (3 Ways)\n\nYou can add plugins **in three different ways**.\n\n---\n\n### ✅ 1️⃣ Via Config Flags (Simplest)\n\n```ts\nnew SERVER({\n  port: 3000,\n  cors: true,\n  helmet: true,\n  bodyParser: true,\n  compression: true,\n  morgan: \"dev\",\n  static: \"public\",\n}).start();\n```\n\n> Built-in flags are internally converted into plugins automatically.\n\n---\n\n### ✅ 2️⃣ Via `config.plugins[]`\n\n```ts\nimport { cors, bodyParser, static as serveStatic } from \"@ajayos/server\";\n\nnew SERVER({\n  port: 3000,\n  plugins: [cors({ origin: \"*\" }), bodyParser(), serveStatic(\"public\")],\n}).start();\n```\n\n---\n\n### ✅ 3️⃣ Via `usePlugin()` (Manual)\n\n```ts\nimport { cors } from \"@ajayos/server\";\n\nconst app = new SERVER(3000);\n\napp.usePlugin(cors({ origin: \"*\" }));\n\napp.start();\n```\n\n---\n\n## 📦 Built-in Plugins List\n\nAvailable out of the box:\n\n| Plugin          | Description                     |\n| --------------- | ------------------------------- |\n| `cors()`        | Cross-Origin Resource Sharing   |\n| `helmet()`      | Security headers                |\n| `bodyParser()`  | JSON + URL-encoded body parsing |\n| `compression()` | Gzip / Brotli compression       |\n| `morgan()`      | HTTP request logging            |\n| `rateLimit()`   | Request rate limiting           |\n| `timeout()`     | Request timeout handling        |\n| `static()`      | Static file serving             |\n| `jsonError()`   | JSON parse error handling       |\n\nAll plugins are available from:\n\n```ts\nimport { cors, helmet, bodyParser } from \"@ajayos/server\";\n```\n\n---\n\n## 🧩 Plugin Usage Examples\n\n### CORS\n\n```ts\nimport { cors } from \"@ajayos/server\";\n\ncors({ origin: \"https://example.com\" });\n```\n\nor via config:\n\n```ts\nnew SERVER({\n  cors: { origin: \"*\" },\n});\n```\n\n---\n\n### Body Parser\n\n```ts\nbodyParser({ limit: \"10mb\" });\n```\n\n---\n\n### Static Files\n\n```ts\nimport { static as serveStatic } from \"@ajayos/server\";\n\nserveStatic(\"public\");\n```\n\n---\n\n### Rate Limiting\n\n```ts\nrateLimit({\n  windowMs: 60_000,\n  max: 100,\n});\n```\n\n---\n\n### JSON Parse Error Handling\n\n```ts\njsonError({ error: \"Invalid JSON body\" });\n```\n\nor with callback:\n\n```ts\njsonError((err, req, res) => {\n  res.status(400).json({\n    message: err.message,\n    path: req.path,\n  });\n});\n```\n\n> Only JSON parse errors are handled. Other errors pass through.\n\n---\n\n## 🧠 Express-Compatible Routing API\n\n```ts\napp.use(middleware);\n\napp.get(\"/users\", handler);\napp.post(\"/users\", handler);\napp.put(\"/users/:id\", handler);\napp.delete(\"/users/:id\", handler);\napp.patch(\"/users/:id\", handler);\napp.all(\"/health\", handler);\n```\n\n---\n\n## 🔔 Events & Lifecycle APIs\n\n### Server Events\n\n```ts\napp.on(\"error\", (err) => {});\napp.once(\"close\", () => {});\napp.off(\"error\", handler);\n```\n\n### Express App Events\n\n```ts\napp.onApp(\"mount\", () => {});\napp.onceApp(\"mount\", () => {});\napp.offApp(\"mount\", handler);\n```\n\n---\n\n## 🌐 Network Utilities\n\n```ts\nconst interfaces = app.getActiveNetworkInterfaces();\n```\n\nReturns active IPv4 addresses (excluding localhost).\n\n---\n\n## 🛑 Graceful Shutdown\n\n```ts\napp.close();\n```\n\n---\n\n## 🧪 TypeScript Support\n\n- Written in TypeScript\n- Ships `.d.ts` files\n- Fully typed plugin system\n- Works with ESM and CommonJS\n\n---\n\n## 📄 License\n\nApache-2.0 License — free to use, modify, and distribute.\n","readmeFilename":"README.md"}