# @chriscalo/start-server

> Simple utility for starting an express server with automatic port selection.

Latest version **0.1.3** (published 2019-09-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @chriscalo/start-server
pnpm add @chriscalo/start-server
yarn add @chriscalo/start-server
bun add @chriscalo/start-server
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2019-09-11 |
| First published | 2019-08-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 249.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Chris Calo |
| Maintainers | chriscalo |

## Links

- npm: https://www.npmjs.com/package/@chriscalo/start-server
- npm.io page: https://npm.io/package/@chriscalo/start-server

## Dependencies (1)

- [portfinder](https://npm.io/package/portfinder.md) ^1.0.23

## Recent versions

- 0.1.3 (latest) — 2019-09-11
- 0.1.1 — 2019-09-02
- 0.1.0 — 2019-09-01
- 0.0.1 — 2019-08-31

## README

# @chriscalo/start-server

# DEPRECATED. See [express-start](https://www.npmjs.com/package/express-start)

Simple utility for starting an [express][express.js] server with
automatic port selection.

Installation:

``` sh
npm install @chriscalo/start-server
# or
yarn add @chriscalo/start-server
```

Usage:

``` js
const express = require("express");
const { start } = require("@chriscalo/start-server");

const server = express();

server.get("/", (req, res) => {
  res.send("Hello, world!");
});

start(server);
// or
start(server, 3000);
```

The logic for selecting a port is as follows:

1. if `process.env.PORT` is defined, it tries that port and fails if it's not
   available
2. the `port` parameter in `start(server, port)` defaults to `8000` when a falsy
   value or no value is provided
3. it first tries to listen on `port`, incrementing it until one is found that
   is available (`8001`, `8002`, `8003`, etc)

Example output:

``` text
App listening on port 8000
Press Ctrl+C to quit.
```

[express.js]: https://expressjs.com

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