flyn

0.0.9 • Public • Published

Flyn

Flyn is a multi framework package that makes easier to create routes for controllers.

Install

NPM

  • Use: require('flyn')
  • Install: npm install --save flyn

YARN

  • Use: require('flyn')
  • Install: yarn add flyn

Usage

Example

const app = require('express')()
 
flyn({
  path: './routes', // default
  logger: true, // default
  prefix: '' // default
})(app)
 
app.listen(process.env.PORT, () => {
  console.log(
    'Server running on', 
    process.env.PORT
  )
})
 

Endpoint file example

// ./routes/GET.status.js
 
/*
  FILE PATH === './routes/GET.status.js'
  METHOD === 'GET'
  URL === '/status'
*/
 
module.exports = app => (req, res) => {
 
  return res.send({
    success: 1
  })
}

Another endpoint file example

// ./routes/entities/POST.user.js
 
/*
  FILE PATH === './routes/entities/POST.user.js'
  METHOD === 'POST'
  URL === '/entities/user'
*/
 
module.exports = app => (req, res) => {
 
  console.log('User created with success')
 
  return res.send({
    success: 1
  })
}

Compatibility

Now

  • Express
  • Fastify
  • Hapi

Soon

  • Koa
  • NestJs

License

Licensed under permissive MIT license

Package Sidebar

Install

npm i flyn

Weekly Downloads

1

Version

0.0.9

License

MIT

Unpacked Size

5.21 kB

Total Files

13

Last publish

Collaborators

  • nneutrinno