Mongo Server
  • Introduction
  • Getting started
  • Basics
    • Routing and Queries
    • Restrict endpoints
    • Route logic
    • Default values
    • Input validation and Output Formatting
  • Auth and permissions
    • Login and authentication
    • Permission handling
    • Local authentication
    • Magic Links and codes
  • Automatic Documentation
    • Server description
    • Swagger Docs
  • Miscellaneous
    • Db Seeding
    • Mailing settings
    • Roadmap
    • Population Constrains
Powered by GitBook
On this page

Was this helpful?

  1. Basics

Route logic

Is very likely that you'll want to add custom logic for some endpoints. for those cases you can use the do fields, which is an enhanced version of the express middleware:

module.exports= {
  resources:{
    dogs:{
      get:{
        // notice that could be an async function, and the use of the spread operator
        do: async ({req, res, next, db, user, resources})=>{
          // custom logic here
          return next() // ensure to throw an error or call next, like a normal express middleware
        }
      }
    }
  }
}
PreviousRestrict endpointsNextDefault values

Last updated 5 years ago

Was this helpful?