How to use feathers - 10 common examples

To help you get started, we’ve selected a few feathers 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 bitovi / testee / lib / host / index.js View on Github external
module.exports = function(configuration) {
  var inject = injector(configuration);
  var root = parse(configuration.root);
  var clientPath = path.join(require.resolve('testee-client'), '..', '..', 'dist');
  var app = feathers()
    .configure(socketio())
    // Statically serves the adapters distributables in the given path
    //testee-client main is defined as /dist/testee.js, so require will resolve to that subpath
    .use(configuration.adapter, feathers.static(clientPath))
    // Inject links to socket.io and the Testee client adapter distributable into any HTML page
    .use(inject);

  if(configuration.coverage) {
    debug('setting up code coverage', configuration.coverage);
    app.use(coverage(configuration.coverage, configuration.root));
  }

  // Depending on the root URL protocol set up a proxy or file server
  if(root.protocol === 'http:' || root.protocol === 'https:') {
    debug('initializing http proxy');
    app.use(proxy.http(root, configuration));
  } else {
    // Use the plain path name
    debug('intializing static file server', configuration.root);
    app.use(feathers.static(configuration.root));
github feathersjs-ecosystem / authentication / examples / sub-apps / index.js View on Github external
var feathers = require('feathers');
var api = require('./api');

// Initialize the application
var app = feathers()
  // Initialize our API sub app
  .use('/api', api)
  .use('/', feathers.static(__dirname + '/public'));

app.listen(3030);

console.log('Feathers authentication app started on 127.0.0.1:3030');
github feathersjs / feathers / packages / authentication / examples / sub-apps / index.js View on Github external
var feathers = require('feathers');
var api = require('./api');

// Initialize the application
var app = feathers()
  // Initialize our API sub app
  .use('/api', api)
  .use('/', feathers.static(__dirname + '/public'));

app.listen(3030);

console.log('Feathers authentication app started on 127.0.0.1:3030');
github feathersjs-ecosystem / feathers-mongodb / examples / basic.js View on Github external
var feathers = require('feathers'),
  bodyParser = require('body-parser'),
  mongoService = require('../lib');

// Create a feathers instance.
var app = feathers()
  // Setup the public folder.
  .use(feathers.static(__dirname + '/public'))
  // Enable Socket.io
  .configure(feathers.socketio())
  // Enable REST services
  .configure(feathers.rest())
  // Turn on JSON parser for REST services
  .use(bodyParser.json())
  // Turn on URL-encoded parser for REST services
  .use(bodyParser.urlencoded({extended: true}))

// Connect to the db, create and register a Feathers service.
app.use('todos', new mongoService('todos'));

// Start the server.
var port = 8080;
app.listen(port, function() {
    console.log('Feathers server listening on port ' + port);
github t2t2 / vue-syncers-feathers / example / server.js View on Github external
const webpack = require('webpack')
const webpackConfig = require('./webpack.config')

const compiler = webpack(webpackConfig)

app.use(require('webpack-dev-middleware')(compiler, {
	publicPath: webpackConfig.output.publicPath,
	noInfo: true,
	stats: {
		colors: true
	}
}))
app.use(require('webpack-hot-middleware')(compiler))

// Static files
app.use('/', feathers.static(__dirname))

// Seed with data
app.service('countries').create(require('country-data').countries.all)

app.listen(8030, () => {
	console.log('Serving examples on http://localhost:8030')
})
github primozs / feathers-react-bojler / server / app.js View on Github external
const webpackHotMiddleware = require('webpack-hot-middleware');

  const compiler = webpack(config);
  app.use(webpackDevMiddleware(compiler, {
    noInfo: true,
    publicPath: config.output.publicPath
  }));
  app.use(webpackHotMiddleware(compiler));
  /* eslint-enable */
}

app.use(compress())
  .options('*', cors())
  .use(cors())
  .use(favicon(path.join(app.get('public'), 'favicon.ico')))
  .use('/', serveStatic(app.get('public')))
  .use(cookieParser())
  .use(bodyParser.json({ limit: '20mb' }))
  .use(bodyParser.urlencoded({ extended: true }))
  .configure(hooks())
  .configure(rest())
  .configure(socketio())
  .configure(services)
  .configure(middleware);

export default app;
module.exports = app;
github usehenri / henri / src / henri.js View on Github external
const init = () => {
  // Basic configuration
  app.use(compress());
  app.options('*', cors());
  app.use(cors());
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: true }));
  app.use(cookieParser());
  app.configure(hooks());
  app.configure(rest());

  if (app.get('public')) {
    debug('serving static files from', app.get('public'));
    app.use('/', serveStatic(app.get('public')));
  }

  debug('socket.io enabled.');
  const socketio = require('feathers-socketio');
  app.configure(socketio());

  if (app.get('auth')) {
    app.configure(auth(app.get('auth')));
    app.configure(local());
    app.configure(jwt());
    app.configure(cookies);
    const addUser = (hook) => {
      const id = hook.params.user._id;
      return hook.app.service('users')
        .get(id)
        .then(user => {
github storynory / kisscms / app.js View on Github external
// server.js
var feathers = require( 'feathers' ),
  bodyParser = require( 'body-parser' ),
  nedbService = require( 'feathers-nedb' );
var router = feathers.Router();

// Create a feathers instance.
var app = feathers()
  // Setup the public folder.
  .use( feathers.static( __dirname + '/public' ) )
  // Enable Socket.io
  .configure( feathers.socketio() )
  // Enable REST services
  .configure( feathers.rest() )
  // Turn on JSON parser for REST services
  .use( bodyParser.json() )
  // Turn on URL-encoded parser for REST services
  .use( bodyParser.urlencoded( {
    extended: true
  } ) )

// Connect to the db, create and register a Feathers service.

app.use( feathers.static( 'views/public' ) );

app.use( 'api/posts', new nedbService( 'posts' ) );
github feathersjs-ecosystem / authentication / examples / basic / index.js View on Github external
"permissions": {
        authType: 'rerequest',
        "scope": ["public_profile", "email"]
      }
    },
    github: {
      strategy: GithubStrategy,
      "clientID": "your-github-client-id",
      "clientSecret": "your-github-client-secret"
    }
  }))
  // Initialize a user service
  .use('/api/users', memory())
  // A simple Message service that we can used for testing
  .use('/messages', memory())
  .use('/', feathers.static(__dirname + '/public'))
  .use(function(error, req, res, next){
    res.status(error.code);
    res.json(error);
  });

var messageService = app.service('/messages');
messageService.create({text: 'A million people walk into a Silicon Valley bar'}, {}, function(){});
messageService.create({text: 'Nobody buys anything'}, {}, function(){});
messageService.create({text: 'Bar declared massive success'}, {}, function(){});

messageService.before({
  all: [
    authHooks.verifyToken({secret: 'feathers-rocks'}),
    authHooks.populateUser(),
    authHooks.requireAuth()
  ]
github root-systems / dogstack / createAssetServer.js View on Github external
app.use(httpLogger({ logger: log }))

  // gzip compression
  app.use(compress())

  // http security headers
  app.use(helmet())

  // favicon
  const faviconConfig = app.get('favicon')
  assert(faviconConfig, 'must set `favicon` in config. example: "app/favicon.ico"')
  app.use(favicon(faviconConfig))

  // static files
  if (assetConfig.root) {
    app.use('/', feathers.static(assetConfig.root, assetConfig))
  }

  // javascript bundler
  const entryFile = getEntryFile(assetConfig)
  const entryPath = join(cwd, entryFile)
  const bundlerHandler = Bundler(entryPath, {
    dirname: cwd
  })
  const compiler = bundlerHandler.compiler
  app.use(bundlerHandler)
  compiler.on('error', (nodeName, edgeName, err) => {
    log.fatal(err)
  })

  return (cb) => {
    return startServer(app, cb)

feathers

Build Better APIs, Faster than Ever.

MIT
Latest version published 7 years ago

Package Health Score

62 / 100
Full package analysis

Popular feathers functions