feathers-mongoose-casl
Version 2.1.2
Version 2.1.2
  • feathers-mongoose-casl
  • Docs
    • Migrating
    • START A NEW PROJECT
      • Generate a new project.
      • install feathers-mongoose-casl
      • feathers-logger
      • Update config
      • Add mongoose
      • Email service
      • App hooks
      • Import required services
      • Verify user and filter user fields
      • Swagger, Logger, BodyParser
      • Email templates
      • public HTML
      • Run the server
      • Create you first user
      • vs code snippet extension
      • Test Login
      • Dashboard
      • Create a new Service with casl&Dashboard
      • Posts Postman snippet
      • Add Admin role
      • Done!
    • Advanced
      • Security - eslint-plugin-security
      • Security - rate limiting
      • Development tools
    • Guides
      • Throw errors
      • Auth Flow
      • Authentication
      • Authouriztion
      • /me
      • Rules Cache
      • Create a new service
      • Custom service validtor client data
      • validators
        • Example of use
        • Types
        • Mongoose schema
      • Default value
      • $Populate
      • Upload service
      • Upload files
        • Create upload service
        • Sign File After Populate
        • Storage support
          • Google-cloud
      • Error
      • feathers Client examples
      • Dashboard
        • Dashboard Config
          • Field configuration
          • doc Layout
          • custom Fields
            • customElements
        • Online dashboard
        • Add to your react app
      • customized feathers-mongoose-casl/services
      • Redis - in progress
      • S3
      • Postman
      • Swagger
      • debug
    • Production
      • ENV
    • Feathers wiki
      • Good links
    • utils
      • send email example
      • Async For Each
      • Create heroku server
      • pick
      • vs code snippet extension
      • Persist user request
    • Ecosystem
    • TODO
    • Versions updates
Powered by GitBook
On this page

Was this helpful?

  1. Docs
  2. START A NEW PROJECT

Swagger, Logger, BodyParser

1-install dependency

npm i feathers-swagger feathers-logger body-parser --save

2- Add to src/app.js

// 1 - Add this requires 
const bodyParser = require('body-parser');
const swagger = require('feathers-swagger');
const feathersLogger = require('feathers-logger');

// const app = express(feathers());
// 2 - add this lines after const app = express(feathers()):

app.configure(feathersLogger(logger));
app.use(bodyParser.json({limit: '10mb'}));
app.use(bodyParser.urlencoded({limit: '10mb', extended: true }));
// Swagger
if(process.env.NODE_ENV !== 'production'){
  app.configure(swagger({
    docsPath: '/docs',
    uiIndex: true, //path.join(__dirname, 'docs.html'),
    info: {
      title: 'feathersjs-server docs',
      description: 'feathersjs-server api'
    }
  }));
}
const path = require('path');
const favicon = require('serve-favicon');
const compress = require('compression');
const helmet = require('helmet');
const cors = require('cors');
const logger = require('./logger');

const feathers = require('@feathersjs/feathers');
const configuration = require('@feathersjs/configuration');
const express = require('@feathersjs/express');
const socketio = require('@feathersjs/socketio');
const {authentication} = require('feathers-mongoose-casl');

const middleware = require('./middleware');

const services = require('./services');
const appHooks = require('./app.hooks');
const channels = require('./channels');

const mongoose = require('./mongoose');
const bodyParser = require('body-parser');
const swagger = require('feathers-swagger');
var feathersLogger = require('feathers-logger');

const app = express(feathers());

app.configure(feathersLogger(logger));
app.use(bodyParser.json({limit: '10mb'}));
app.use(bodyParser.urlencoded({limit: '10mb', extended: true }));
// Swagger
app.configure(swagger({
  docsPath: '/docs',
  uiIndex: true, //path.join(__dirname, 'docs.html'),
  info: {
    title: 'feathersjs-server docs',
    description: 'feathersjs-server api'
  }   
}));

// 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());
app.configure(socketio());

app.configure(mongoose);

// Configure other middleware (see `middleware/index.js`)
app.configure(middleware);
app.configure(authentication);
// Set up our services (see `services/index.js`)
app.configure(services);
// Set up event channels (see channels.js)
app.configure(channels);

// Configure a middleware for 404s and the error handler
app.use(express.notFound());
app.use(express.errorHandler({ logger }));

app.hooks(appHooks);

module.exports = app;
git add .
git commit -m "add bodyParser to handle files, swagger and feathersLogger"
PreviousVerify user and filter user fieldsNextEmail templates

Last updated 6 years ago

Was this helpful?