Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
moleculer-adapter-feathers
Advanced tools
Readme
Moleculer adapter to import feathers services. That includes:
$ npm install moleculer-adapter-feathers --save
const Feathers = require("moleculer-adapter-feathers");
const { ServiceBroker } = require("moleculer");
const feathersKnex = require("feathers-knex");
const knex = require("knex");
const broker = new ServiceBroker();
// Create a DB service via knex for `user` entities
broker.createService({
name: "users",
mixins: [Feathers],
settings: {
feathers: {
adapter: feathersKnex,
options: {
name: "users",
Model: new knex({
client: "pg",
connection: { ... },
}),
},
},
},
});
broker.start()
// Create a new user
.then(() => broker.call("users.create", {
username: "john",
email: "john@doe.com",
}))
// Get all users
.then(() => broker.call("users.find").then(console.log));
Property | Type | Default | Description |
---|---|---|---|
adapter | `Object | Function` | required |
hooks | Object | {} | Object containing before and after hooks. |
options | Object | {} | Options passed to Feathers service adapter. |
Hooks work just as they do in Feathers. They are passed down to a service in settings.feathers.hooks
.
users.service.js
module.exports = {
...
settings: {
feathers: {
adapter: feathersKnex,
hooks: require('./hooks'),
options: {
name: "users",
Model: new knex({
client: "pg",
connection: { ... },
}),
},
},
},
...
}
hooks.js
module.exports = {
before: {
create: [
hook => {
console.log('create hook')
return hook
},
],
find: [],
get: [],
update: [],
patch: [],
remove: [],
},
after: {
create: [],
find: [],
get: [],
update: [],
patch: [],
remove: [],
},
}
Standard Feathers actions are exposed: create
, get
, find
, update
, patch
, remove
with all the standard Feathers parameters. Actions can be overwritten.
Feathers service methods can be accessed directly via this.create
, this.find
and etc.
create
Create an object in a service.
Property | Type | Default | Description |
---|---|---|---|
* | Any | {} | Object to be created. |
Type: Object
Created object (or any other service response).
find
Find objects by a provided query, if any.
Property | Type | Default | Description |
---|---|---|---|
* | Any | {} | Query specified by the service. |
Type: Array[Object]
Array of results.
get
Get object in the service by a provided (unique) ID.
Property | Type | Default | Description |
---|---|---|---|
id | `String | Number` | required |
Type: Object
Object found by the ID.
patch
Changes the properties of an object.
Property | Type | Default | Description |
---|---|---|---|
id | `String | Number` | required |
* | Any | {} | Values to be patched. |
Type: Object
Object patched.
update
Overwrites an object's properties.
Property | Type | Default | Description |
---|---|---|---|
id | `String | Number` | required |
* | Any | {} | Rest of the object. |
Type: Object
Object updated.
remove
Remove object by ID.
Property | Type | Default | Description |
---|---|---|---|
id | `String | Number` | required |
Type: Object
Object removed.
FAQs
Moleculer service mixin adapting Feathers.js services
The npm package moleculer-adapter-feathers receives a total of 4 weekly downloads. As such, moleculer-adapter-feathers popularity was classified as not popular.
We found that moleculer-adapter-feathers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.