choo-resource

1.0.1 • Public • Published

choo-resource stability

npm version build status downloads js-standard-style

simple resource management for choo apps

Installation

$ npm install choo-resource

Usage

// index.js
var choo = require('choo')
var html = require('choo/html')
var link = require('choo-resource/link')
 
var app = choo()
 
app.use(require('choo-resource')())
 
// registers '/posts' and '/posts/:id' routes
// registers Post and Posts components in component cache
app.resource(
  '/posts',
  require('./views/posts'),
  require('./components/posts')
  )
app.resource(
  '/posts/:id'
  require('./views/post'),
  require('./components/post'),
  )
 
app.route('/', (state, emit) => {
  return html`<body>
    <ul>
      <li>${link('All posts', '/posts')}</li>
      <li>${link('Post 1', '/posts/1')}</li>
      <li>${link('Post 2', '/posts/2')}</li>
    </ul>
  </body>`
})
 
app.mount('body')

Readme

Keywords

none

Package Sidebar

Install

npm i choo-resource

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • s3ththompson