https://github.com/axtgr/discope
https://github.com/axtgr/discope
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/axtgr/discope
- Owner: axtgr
- License: isc
- Created: 2022-06-26T13:20:38.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-12-01T13:02:17.000Z (over 3 years ago)
- Last Synced: 2025-02-19T13:40:02.047Z (over 1 year ago)
- Language: TypeScript
- Size: 1.09 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
🕺 Discope
## Quickstart
```
npm install discope
```
```js
import { scope, singleton, factory } from 'discope'
import pino from 'pino'
import { createConfig } from './config.js'
import App from './App.js'
const servicesScope = scope((deps) => {
const logger = factory(({ name }) => {
return pino({ name, level: deps.config.logLevel })
})
return { logger }
})
const appScope = scope(() => {
const config = singleton(() => createConfig())
const { logger } = servicesScope({ config })
const app = singleton(() => new App({ config: config(), logger: logger('App') }))
return { app }
})
const app = appScope()()
app.start()
```