Skip to content

Instantly share code, notes, and snippets.

@Cerwyn
Created January 2, 2022 12:53
Show Gist options
  • Save Cerwyn/3560bde1f6b1a14adbb6db21fca95414 to your computer and use it in GitHub Desktop.
Save Cerwyn/3560bde1f6b1a14adbb6db21fca95414 to your computer and use it in GitHub Desktop.
Adonis-Vue3
/*
|--------------------------------------------------------------------------
| Routes
|--------------------------------------------------------------------------
|
| This file is dedicated for defining HTTP routes. A single file is enough
| for majority of projects, however you can define routes in different
| files and just make sure to import them inside this file. For example
|
| Define routes in following two files
| ├── start/routes/cart.ts
| ├── start/routes/customer.ts
|
| and then import them inside `start/routes.ts` as follows
|
| import './routes/cart'
| import './routes/customer''
|
*/
import Route from '@ioc:Adonis/Core/Route'
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
// A typical route handler
Route.get('/', async ({ view }: HttpContextContract) => {
return view.render('index')
}).as('index')
/* A catch-all route handler. If a user hits the address http://example.com/a-route-that-does-not-exist directly in the browser, then our Vue.js app will mount, and routing will be delegated to vue-router.
*/
Route.get('*', async ({ view }: HttpContextContract) => {
return view.render('index')
}).as('not_found')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment