How to use the @feathersjs/feathers function in @feathersjs/feathers

To help you get started, we’ve selected a few @feathersjs/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 feathers-plus / generator-feathers-plus / test-expands / ts-cumulative-1-generic.test-expected / src1 / app.ts View on Github external
import configuration from '@feathersjs/configuration';
import express from '@feathersjs/express';
import socketio from '@feathersjs/socketio';

import middleware from './middleware';
import services from './services';
import appHooks from './app.hooks';
import channels from './channels';
// tslint:disable-next-line
const generatorSpecs = require('../feathers-gen-specs.json');
import authentication from './authentication';

// !code: imports // !end
// !code: init // !end

const app = express(feathers());
// !code: use_start // !end

// Load app configuration
app.configure(configuration());
// ! code: init_config
app.set('generatorSpecs', generatorSpecs);
// !end

// Enable security, CORS, compression, favicon and body parsing
app.use(helmet(
  // !code: helmet_config // !end
));
app.use(cors(
  // !code: cors_config // !end
));
app.use(compress(
github nothingismagick / quasar-starter-ssr-pwa-jest-cypress / src / api / feathers.js View on Github external
import Vue from 'vue'
import createApplication from '@feathersjs/feathers'
import socketio from '@feathersjs/socketio-client'
import authentication from '@feathersjs/authentication-client'
import io from 'socket.io-client'

const socket = io(process.env.API_BASE_URL, {
  transports: ['websocket']
})
const feathers = createApplication()

feathers.configure(socketio(socket))

if (typeof window !== 'undefined') {

  feathers.configure(authentication({
    header: 'Authorization', // the default authorization header for REST
    path: '/api/authentication', // the server-side authentication service path
    jwtStrategy: 'jwt', // the name of the JWT authentication strategy
    entity: 'user', // the entity you are authenticating (ie. a users)
    service: 'users', // the service to look up the entity
    cookie: 'feathers-jwt', // the name of the cookie to parse the JWT from when cookies are enabled server side
    storageKey: 'feathers-jwt', // the key to store the accessToken in localstorage or AsyncStorage on React Native
    storage: window.localStorage // Passing a WebStorage-compatible object to enable automatic storage on the client.
  }))
} else {
github kalisio / krawler / src / cli.js View on Github external
export async function createApp (job, options = {}) {
  debug('Initializing krawler application')
  app = express(feathers())
  // Enable CORS, security, compression, and body parsing
  app.use(cors())
  app.use(helmet())
  app.use(compress())
  app.use(bodyParser.json())
  app.use(bodyParser.urlencoded({ extended: true }))

  const apiPrefix = (options.api ? options.apiPrefix : '')
  debug('API prefix ' + apiPrefix)
  app.configure(rest())
  app.configure(socketio({
    path: apiPrefix + 'ws',
    transports: ['websocket']
  }))
  // Env var can be overridden by option
  const sync = options.sync || process.env.SYNC_DB_URL
github feathersjs-ecosystem / feathers-objection / example / app.js View on Github external
import createModel from './todo'

// Initialize Knex
const knex = require('knex')({
  client: 'sqlite3',
  connection: {
    filename: './db.sqlite'
  },
  useNullAsDefault: false
})

// Bind Objection.js
Model.knex(knex)

// Create a feathers instance.
const app = express(feathers())
  // Enable REST services
  .configure(rest())
  // Turn on JSON parser for REST services
  .use(bodyParser.json())
  // Turn on URL-encoded parser for REST services
  .use(bodyParser.urlencoded({ extended: true }))

app.set('knex', knex)

// Create service
app.use('/todos', createService({
  model: createModel(app),
  id: 'id',
  paginate: {
    default: 2,
    max: 4
github feathers-nuxt / template-app / template / src / client / utils / initClient.js View on Github external
export default async function(ctx) {
  // initialize feathers rest client
  if(process.client) { // on browser pocess only

    const { app, nuxtState } = ctx
    const { protocol, host, port } = nuxtState.config
    const storage = window.localStorage

    const feathersClient = feathers()

    feathersClient.hooks(hooks)
    feathersClient.configure(rest(`${protocol}://${host}:${port}/api`).axios(app.$axios))
    feathersClient.configure(authentication({ storage, service: 'logins', jwtStrategy: 'jwt', path: '/authentication' }))

    // automatically logout once jwt expires
    feathersClient.on('authenticated', ({user}) => setTimeout(feathersClient.logout, ( new Date(user.validTill) - Date.now() )) )

    // automatically navigate to login page after logout
    feathersClient.on('logout', () => app.router.push({ path: '/' })  )

    const deleteCookie = (name) => document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;'
    
    // logout if token invalidated
    if(app.store.state.auth.errorOnAuthenticate) {
      feathersClient.logout().then(() => {
github autoai-org / AID / components / discovery / src / app.ts View on Github external
import cors from 'cors';
import feathers from '@feathersjs/feathers';
import configuration from '@feathersjs/configuration';
import express from '@feathersjs/express';
import { Application } from './declarations';
import logger from './logger';
import middleware from './middleware';
import services from './services';
import appHooks from './app.hooks';
import channels from './channels';
import authentication from './authentication';
import mongoose from './mongoose';

// Don't remove this comment. It's needed to format import lines nicely.

const app: Application = express(feathers());

// Load app configuration
app.configure(configuration());
// Enable security, CORS, compression, favicon and body parsing
app.use(helmet());
app.use(cors());
app.use(compress());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(favicon(path.join(app.get('public'), 'favicon.ico')));
// Host the public folder
app.use('/', express.static(app.get('public')));

// Set up Plugins and providers
app.configure(express.rest());
github thosakwe / feathers-seeder / test / callback.js View on Github external
it('can nest config', done => {
    const app = feathers();
    app.use('/albums', memory());
    app.use('/songs', memory());

    app.use('/albums/:albumId/songs', {
      find(params) {
        console.log(`Searching for songs from album #${params.albumId}...`);
        return app.service('songs').find({
          query: {
            albumId: params.albumId
          }
        });
      },

      create(data, params) {
        const songData = Object.assign(data, {
          albumId: params.albumId
github silvestreh / feathers-nuxt / client / feathers-client.js View on Github external
import feathers from '@feathersjs/feathers';
import socketio from '@feathersjs/socketio-client';
import auth from '@feathersjs/authentication-client';
import io from 'socket.io-client';
import { CookieStorage } from 'cookie-storage'

const storage = new CookieStorage();
const socket = io(process.env.apiURL, { transports: ['websocket'] });
const app = feathers()
  .configure(socketio(socket))
  .configure(auth({ storage }));

export default app;
github petermikitsh / myethereumapp / src / server / app.js View on Github external
function makeApp() {
  const app = express(feathers());

  app.get(`/client-${__GIT_SHA__}.js`, (req, res) => {
    res.setHeader('Cache-Control', 'public, max-age=31536000');
    res.setHeader('content-type', 'application/javascript');
    res.send(__CLIENT_JS__);
  });

  app.get(`/client-${__GIT_SHA__}.css`, (req, res) => {
    res.setHeader('Cache-Control', 'public, max-age=31536000');
    res.setHeader('content-type', 'text/css');
    res.send(__CLIENT_CSS__);
  });

  app
    .use(bodyParser.json())
    .use(bodyParser.urlencoded({ extended: true }))

@feathersjs/feathers

A framework for real-time applications and REST API with JavaScript and TypeScript

MIT
Latest version published 2 months ago

Package Health Score

92 / 100
Full package analysis