Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gallolabs/application

A nodejs light framework to frame your work
https://github.com/gallolabs/application

Last synced: 29 days ago
JSON representation

A nodejs light framework to frame your work

Awesome Lists containing this project

README

        



Gallo App

A nodejs light framework to frame your work

Application runner:

- Easy Dependencies injection
- Kill signal catched and converted to abortSignal
- Structured
- Built-in config (load from files, envs, validation, watches, etc) and logger

[ ] Refactorize aborts, with aborts to interrupt, aborts to stop/clean, etc

```typescript
import { runApp } from '@gallofeliz/application'

// ...

runApp({
name: '@gallofeliz/Pikatchu',
config: {
watchChanges: true,
userProvidedConfigSchema: tsToJsSchema()
},
services: {
userService({logger, db}): UserService {
return new UserService(logger, db)
},
db({config, configWatcher}): Db {
const db = new Db(config.dbPath)

configWatcher.on('change:dbPath', ({value}) => db.setPath(value as string))

return db
}
},
async run({userService, logger, abortSignal, abortController}) {
userService.doAJob()
let st: NodeJS.Timeout

abortSignal.addEventListener('abort', () => {
clearTimeout(st)
console.log('clean')
userService.clean()
resolve(undefined)
})

await new Promise(resolve => st = setTimeout(resolve, 5000))

abortController.abort()
}
})
```