-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Route handling #4
Comments
I think we should support queries! :) Also we probably should pass object as a second argument to filter db.find import { router } from 'kakapo';
router.get('/users?size=42&page=7', usersHandler);
router.get('/users/:id', usersHandler);
const usersHandler = (request, database) => ({
users: database.find('user', request.params, request.query.size);
}); |
As I think of that, we shouldn't have router & database being so tightly coupled... imo router shouldn't know anything about database: import { Database, Router } from 'kakapo';
const database = new Database(/* bla bla bla */);
const router = new Router(/* bla bla bla */);
database.register('user', /* bla bla bla */);
router.get('/users?size=42&page=7', usersHandler);
router.get('/users/:id', usersHandler);
const usersHandler = request => ({
users: database.find('user', {id: request.params.id}, {size: request.query.size});
}); |
|
@oskarcieslik should we close this issue and create a new one with the point of decoupling the router and the db? |
Yes, I will close this after tests for query implementation pass :) |
The
Router
must use https://github.com/pillarjs/path-to-regexp to handle requestsDraft...
The text was updated successfully, but these errors were encountered: