Skip to main content

routing

In addition to configuration for building your Koa app, a separate configuration file is provided to configure the routing mechanism provided by Psychic. This file is located at conf/routes.ts:

// conf/routes.ts
import { PsychicRouter } from '@rvoh/psychic'
export default (r: PsychicRouter) => {
r.namespace('v1', r => {
r.namespace('host', r => {
r.resources('places')
})
})
}

GET    v1/host/places      V1/Host/Places#index
POST   v1/host/places      V1/Host/Places#create
GET    v1/host/places/:id  V1/Host/Places#show
PUT    v1/host/places/:id  V1/Host/Places#update
PATCH  v1/host/places/:id  V1/Host/Places#update
DELETE v1/host/places/:id  V1/Host/Places#destroy

The routes API is quite robust. For more information on available methods, and on how the top-level namespace you choose (v1/, admin/, webhooks/, ...) doubles as your auth architecture, see the routing guides and the controller guides.