Tapestries Spool. This spool provides the tapestry interface, which
other spools such as spool-sequelize implement,
as well as a suite of tests that Tapestry implementations should pass.
What are Tapestries?
Tapestries automatically generate easy-to-use RESTful endpoints for your models.
Install
$ npm install @fabrix/spool-tapestries --save
Configure
// config/main.tsexportconstmain{spools: [// ... other spoolsrequire('@fabrix/spool-tapestries').TapestriesSpool]}
// config/tapestries.tsexportconsttapestries={/** * Generate routes for controller handlers. * You can set controllers to true/false to enable/disable * automatic tapestries routes globaly */controllers: {/** * Default methods to accept for routes generated from controller handlers. */method: '*',/** * List of controllers to ignore; that is, do not generate tapestry routes * for them. */ignore: []},/** * Generate conventional Create, Read, Update, and Delete (CRUD) routes for * each Model. */models: {options: {/** * The max number of objects to return by default. Can be overridden in * the request using the ?limit argument. */defaultLimit: 100,/** * Subscribe to changes on requested models via WebSocket * (support provided by spool-websocket) */watch: false,/** * Whether to populate all model associations by default (for "find") */populate: true},actions: {create: true,find: true,update: true,destroy: true,/** * Specify which "association" endpoints to activate. */createAssociation: true,findAssociation: true,updateAssociation: true,destroyAssociation: true}},/** * Prefix your tapestry route paths */prefix: '/api/v1'}
API
api.services.TapestryService
The purpose of TapestryService is to transform and forward queries to the datastore.
create (modelName, values, [options])
param
required?
description
example
modelName
Yes
The name of the model to create (in api.models)
User
values
Yes
An object containing the values of the record to create
{ username: 'admin' }
options
No
Datastore-specific options
find (modelName, criteria, [options])
param
required?
description
example
modelName
Yes
The name of the model to search for (in api.models)