# @eth-optimism/service-base

> ## What is this?

Latest version **1.1.5** (published 2021-03-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @eth-optimism/service-base
pnpm add @eth-optimism/service-base
yarn add @eth-optimism/service-base
bun add @eth-optimism/service-base
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2021-03-09 |
| First published | 2021-02-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 16.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | karlfloersch, ben-chain, will_optimism, k-ho, tynes, kelvinfichter |

## Links

- npm: https://www.npmjs.com/package/@eth-optimism/service-base
- npm.io page: https://npm.io/package/@eth-optimism/service-base

## Dependencies (2)

- [colors](https://npm.io/package/colors.md) ^1.4.0
- [@eth-optimism/core-utils](https://npm.io/package/@eth-optimism/core-utils.md) 0.1.9

## Recent versions

- 1.1.5 (latest) — 2021-03-09
- 1.1.3 — 2021-03-02
- 1.1.1 — 2021-02-13
- 1.1.0 — 2021-02-13
- 0.0.1 — 2021-02-01

## README

# @eth-optimism/service-base

## What is this?

`@eth-optimism/service-base` is a package that exposes a `BaseService` JavaScript class that can be used to implement various stateful JavaScript services.
Nice!

If you aren't working on the back-end side of Optimism, you probably don't need to use this package.
Otherwise, keep reading!

## Installation

### Via `npm`

```
npm install @eth-optimism/service-base --save
```

### Via `yarn`

```
yarn add @eth-optimism/service-base --save
```

## Usage

```typescript
import { BaseService } from '@eth-optimism/service-base'

interface MyServiceOptions {
    // Options to be passed into the service
}

class MyService extends BaseService<MyServiceOptions> {
    protected name = 'My Service'
    protected defaultOptions = {
        // Fill these out if you want defaults for anything
    }

    protected async _init() {
        // Do initialization logic here, will be called before anything else is run.
    }

    protected async _start() {
        // Do stuff here. Gets called inside of `service.start()`.
    }

    protected async _stop() {
        // Shut down things here. Gets called inside of `service.stop()`.
    }
}

const main = async () => {
    const service = MyService({
        // Options go here, if any.
    })

    await service.start()
}

main()
```

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