@dvpnt/express-api-resource

1.0.0 • Public • Published

@dvpnt/express-api-resource

Build Status Coverage Status NPM Version

Convenient wrapper for express router for easy REST API building and composing.

Installation

$ npm install @dvpnt/express-api-resource

Usage

const express = require('express');
const ApiResource = require('@dvpnt/express-api-resource');

const resource = new ApiResource({
	root: 'entities',
	versions: ['1.0'],
	idAttributeName: 'id'
});

resource.getOne('1.0', (req, res) => {
	res.json({id: 1, name: 'foo'});
});

resource.get('1.0', (req, res) => {
	res.json([
		{id: 1, name: 'foo'},
		{id: 2, name: 'foo'}
	]);
});

const app = express();

app.use('/api', resource);

License

The MIT License (MIT)

Readme

Keywords

none

Package Sidebar

Install

npm i @dvpnt/express-api-resource

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

6.44 kB

Total Files

4

Last publish

Collaborators

  • fleg
  • dvpnt