Skip to main content

routing

In addition to configuration for building your express 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 'psychic'
export default (r: PsychicRouter) => {
r.namespace('api', (r) => {
r.namespace('v1', (r) => {
r.resources('pets')
})
})
}

GET    api/v1/pets      Api/V1/Pets#index
POST   api/v1/pets      Api/V1/Pets#create
GET    api/v1/pets/:id  Api/V1/Pets#show
PUT    api/v1/pets/:id  Api/V1/Pets#update
PATCH  api/v1/pets/:id  Api/V1/Pets#update
DELETE api/v1/pets/:id  Api/V1/Pets#destroy

The routes API is fairly robust. For more information on available methods, see our routing guides.