Skip to content

Instantly share code, notes, and snippets.

@nemrosim
Created April 7, 2020 09:01
Show Gist options
  • Save nemrosim/8401397dcb91b984a4ae514cbb0fe090 to your computer and use it in GitHub Desktop.
Save nemrosim/8401397dcb91b984a4ae514cbb0fe090 to your computer and use it in GitHub Desktop.
refactored routes
const Route = use('Route');
const { ROUTES, CONTROLLERS } = require('../../constants/routes');
Route
.group(() => {
Route
.resource(ROUTES.ADDRESSES, CONTROLLERS.ADDRESSES)
.middleware('auth')
.apiOnly();
Route
.get(`${ROUTES.ADDRESSES}/current`, `${CONTROLLERS.ADDRESSES}.addressOfCurrentUser`)
.middleware('auth')
.formats(['json']);
Route
.get(`${ROUTES.ADDRESSES}/user/:id`, `${CONTROLLERS.ADDRESSES}.findByUserId`)
.middleware('auth')
.formats(['json']);
Route
.delete(`${ROUTES.ADDRESSES}/user/:id`, `${CONTROLLERS.ADDRESSES}.deleteByUserId`)
.middleware('auth')
.formats(['json']);
})
.prefix('api/v1/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment