0.2.0 • Published 1 year ago

@pybot/fastify-autoload v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@pybot/fastify-autoload

Test workflow npm version NPM License

Fastify plugin for creating dynamic routes based on valid JSON.

Installation

npm i @pybot/fastify-autoload

Example

const fastify = require('fastify')
const autoload = require('@pybot/fastify-autoload')

const app = fastify({logger: true})

app.register(autoload, {
  dir: 'config'
})

app.listen({ port: 3000 })

Folder structure:

├── config
│   ├── api-server.json
│   ├── unsupported.txt
│   ├── trace.json
├── package.json
└── src
    └── index.js

Now we can specify multiple directories as well.

const fastify = require('fastify')
const autoload = require('@pybot/fastify-autoload')

const app = fastify({logger: true})

app.register(autoload, {
  dir: ['server-config', 'files']
})

app.listen({ port: 3000 })

Folder structure:

├── server-config
│   ├── api-server.json
│   ├── unsupported.txt
│   ├── trace.json
├── files
│   ├── invalid.json
│   ├── unsupported.txt
│   ├── server.json
├── package.json
└── src
    └── index.js
0.1.0

1 year ago

0.0.3

1 year ago

0.2.0

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago