
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
@tailored-apps/rethinkable
Advanced tools
Util collection for APIs using RethinkDB (Model, CRUD Router, CRUD Pluralized Router).
rethinkable is a model and CRUD helper library for rethinkdb and Koa, using Koa-Router].
npm install @tailored-apps/rethinkable
Once you should set the connection and if you want your custom logger instance to the library.
Therefor the library provides you 2 functions setConnection(__connectioon__)
and setLogger(__logger__)
.
Without the connection the library will not be able to conenct to your database.
I would prefer you to create your own abstract model which extends from the Model
provided by the library.
At this place you could setup your configuration and some more optional custom changes.
import { Model, setLogger, setConnection } from 'rethinkable'
import { getLogger } from './logger'
import { getConnection ] from './database'
setLogger(getLogger())
setConnection(getConnection())
export default class Abstract extends Model {
// general custom changes could be implemented hiere
}
Per default your models should be named (uppercase first character) like your tables.
The id
property will be handled from the library's model class.
import Abstract from './Abstract'
export default class TableName extends Abstract {
constructor ({ name1, name2, name3, ...other }) {
super(other)
this.name1 = name1
this.name2 = name2
this.name3 = name3
}
}
In general each router is an instance of the koa-router. Like for models I would prefer you to create your own abstract router, at least to set the require path for your models.
import Router from 'rethinkable/RouterPluralized'
export default class Abstract extends Router {
get modelsRequirePath () {
return '../models'
}
}
Like models, the router should be named (uppercase first character) like your tables, to work out of the box with your previously generated models.
import Abstract from './Abstract'
esport default class TableName extends Abstract {}
After all classes are created, you have to enable router's route to your koa-router.
import Router from 'koa-router'
import TableNameRouter from './routers/TableName'
const router = new TableNameRouter({ prefix: '/tableName', listFields: 'id,name1' }).enableRoutes()
export default new Router()
.use(router.routes(), router.allowedMethods())
The router class could initialized with some configuration options:
Option | Description |
---|---|
middleware | a list of middleware which should be executed before the router calls |
routes | a list of all routes which should be enables |
modifiers | a modifier function, which prepare each returned entry |
offset | the default offset value for the list call (default: 0) |
limit | the default limit value for the list call (default: 10) |
listFields | a comma separated list of values, which should be returned on the list call |
Routes
Route | HTTP Method | Path |
---|---|---|
load | GET | / |
loadAll | GET | /:id |
create | POST | / |
replace | PUT | / |
update | PATCH | /:id |
remove | DELETE | /:id |
FAQs
Util collection for APIs using RethinkDB (Model, CRUD Router, CRUD Pluralized Router).
The npm package @tailored-apps/rethinkable receives a total of 3 weekly downloads. As such, @tailored-apps/rethinkable popularity was classified as not popular.
We found that @tailored-apps/rethinkable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.