feathersjs

User's permissions in feathers.js API

非 Y 不嫁゛ 提交于 2019-12-24 22:28:09
问题 I'm trying to create some REST API with user roles like admin, superadmin etc. I was trying to achieve this by using feathers-permissions module, but there are none working examples and the internet. Have you ever dealt with such task? What I do now is: feathers generate app and then feathers generate authentication . What should I do next? 回答1: The secret to implementing permissions and roles in Feathers is that Hooks really provide everything you need with all the flexibility you might want

How Can I set the default Sort order in FeathersJs

ε祈祈猫儿з 提交于 2019-12-24 10:55:11
问题 I have an issue with Feathersjs , integrating with sequalize. If I set the default pagination like below, and there is no sort specified it will generate an error because the SQL statement generated is invalid. Service Created with default of 5: app.use('/manifests', service({ paginate: { default: 5, max: 25 } })); SQL Statement Generated ( setting a limit of 20 ) SELECT [id], ...etc FROM [Manifest] AS [Manifest] OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY It Makes sense to set a default order ,

Chat App Tut: purpose of populate()?

删除回忆录丶 提交于 2019-12-24 10:15:59
问题 I'm in the process of learning FeathersJS and so far it seems like everything I wish Meteor was. Keep up the great work! Right now I'm working through the Chat App tutorial but have run into some confusion. I don't quite understand what's going on in this section of the tutorial, specifically the populate hook in messages.hooks.js : 'use strict'; const { authenticate } = require('feathers-authentication').hooks; const { populate } = require('feathers-hooks-common'); const processMessage =

Feathers calling custom API method

夙愿已清 提交于 2019-12-23 08:38:34
问题 I define my api with something like the below: class MyFeathersApi { feathersClient: any; accountsAPI: any; productsAPI: any; constructor(app) { var port: number = app.get('port'); this.accountsAPI = app.service('/api/accounts'); this.productsAPI = app.service('/api/products'); } findAdminAccounts(filter: any, cb: (err:Error, accounts:Models.IAccount[]) => void) { filter = { query: { adminProfile: { $exists: true } } } this.accountsAPI.find(filter, cb); } When I want to use database adapter

is there any way where i can apply group and pagination using createQuery?

不想你离开。 提交于 2019-12-23 06:27:23
问题 Query like this, http://localhost:3030/dflowzdata?$skip=0&$group=uuid&$limit=2 and dflowzdata service contains data like, [ { "uuid": 123456, "id": 1 }, { "uuid": 123456, "id": 2 }, { "uuid": 7890, "id": 3 }, { "uuid": 123456, "id": 4 }, { "uuid": 4567, "id": 5 } ] Before Find Hook like, if (query.$group !== undefined) { let value = hook.params.query.$group delete hook.params.query.$group const query = hook.service.createQuery(hook.params.query); hook.params.rethinkdb = query.group(value) }

is there any way where i can apply group and pagination using createQuery?

孤街醉人 提交于 2019-12-23 06:27:11
问题 Query like this, http://localhost:3030/dflowzdata?$skip=0&$group=uuid&$limit=2 and dflowzdata service contains data like, [ { "uuid": 123456, "id": 1 }, { "uuid": 123456, "id": 2 }, { "uuid": 7890, "id": 3 }, { "uuid": 123456, "id": 4 }, { "uuid": 4567, "id": 5 } ] Before Find Hook like, if (query.$group !== undefined) { let value = hook.params.query.$group delete hook.params.query.$group const query = hook.service.createQuery(hook.params.query); hook.params.rethinkdb = query.group(value) }

How to use app.service('myService') inside a FeathersJS service extension?

微笑、不失礼 提交于 2019-12-23 05:34:34
问题 I am trying to extend find() method for a service named properties in my FeathersJS app. What I need is appending in all records returned by find() an array with integers coming from another service named propertyadds . This means I need to change my response from { "total": 2973, "limit": 10, "skip": 0, "data": [ { "id": 1, ... }, { "id": 2, ... } ... ] } to { "total": 2973, "limit": 10, "skip": 0, data: [ { "id": 1, ... "additionals": [10,20,30] }, { "id": 2, ... "additionals": [12,25,33] }

MobX + React Native : way to inject stores

霸气de小男生 提交于 2019-12-22 08:14:17
问题 I'm trying to work with MobX for a new project. I started it on May 2017, and everything was working well. I had to stop, and now I go on developing it. I had to make an npm install to manage making it working, but now, I have some problem with stores... I rely on this tutorial for the structure : https://blog.callstack.io/write-react-native-apps-in-2017-style-with-mobx-e2dffc209fcb This is my structure : Main index.js import { Provider } from 'mobx-react'; import Stack from './router';

How to query many to many relation in sequelize

女生的网名这么多〃 提交于 2019-12-22 07:05:30
问题 I've been using feathersjs/nodejs over postgres db via sequelize. In my db i have Users table and Events table. They are twice in relation: events.belongsTo(models.users, { foreignKey: { name: 'creatorId', allowNull: false }, onDelete: 'CASCADE', as: 'creator' }); events.belongsToMany(models.users, { through: 'event_participants', as: 'participants', foreignKey: 'eventId', otherKey: 'userId' }); models.users.belongsToMany(events, { through: 'event_participants', as: 'events' }); Everything

Structure restrictToOwner & restrictToRoles in feathersjs

戏子无情 提交于 2019-12-13 03:26:13
问题 I've read through the documentation, but I can't seem to get it right. I'm trying to implement a restrictToOwner and restrictToRoles such that users with admin or superadmin role can access every other method in this service const restrict = [ ‎ authenticate('jwt'), ‎ restrictToOwner({ idField: '_id', ownerField: '_id' }) ] ‎ const restrictUser = [ authenticate('jwt'), restrictToRoles({ roles: ['admin', 'super-admin'], fieldName: 'roles' }) ] before: { all: [], find: [ ...restrictUser ], get: