0.0.9 • Published 5 years ago

flyn v0.0.9

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

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

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago