forked from nuxt/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add server-routes example (nuxt#4301)
- Loading branch information
Showing
13 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
template: Example | ||
--- | ||
|
||
# Server Routes | ||
|
||
This example shows how to create server routes inside a `server/api` directory. | ||
|
||
::ReadMore{link="/guide/features/server-routes"} | ||
:: | ||
|
||
::sandbox{repo="nuxt/framework" branch="main" dir="examples/server/routes" file="app.vue"} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<template> | ||
<NuxtExampleLayout example="server/routes"> | ||
<p>Fetched from <pre>/api/mountain</pre>: {{ mountain }}</p> | ||
</NuxtExampleLayout> | ||
</template> | ||
|
||
<script setup> | ||
const { data: mountain } = await useFetch('/api/mountain') | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineNuxtConfig } from 'nuxt3' | ||
|
||
export default defineNuxtConfig({ | ||
modules: [ | ||
'@nuxt/ui' | ||
] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "example-server-routes", | ||
"private": true, | ||
"scripts": { | ||
"build": "nuxi build", | ||
"dev": "nuxi dev", | ||
"start": "nuxi preview" | ||
}, | ||
"devDependencies": { | ||
"@nuxt/ui": "npm:@nuxt/ui-edge@latest", | ||
"nuxt3": "latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export default defineEventHandler(() => { | ||
return { | ||
title: 'Mount Everest', | ||
description: "Mount Everest is Earth's highest mountain above sea level, located in the Mahalangur Himal sub-range of the Himalayas. The China–Nepal border runs across its summit point", | ||
height: '8,848 m', | ||
countries: [ | ||
'China', | ||
'Nepal' | ||
], | ||
continent: 'Asia', | ||
image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Everest_kalapatthar.jpg/600px-Everest_kalapatthar.jpg', | ||
dir: '/mountains', | ||
path: '/mountains/mount-everest', | ||
slug: 'mount-everest', | ||
updatedAt: '2020-12-11T15:40:35.000Z' | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "./.nuxt/tsconfig.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters