Skip to content

convenient wrapper for express router for easy REST API building and composing

License

Notifications You must be signed in to change notification settings

dvpnt/express-api-resource

Repository files navigation

@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)

About

convenient wrapper for express router for easy REST API building and composing

Resources

License

Stars

Watchers

Forks

Packages

No packages published