# simple-resource

> simple rest route map using es6 and express

Latest version **0.0.2** (published 2015-11-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install simple-resource
pnpm add simple-resource
yarn add simple-resource
bun add simple-resource
```

## 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.0.2 |
| Published | 2015-11-19 |
| First published | 2015-11-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | jdaviderb |
| Maintainers | jdaviderb |

## Links

- npm: https://www.npmjs.com/package/simple-resource
- npm.io page: https://npm.io/package/simple-resource

## Recent versions

- 0.0.2 (latest) — 2015-11-19

## README

# Simple resource

experimental ES6 Restful router for express 

# Installation

```sh
    npm install simple-resource --save
```

# usage 
```js
'use strict';
 let express = require('express');
 let app = express();
 let SimpleResource = require('./index');
 
 class NoticesController{

	constructor(){
		this.name = "jorge";
	}
	index(req,res){
		console.log(this);
		return res.send('MAP GET /notices')
	}

	show(req,res){
		return res.send('MAP GET /notices/:noticeId')	
	}

	create(req,res){
        return res.send('MAP POST /notices');
	}

	update(req,res){
		return res.send('MAP PUT /notices/:noticeId')
	}

	delete(req,res){
		return res.send('MAP DELETE /notices/:noticeId')
	}


  custom(req,res){
    return res.send('MAP GET /notices/:noticeId/custom')
  }
}

class TagsController{
	index(req,res){
		return res.send(' nested tag from notices resource -> /notices/:noticeId/tags');

	}
}

let customMiddleWare = function(req,res,next){
  console.log('custom middleware optional');
  next();
};



new SimpleResource(app,customMiddleWare)
	.resource({
		name: 'notices',
		url: '/notices/:noticeId',
		controller: new NoticesController,
		members: [
			{
				url: '/custom',
				method: 'get',
				action: 'custom'
			}
		]
	})
	.resource({
		name: 'notices.tags',
		url: '/tags/:tagId',
		controller: new TagsController
	})

app.listen(3000);
```

#  default actions
 * index(get all resources)
 * show(get resource)
 * update(update resource)
 * delete (delete resource)

# tested
```sh
 node -v
  v4.2.2
```

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