How to use the @feathersjs/express/rest function in @feathersjs/express

To help you get started, we’ve selected a few @feathersjs/express 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 / 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
  if (sync) {
    app.sync = mubsub(sync)
    const channel = app.sync.channel('krawler-events')
    app.on('krawler', (event) => {
      channel.publish(event.name, event.data)
    })
  }
  app.configure(plugin())
  // In API mode everything is open, otherwise only health check is
  app.use('/', (req, res, next) => {
github feathersjs-ecosystem / feathers-objection / example / app.js View on Github external
// 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
  }
}))