mirror of
https://github.com/wassname/talk.git
synced 2026-08-13 12:40:11 +08:00
replaced eslint:recommended with prettier
This commit is contained in:
+17
-15
@@ -13,10 +13,12 @@ const debug = require('debug')('talk:graph:context');
|
||||
* level functions all need the context reference.
|
||||
* @type {Array}
|
||||
*/
|
||||
const contextPlugins = plugins.get('server', 'context').map(({plugin, context}) => {
|
||||
debug(`added plugin '${plugin.name}'`);
|
||||
return {context};
|
||||
});
|
||||
const contextPlugins = plugins
|
||||
.get('server', 'context')
|
||||
.map(({ plugin, context }) => {
|
||||
debug(`added plugin '${plugin.name}'`);
|
||||
return { context };
|
||||
});
|
||||
|
||||
/**
|
||||
* This should iterate over the passed in plugins and load them all with the
|
||||
@@ -24,18 +26,19 @@ const contextPlugins = plugins.get('server', 'context').map(({plugin, context})
|
||||
* @return {Object} the saturated plugins object
|
||||
*/
|
||||
const decorateContextPlugins = (context, contextPlugins) => {
|
||||
|
||||
// For each of the plugins, we execute with the context to get the context
|
||||
// based plugin. We then merge that into an object for the plugin. Once the
|
||||
// plugin is assembled, we merge that object with all the other objects
|
||||
// provided from the other plugins.
|
||||
return merge(...contextPlugins.map((plugin) => {
|
||||
return Object.keys(plugin.context).reduce((services, serviceName) => {
|
||||
services[serviceName] = plugin.context[serviceName](context);
|
||||
return merge(
|
||||
...contextPlugins.map(plugin => {
|
||||
return Object.keys(plugin.context).reduce((services, serviceName) => {
|
||||
services[serviceName] = plugin.context[serviceName](context);
|
||||
|
||||
return services;
|
||||
}, {});
|
||||
}));
|
||||
return services;
|
||||
}, {});
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -43,7 +46,6 @@ const decorateContextPlugins = (context, contextPlugins) => {
|
||||
*/
|
||||
class Context {
|
||||
constructor(parent) {
|
||||
|
||||
// Generate a new context id for the request if the parent doesn't provide
|
||||
// one.
|
||||
this.id = parent.id || uuid.v4();
|
||||
@@ -76,12 +78,12 @@ class Context {
|
||||
*
|
||||
*/
|
||||
static forSystem() {
|
||||
const {models: {User}} = connectors;
|
||||
const { models: { User } } = connectors;
|
||||
|
||||
// Create the system user.
|
||||
const user = new User({system: true});
|
||||
const user = new User({ system: true });
|
||||
|
||||
return new Context({user});
|
||||
return new Context({ user });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user