revane-fastify
Installation
npm install revane-fastify --save
Example
const RevaneFastify = ;const BeanProvider = ; const beanProvider = basePackage: __dirname;const options = port: 3000;const revaneFastify = options beanProvider;return revaneFastify ;
API
new RevaneFastify(options, beanProvider)
options
host
The host that will passed to fastify
.
port
The port that will passed to fastify
.
silent
If set to true
no information about the application will be logged. Defaults to false
.
use(middleware)
Allows to add a middleware.
Note: This will be executed asynchronous.
register(plugin, [options])
Allows to add a fastify
plugin.
Note: This will be executed asynchronous.
register(id)
Selects a bean by id and adds it to the fastify
server.
Note: This will be executed asynchronous.
registerControllers()
Registers all beans decorated with @Controller()
.
Note: This will be executed asynchronous.
listen()
Starts listening on the configured host/port. Returns a Promise.
close()
Closes the server. Returns a Promise.
port()
Returns the port of the server.
ready(handler)
Calls the handler
function when all olugins have been loaded.
Note: This will be executed asynchronous.
setErrorHandler(handler)
Adds an error handler.
fastifyRevane
Note: This will be executed asynchronous.
setNotFoundHandler(handler)
Adds a page not found handler.
fastifyRevane
Note: This will be executed asynchronous.
after(handler)
Executes the handler
function after the current plugin has been added.
Note: This will be executed asynchronous.
Controllers
It is possible to create controllers using decorators.
@ { return id } @ { return }
There are decorators for the http methods:
- Get(url, [options])
- Post(url, [options])
- Put(url, [options])
- Delete(url, [options])
- Patch(url, [options])
- Head(url, [options])
- Options(url, [options])
- All(url, [options])
Furthermore there are decorators that provide information from the request
and the reply
itself.
-
Query
-
Cookie
-
Param
-
Body
-
Header
-
Reply
-
Log
-
Headers
-
Params
-
QueryParameters
-
RequestBody
-
Cookies