How to use the @feathersjs/commons.stripSlashes function in @feathersjs/commons

To help you get started, we’ve selected a few @feathersjs/commons examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kalisio / feathers-distributed / src / index.js View on Github external
function publishService (app, path) {
  const service = app.service(path)
  if (!service || (typeof service !== 'object')) return
  if (service.remote) {
    debug('Ignoring remote service publication on path ' + path + ' for app with uuid ' + app.uuid)
    return
  }
  const serviceDescriptor = {
    uuid: app.uuid,
    path: stripSlashes(path),
    events: service.distributedEvents || service._serviceEvents
  }
  // Skip internal services
  if (isInternalService(app, serviceDescriptor)) {
    debug('Ignoring local service on path ' + serviceDescriptor.path + ' for app with uuid ' + app.uuid)
    return
  }
  // Register the responder to handle remote calls to the service
  if (!service.responder) service.responder = new LocalService(Object.assign({ app }, serviceDescriptor))
  // Publish new local service
  app.servicePublisher.publish('service', serviceDescriptor)
  debug('Published local service on path ' + serviceDescriptor.path + ' for app with uuid ' + app.uuid)
}
github feathersjs / feathers / packages / feathers / lib / application.js View on Github external
service (path, service) {
    if (typeof service !== 'undefined') {
      throw new Error('Registering a new service with `app.service(path, service)` is no longer supported. Use `app.use(path, service)` instead.');
    }

    const location = stripSlashes(path) || '/';
    const current = this.services[location];

    if (typeof current === 'undefined' && typeof this.defaultService === 'function') {
      return this.use(location, this.defaultService(location))
        .service(location);
    }

    return current;
  },
github feathersjs / feathers / packages / authentication-client / src / hooks / authentication.ts View on Github external
return (context: HookContext) => {
    const { app, params, path, method, app: { authentication: service } } = context;

    if (stripSlashes(service.options.path) === path && method === 'create') {
      return context;
    }

    return Promise.resolve(app.get('authentication')).then(authResult => {
      if (authResult) {
        context.params = Object.assign({}, authResult, params);
      }

      return context;
    });
  };
};
github feathersjs / feathers / packages / feathers / lib / application.js View on Github external
use (path, service, options = {}) {
    if (typeof path !== 'string') {
      throw new Error(`'${path}' is not a valid service path.`);
    }

    const location = stripSlashes(path) || '/';
    const isSubApp = typeof service.service === 'function' && service.services;
    const isService = this.methods.concat('setup').some(name => typeof service[name] === 'function');

    if (isSubApp) {
      const subApp = service;

      Object.keys(subApp.services).forEach(subPath =>
        this.use(`${location}/${subPath}`, subApp.service(subPath))
      );

      return this;
    }

    if (!isService) {
      throw new Error(`Invalid service object passed for path \`${location}\``);
    }
github feathersjs / feathers / packages / express / lib / rest / index.js View on Github external
function parseRoute (path, methods, method, route) {
  return {
    method,
    verb: route.verb,
    uri: route.uri ? `/${path}/${stripSlashes(route.uri)}` : getDefaultUri(path, methods, method)
  };
}
github feathersjs / feathers / packages / transport-commons / src / routing.ts View on Github external
lookup (path: string): { [key: string]: string } {
      if (!path) {
        return null;
      }

      return this[ROUTER].lookup(stripSlashes('' + path) || '/');
    }
  });
github feathersjs / feathers / packages / rest-client / lib / base.js View on Github external
constructor (settings) {
    this.name = stripSlashes(settings.name);
    this.options = settings.options;
    this.connection = settings.connection;
    this.base = `${settings.base}/${this.name}`;
  }