{"id":24869408,"url":"https://github.com/deepal/tscore","last_synced_at":"2026-02-19T16:31:41.956Z","repository":{"id":41799215,"uuid":"166093017","full_name":"deepal/tscore","owner":"deepal","description":"TypeScript based Application bootstrapper and dependency injection container for NodeJS REST APIs","archived":false,"fork":false,"pushed_at":"2022-12-30T17:15:04.000Z","size":895,"stargazers_count":3,"open_issues_count":17,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-04T14:16:39.204Z","etag":null,"topics":["application-bootstrapper","dependency-injection","express","nodejs","typescript"],"latest_commit_sha":null,"homepage":"http://tscore.deepal.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deepal.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-16T18:51:12.000Z","updated_at":"2019-05-20T20:16:50.000Z","dependencies_parsed_at":"2023-01-31T12:15:24.461Z","dependency_job_id":null,"html_url":"https://github.com/deepal/tscore","commit_stats":null,"previous_names":["dpjayasekara/tscore"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Ftscore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Ftscore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Ftscore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Ftscore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepal","download_url":"https://codeload.github.com/deepal/tscore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236612797,"owners_count":19177154,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["application-bootstrapper","dependency-injection","express","nodejs","typescript"],"created_at":"2025-02-01T03:23:00.569Z","updated_at":"2025-10-15T13:31:42.165Z","avatar_url":"https://github.com/deepal.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TSCore\n\nhttp://tscore.deepal.io/\n\n![](https://img.shields.io/npm/v/@dpjayasekara/tscore.svg?colorB=brightgreen\u0026style=flat-square)\n![](https://img.shields.io/david/dpjayasekara/tscore.svg?style=flat-square)\n![](https://img.shields.io/travis/dpjayasekara/tscore/master.svg?style=flat-square)\n[![The MIT License](https://img.shields.io/badge/license-MIT-orange.svg?style=flat-square)](http://opensource.org/licenses/MIT) \n\n![](https://github.com/dpjayasekara/tscore/raw/master/docs/tscore.png)\n\nTSCore is a dependency injection container to develop REST APIs with NodeJS. In comes with a built-in http server powered by Express.js. TSCore is completely written in TypeScript, and comes all the type definitions built in.\n\n### Why do you need it?\n\nTSCore is not the silver bullet, but it helps you bootstrap your REST API in a matter of minutes. It comes with a built-in Express sever including, \n- JSON Body parser using `body-parser`\n- Basic auth header parser\n- Secure HTTP Headers configuration using `helmet`\n- A dependency injection container\n- Built-in `bunyan` logger\n\n**More customizations are coming!!!**\n\n### Installation\n\n```sh\nnpm i @dpjayasekara/tscore\n```\n\n## Usage\n\nFor a sample application, please checkout : https://github.com/dpjayasekara/tscore-sample-app\n\nWrite your code as individual modules with the following signature\n\n### Module\n\nThe following is an example for a tscore module.\n\n```js\nimport { Constants } from '@dpjayasekara/tscore';\n\nexport default class YourModule {\n    private container;\n    private logger;\n    private config;\n\n    constructor({container, logger, config}) {\n        // access the container instance\n        this.container = container;\n\n        // access the logger instance\n        this.logger = logger;\n\n        // access the configuration object for this module\n        this.config = config;\n\n        // triggers yourFunction() when all the modules are loaded\n        this.container.on(Constants.EVENT.APPLICATION_START, this.yourFunction.bind(this));\n    }\n\n    public yourFunction() {\n        // do your thing\n    }\n}\n\n```\n\n### Launcher\n\nYou can use `Launcher` to to bootstrap your application.\n\n```js\nimport {Launcher, ConfigLoader} from '@dpjayasekara/tscore'\n\nconst launcher = new Launcher();\n\nlauncher\n    .onBaseDir(__dirname)                           // optional function call. defaults to process.cwd()\n    .withConfig(ConfigLoader.jsConfigLoader({    // optional if config loading is required\n        filePath: './config.json'\n    }))\n    .withLoggerConfig({                             // optional if no explicit minimum log level or log file is not configured\n        name: 'myapp',\n        level: 'debug'\n    })\n    .module({ name: 'a', path: './moduleA.ts'})\n    .module({ name: 'b', path: './moduleB.ts'})\n    .module({ name: 'server', path: './main.ts'})\n    .start();\n\n```\n\nWhat is happening here:\n\n- ModuleA is a typescript/javascript module which will be injected to the container with name `a`. This module can be accessed by any other injected module as follows assuming the module follows the aforementioned tscore module structure.\n\n```\nconst moduleA = this.container.module('a');\n```\n\n- ModuleB is a typescript/javascript module which will be injected to the container with name `b`\n- Server is the main module of our application. We need to start the server, only if all the other modules are loaded. This can be done by listening on the `APPLICATION_START` event emitted from the container. The following is the structure of your main module:\n\n```js\nimport { Container, Constants } from '@dpjayasekara/tscore';\n\nexport default class Main {\n    private container;\n    private logger;\n    private config;\n    private serviceA;\n    private serviceB;\n\n    constructor({container, logger, config}) {\n        this.container = container;\n        this.logger = logger;\n        this.config = config;\n        this.startServer = this.startServer.bind(this)\n        this.requestLogger = this.requestLogger.bind(this)\n\n        this.serviceA = this.container.module('a');\n        this.serviceB = this.container.module('b');\n\n        this.container.on(Constants.EVENT.APPLICATION_START, this.startServer);\n    }\n\n    private startServer() {\n        // start the server\n    }\n}\n\n```\n\nIn the above example, `startServer()` will be called once all the modules are loaded, and that is the exact place you need to fire up your server.\n\n### API\n\nhttp://tscore.deepal.io\n\n### Roadmap\n\n- [x] Launcher:Async configuration loading support\n- [ ] Server:Customizing server headers\n- [ ] Server:Request signing module\n- [ ] Launcher:Custom logger support\n- [ ] Server:Configurable health check endpoint\n- [ ] Launcher:TSCore Submodules","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepal%2Ftscore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepal%2Ftscore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepal%2Ftscore/lists"}