# @microservice-framework/microservice

> Microservice framework worker class.

Latest version **2.0.6** (published 2026-11-19) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install @microservice-framework/microservice
pnpm add @microservice-framework/microservice
yarn add @microservice-framework/microservice
bun add @microservice-framework/microservice
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 2.0.6 |
| Published | 2026-11-19 |
| First published | 2017-04-15 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 51.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Gormartsen |
| Maintainers | microservice-framework |

## Links

- npm: https://www.npmjs.com/package/@microservice-framework/microservice
- Repository: https://github.com/microservice-framework/microservice
- Homepage: https://github.com/microservice-framework/microservice#readme
- Issues: https://github.com/microservice-framework/microservice/issues
- npm.io page: https://npm.io/package/@microservice-framework/microservice

## Dependencies (4)

- [debug](https://npm.io/package/debug.md) ^2.2.0
- [mongodb](https://npm.io/package/mongodb.md) ^2.2.1
- [jsonschema](https://npm.io/package/jsonschema.md) 1.4.x
- [@microservice-framework/microservice-client](https://npm.io/package/@microservice-framework/microservice-client.md) ^1.3.0

## Recent versions

- 2.0.6 (latest) — 2026-11-19
- 1.3.12 — 2025-05-21
- 1.3.11 — 2025-05-21
- 1.3.10 — 2025-05-21
- 1.3.9 — 2025-03-25
- 2.0.5 — 2025-03-20
- 3.0.6 — 2025-03-03
- 3.0.5 — 2025-03-03
- 3.0.4 — 2025-03-02
- 3.0.3 — 2025-02-27
- 3.0.2 — 2025-02-25
- 3.0.1 — 2025-02-25
- 3.0.0 — 2025-02-24
- 2.0.4 — 2025-02-18
- 2.0.3 — 2025-02-16
- … 26 more at https://npm.io/package/@microservice-framework/microservice/versions

## README

# microservice

[![Gitter](https://img.shields.io/gitter/room/microservice-framework/chat.svg?style=flat-square)](https://gitter.im/microservice-framework/chat)
[![npm](https://img.shields.io/npm/dt/@microservice-framework/microservice.svg?style=flat-square)](https://www.npmjs.com/~microservice-framework)
[![microservice-frame.work](https://img.shields.io/badge/online%20docs-200-green.svg?style=flat-square)](http://microservice-frame.work)

Microservice framework worker class.

Simple example:

```js
'use strict';

const Cluster = require('@microservice-framework/microservice-cluster');
const Microservice = require('@microservice-framework/microservice');

require('dotenv').config();

var mservice = new Microservice({
  mongoUrl: process.env.MONGO_URL + process.env.MONGO_PREFIX + process.env.MONGO_OPTIONS,
  mongoTable: process.env.MONGO_TABLE,
  secureKey: process.env.SECURE_KEY,
  schema: process.env.SCHEMA
});

var mControlCluster = new Cluster({
  pid: process.env.PIDFILE,
  port: process.env.PORT,
  hostname: process.env.HOSTNAME,
  count: process.env.WORKERS,
  callbacks: {
    validate: mservice.validate,
    POST: mservice.post,
    GET: mservice.get,
    PUT: mservice.put,
    DELETE: mservice.delete,
    SEARCH: mservice.search
  }
});

```

For more details please check our [website](http://microservice-frame.work)

### Changelog

- `1.3.0` - open mongo connection on class init, instead of each request.
- `1.3.1` - bug fix.
- `1.3.2` - implements events error and ready.
- `1.3.3-5` - Implementing new access token validation mechanism
- `1.3.6` - fix Access-token check. 
- `1.3.7` - Add ObjectID like field defenition.
- `1.3.8` - Fix removing _id from output when _id specified as field.

- `2.0.0` - Fix search by id when it is array.
          - support header execution-limit to limit execution time
          - support header force-index to force index search
          - support for env MAX_TIME_MS to set max exection time for search
          - support noCount request params to avoid countin total-count on search
          - properly close mongo connection on SIGINT (mfw stop serviceName)

---
_Source: https://npm.io/package/@microservice-framework/microservice · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
