Note: The public API is under development and may change.
A TypeScript-first, opinionated ecosystem of modules and adapters for building production-ready backend services. Cortec provides standardized dependency injection, lifecycle management, and integrations for databases, queues, logging, and more.
Cortec helps you build backend services with minimal boilerplate by providing a set of modules for common tasks (HTTP, databases, queues, logging, etc.) and a unified way to load, configure, and manage them.
Core Principles:
- TypeScript native
- Dependency injection
- Production-ready defaults
- Extensible and modular
Install the core modules:
npm i @cortec/core @cortec/polka @cortec/serverCreate a minimal server:
import Cortec from '@cortec/core';
import Polka from '@cortec/polka';
import Server from '@cortec/server';
const cortec = new Cortec({ name: 'my-app', version: '1.0.0' });
const polka = new Polka((app) =>
app.get('/', (req, res) => res.end('Hello World'))
);
const server = new Server(polka.name);
cortec.use(polka);
cortec.use(server);
await cortec.load();Add configuration in config/default.yml:
server:
http:
port: 8080
polka:
bodyParser:
json:
limit: '100kb'Cortec provides a suite of modules for common backend tasks. Click each for details:
| Module | Description | Link |
|---|---|---|
| Core | Dependency injection & lifecycle management | @cortec/core |
| Config | Typed config loader | @cortec/config |
| Polka | HTTP server & routing | @cortec/polka |
| Server | HTTP server abstraction | @cortec/server |
| Redis | Redis integration | @cortec/redis |
| MongoDB | MongoDB integration | @cortec/mongodb |
| Postgres | PostgreSQL integration | @cortec/postgres |
| BullMQ | Job queues with BullMQ | @cortec/bullmq |
| RabbitMQ | Message queues with RabbitMQ | @cortec/rabbitmq |
| Logger | Structured logging | @cortec/logger |
| Sentry | Error tracking | @cortec/sentry |
| NewRelic | Performance monitoring | @cortec/newrelic |
| Axios | HTTP client wrapper | @cortec/axios |
| Cassandra | Cassandra DB integration | @cortec/cassandra |
| Elastic | Elasticsearch integration | @cortec/elastic |
| Opensearch | OpenSearch integration | @cortec/opensearch |
| Storage | File storage abstraction | @cortec/storage |
| Dynamic Config | Runtime config from DB | @cortec/dynamic-config |
| Temporal | Temporal workflow integration | @cortec/temporal |
| Types | Shared type definitions | @cortec/types |
See each module’s README for configuration and usage examples.
To create your own module, implement the IModule interface:
import { IModule } from '@cortec/core';
class MyModule implements IModule {
name = 'my-module';
async load() {
/* ... */
}
async dispose() {
/* ... */
}
}Register with Cortec:
cortec.use(new MyModule());
await cortec.load();Contributions are welcome! Please open issues or pull requests.
MIT