alarner / bookshelf-api Goto Github PK
View Code? Open in Web Editor NEWExpress middleware for generating an API based on bookshelf models.
License: MIT License
Express middleware for generating an API based on bookshelf models.
License: MIT License
for example /api/v1/event/?withRelated[0]=user
<h1>model.hasTimestamps.indexOf is not a function</h1>
<h2></h2>
<pre>TypeError: model.hasTimestamps.indexOf is not a function
at module.exports (/Users/admin/tiy/final-project/node_modules/bookshelf-api/dist/get.js:7:26)
at /Users/admin/tiy/final-project/node_modules/bookshelf-api/dist/middleware.js:46:11
at Layer.handle [as handle_request] (/Users/admin/tiy/final-project/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/admin/tiy/final-project/node_modules/express/lib/router/index.js:312:13)
at /Users/admin/tiy/final-project/node_modules/express/lib/router/index.js:280:7
at Function.process_params (/Users/admin/tiy/final-project/node_modules/express/lib/router/index.js:330:12)
at next (/Users/admin/tiy/final-project/node_modules/express/lib/router/index.js:271:10)
at module.exports (/Users/admin/tiy/final-project/lib/middleware/logged-in.js:8:3)
at Layer.handle [as handle_request] (/Users/admin/tiy/final-project/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/admin/tiy/final-project/node_modules/express/lib/router/index.js:312:13)
at /Users/admin/tiy/final-project/node_modules/express/lib/router/index.js:280:7
at Function.process_params (/Users/admin/tiy/final-project/node_modules/express/lib/router/index.js:330:12)
at next (/Users/admin/tiy/final-project/node_modules/express/lib/router/index.js:271:10)
at Function.handle (/Users/admin/tiy/final-project/node_modules/express/lib/router/index.js:176:3)
at router (/Users/admin/tiy/final-project/node_modules/express/lib/router/index.js:46:12)
at Layer.handle [as handle_request] (/Users/admin/tiy/final-project/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/admin/tiy/final-project/node_modules/express/lib/router/index.js:312:13)
at /Users/admin/tiy/final-project/node_modules/express/lib/router/index.js:280:7
at Function.process_params (/Users/admin/tiy/final-project/node_modules/express/lib/router/index.js:330:12)
at next (/Users/admin/tiy/final-project/node_modules/express/lib/router/index.js:271:10)
at SessionStrategy.strategy.pass (/Users/admin/tiy/final-project/node_modules/passport/lib/middleware/authenticate.js:325:9)
at /Users/admin/tiy/final-project/node_modules/passport/lib/strategies/session.js:65:12</pre>
Similarly to the way that you can filter with where clauses and pull related models, it would be nice to be able to specify result order via query params
Similarly to the way that you can filter with where clauses and pull related models, it would be nice to be able to specify result limit and offset via query params. It would also be great to be able to specify a hard maximum limit in the middleware configuration options so that you can't query millions of records
I'm use node 6.2.0 win10 I'm test by you example /api/v1/product is not work
it say Not Found 404
but in custom route is work app.get('/api/v1/product', api('Product'))
please help me
Thanks.
I'm using UUIDs as IDs in my models. When I make a GET request with an id (e.g. user/:id) and the UUID starts with a number, the related objects (oneToMany) aren't loaded. It works when the UUID starts with a letter.
I'm guessing, that somewhere the ID is converted to a number.
Right now models, database table and route pluralization is inconsistent:
For example:
db table: products
model: Product
endpoint: /api/v1/product
I've had requests to allow the route to be pluralized. For example:
endpoint: /api/v1/products
or /api/v1/products/1
This should be added as an option to the configuration file:
let api = require('bookshelf-api')({
path: path.join(__dirname, 'models'),
pluralEndpoints: true
});
A quick look shows that this might be helpful: https://github.com/blakeembrey/pluralize
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.