# comprest

> A productivity framework for Node.js REST applications

Latest version **0.2.0** (published 2015-09-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install comprest
pnpm add comprest
yarn add comprest
bun add comprest
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2015-09-14 |
| First published | 2015-09-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | andrewmnelson |
| Maintainers | andrewmnelson |
| Keywords | server, framework |

## Links

- npm: https://www.npmjs.com/package/comprest
- Repository: https://github.com/andrewmnelson/0913_framework
- Homepage: https://github.com/andrewmnelson/0913_framework#readme
- Issues: https://github.com/andrewmnelson/0913_framework/issues
- npm.io page: https://npm.io/package/comprest

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@atlaskit/theme](https://npm.io/package/@atlaskit/theme.md) — 402.0K weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2015-09-14
- 0.1.0 — 2015-09-14

## README

## CompREST
===


A productivity framework for Node.js REST applications.  Student work for class - you've been warned.

<img src=https://travis-ci.org/andrewmnelson/0913_framework.svg>

####Example
~~~javascript
var http = require('http');
var compRest = require('comprest');

var serverFunction = function(req, resp) {
  if ('/' === req.url) {
    compRest(resp).text('A sample server');
  }
  else if ('/json' === req.url) {
    var obj = { a: 'one', b: 'two' };
    compRest(resp).json(obj);
  }
  else if ('/download' === req.url) {
    var readFile = fs.createReadStream('./filename.png');
    compRest(resp).pipe(readFile);
  }
};

var server = http.createServer(serverFunction);
server.listen(3000);
~~~

####Functions

- __text(str, [status])__
  Expands to the following code:

      resp.writeHead((status? status : 200),
            {'Content-Type': 'text/plain'} );
      resp.write(str);
      resp.end();
  If status is not supplied, defaults to 200

- __json(obj, [status])__
  Expands to the following code:

      resp.writeHead((status? status : 200),
            {'Content-Type': 'application/json'} );
      resp.write(JSON.stringify(obj));
      resp.end();
  If status is not supplied, defaults to 200

- __pipe(stream, [status])__
  Expands to the following code:

      resp.writeHead((status? status : 200),
            {'Content-Type': 'text/plain'} );
      stream.pipe(resp);
  If status is not supplied, defaults to 200

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