0.1.3 • Published 2 years ago
@kenzhemir/fastify-crud v0.1.3
fastify-crud
Fastify Plugin to create CRUD routes. This plugin is good for fast prototyping.
Installation
npm i @kenzhemir/fastify-crudUsage
import Fastify from 'fastify'
import crudPlugin from 'fastify-crud-plugin'
const fastify = Fastify()
fastify.register(crudPlugin, {
baseUrl: '/api/v1/books',
create: async (resource) => {/* Insert resource into DB */},
read: async (resourceId) => {/* Select resource from DB */},
update: async (resourceId, resource) => {/* Update resource in DB */},
delete: async (resourceId) => {/* Delete resource from */},
schemas: {
IdParam: {/*...*/},
CreateBody: {/*...*/},
UpdateBody: {/*...*/}
}
})
fastify.listen(3000)Options
baseUrl(required): This URL is used to create the routes.create: This function is used to create a resource for the POST {baseUrl} route.read: This function is used to read a resource for the GET {baseUrl}/:id route.update: This function is used to update a resource for the PUT {baseUrl}/:id route.delete: This function is used to delete a resource for the DELETE {baseUrl}/:id route.schemas: Optional validation schemasIdParam: Schema for validating :id parameter. Adding validation schema can impact the id argument.CreateBody: Schema for validating resource forCreate.UpdateBody: Schema for validating resource forUpdate.
defaultRouteParams: Object that will be used as a base for all the Route objects. This is an escape hatch in case you want to minimally configure the Routes' behaviour
0.1.3-beta.2
2 years ago
0.1.3-beta.1
2 years ago
0.1.3-beta.0
2 years ago
0.1.3
2 years ago
0.1.2-beta.0
2 years ago
0.1.2
2 years ago
0.1.0
2 years ago
0.1.0-4
2 years ago
0.1.1-beta.0
2 years ago
0.1.1
2 years ago
0.1.0-3
2 years ago
0.1.0-2
2 years ago
0.1.0-1
2 years ago
0.1.0-0
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago