{"_id":"@aliksend/module","name":"@aliksend/module","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@aliksend/module","version":"1.0.0","description":"Declare modules in your services","keywords":["modules"],"repository":{"type":"git","url":"git+https://github.com/aliksend/node-packages.git"},"license":"MIT","author":{"name":"Alik Send"},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"prepublishOnly":"npm run build","test":"node --require ts-node/register --test ./src/*.test.ts","build":"rm -rf dist && tsc","lint":"npx @aliksend/linter --fix"},"dependencies":{"@aliksend/utils":"^1.0.0","zod":"^3.22.4"},"devDependencies":{"@types/stack-trace":"^0.0.33","ts-node":"^10.9.2","typescript":"^5.3.3"},"publishConfig":{"access":"public"},"_id":"@aliksend/module@1.0.0","bugs":{"url":"https://github.com/aliksend/node-packages/issues"},"homepage":"https://github.com/aliksend/node-packages#readme","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-bzWCXPLphXrAAiKupFKFWl4ijSTyi7CNStUj/Z6zL5tquTvuwbTLXup9Ac6gR7knGThgYxFiUrTqxnicV/K8tw==","shasum":"22be066324eb78a90ce9bfb2d192f6c492b19d2a","tarball":"https://registry.npmjs.org/@aliksend/module/-/module-1.0.0.tgz","fileCount":19,"unpackedSize":36323,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIB5rmaMr0BJIHuKS70bUrpK4HtTEGcKpxCd0UHj+melDAiBOEe5BZoPL6+IAaVQEhCnzDa5XHD02IGlScZtJcFreIA=="}]},"_npmUser":{"name":"aliksend","email":"aliknoname@gmail.com"},"directories":{},"maintainers":[{"name":"aliksend","email":"aliknoname@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/module_1.0.0_1707737531210_0.9242067707861046"},"_hasShrinkwrap":false}},"time":{"created":"2024-02-12T11:32:11.123Z","1.0.0":"2024-02-12T11:32:11.350Z","modified":"2024-02-12T11:32:11.608Z"},"maintainers":[{"name":"aliksend","email":"aliknoname@gmail.com"}],"description":"Declare modules in your services","homepage":"https://github.com/aliksend/node-packages#readme","keywords":["modules"],"repository":{"type":"git","url":"git+https://github.com/aliksend/node-packages.git"},"author":{"name":"Alik Send"},"bugs":{"url":"https://github.com/aliksend/node-packages/issues"},"license":"MIT","readme":"# modules-for-services\n\nUsed to declare modules in your services\n\nUsage example:\n```typescript\n// db/knex.ts\nconst m = Module.declare('knex', 'input', {\n  configSchema: z.object({}).passthrough(),\n  startArg: null,\n  start: async (config, startArg) => {\n    return knex(config)\n  },\n  stop: async (db) => {\n    await db.destroy()\n  },\n})\n\n// now you can use `m`, even while module isn't started\n// you can use `m.value` in http-handlers that will be called after module is started\n\n// then you can call `startAll` with config to start all modules, declared in your service\nawait Module.startAll({\n  db: {\n    client: 'pg',\n    connection: 'TODO'\n  }\n})\n```\n","readmeFilename":"README.md"}