# restified

> REST routes constructor for express and koa

Latest version **0.0.1-dev.0** (published 2017-01-31) · MIT license · 0 weekly downloads

## Install

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

## 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.1-dev.0 |
| Published | 2017-01-31 |
| First published | 2017-01-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 25 |
| Author | Sergey Sova |
| Maintainers | lestad |

## Links

- npm: https://www.npmjs.com/package/restified
- Repository: https://github.com/atomixinteractions/restified
- Homepage: https://github.com/atomixinteractions/restified#readme
- Issues: https://github.com/atomixinteractions/restified/issues
- npm.io page: https://npm.io/package/restified

## Recent versions

- 0.0.1-dev.0 (latest) — 2017-01-31

## README

# Restified

Declare your routes


## Warning!

> That middleware now in development! Do not use it in production (only before v1 release)


## Usage example

```js
import Restified from 'restified'

import {
  BooksController,
  SectionsController,
  DemosController,
  LikeController,
  ProfileController,
  BookmarksController,
} from './controllers'

const router = Restified()


router.root(r => {
  r.resources('book', {}, BooksController)
  // get /books             -> BooksController.#index
  // post /books            -> BooksController.#create
  // get /books/:bookId     -> BooksController.#read
  // put /books/:bookId     -> BooksController.#update
  // patch /books/:bookId   -> BooksController.#update
  // delete /books/:bookId  -> BooksController.#destroy

  r.resources('section', { only: ['index', 'read'] }, SectionsController)
  // get /sections              -> SectionsController.#index
  // get /sections/:sectionId   -> SectionsController.#read

  r.resources('demo', {}, DemosController, r => {
    r.member.post('close')
    r.member.post('open', { methodName: 'reopen' })

    r.resource('like', LikeController)
  })
  // get /demos             -> DemosController.#index
  // post /demos            -> DemosController.#create
  // get /demos/:demoId     -> DemosController.#read
  // put /demos/:demoId     -> DemosController.#update
  // patch /demos/:demoId   -> DemosController.#update
  // delete /demos/:demoId  -> DemosController.#destroy
  // post /demos/:demoId/close    -> DemosController.#close
  // post /demos/:demoId/open     -> DemosController.#reopen
  // get /demos/like      -> LikeController.#read
  // post /demos/like     -> LikeController.#create
  // put /demos/like      -> LikeController.#update
  // delete /demos/like   -> LikeController.#destroy

  r.resource('profile', {}, ProfileController, r => {
    r.resources('bookmark', { memberId: 'id' }, BookmarksController, r => {
      r.member({}, r => {
        r.resource('share_link', BookmarksController.ShareLinkController)
      })
    })
  })
  // get /profile                -> ProfileController.#read
  // post /profile               -> ProfileController.#create
  // put /profile                -> ProfileController.#update
  // delete /profile             -> ProfileController.#destroy
  // get /profile/bookmarks             -> BookmarksController.#index
  // post /profile/bookmarks            -> BookmarksController.#create
  // get /profile/bookmarks/:id         -> BookmarksController.#read
  // put /profile/bookmarks/:id         -> BookmarksController.#update
  // patch /profile/bookmarks/:id       -> BookmarksController.#update
  // delete /profile/bookmarks/:id      -> BookmarksController.#destroy
  // get /profile/bookmarks/:id/share_link      -> BookmarksController.ShareLinkController.#read
  // post /profile/bookmarks/:id/share_link      -> BookmarksController.ShareLinkController.#create
  // patch /profile/bookmarks/:id/share_link      -> BookmarksController.ShareLinkController.#update
  // delete /profile/bookmarks/:id/share_link      -> BookmarksController.ShareLinkController.#destroy
})

export default router.expressMiddleware()

// or for Koa
// export default router.koaMiddleware()

```

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