# 后端定制示例手册

> Source: https://strapi.nodejs.cn/cms/backend-customization/examples

🌐 Backend customization: An examples cookbook using FoodAdvisor

一本使用 FoodAdvisor 演示应用的真实后端定制示例的烹饪书，演示如何在 Strapi 中实现自定义路由、控制器、服务、策略和中间件。

🌐 A cookbook of real-world backend customization examples using the FoodAdvisor demo application, demonstrating how to implement custom routes, controllers, services, policies, and middlewares in Strapi.

:::callout 🏗 About these examples

这些示例是围绕 [FoodAdvisor](https://github.com/strapi/foodadvisor)构建的，而 [FoodAdvisor](https://github.com/strapi/foodadvisor)不再是Strapi的特色演示应用（它已被 [LaunchPad](https://github.com/strapi/LaunchPad)取代）。这里重要的是理解所展示的后端机制，而不是FoodAdvisor本身。这些页面将被重新访问以使用LaunchPad。

:::

本文档的当前部分面向希望更深入了解 Strapi 后端定制可能性的开发者。

🌐 The present section of the documentation is intended for developers who would like to get a deeper understanding of the Strapi back end customization possibilities.

本节是示例的集合，演示了 Strapi 后端服务器的核心组件如何在实际项目中使用。与后端交互的前端代码也可能是某些示例的一部分，但默认情况下会以折叠块显示，因为前端代码示例并不是本手册的主要关注点。

🌐 The section is a collection of examples that demonstrate how the core components of the back-end server of Strapi can be used in a real-world project. Front-end code that interacts with the back end may also be part of some examples, but displayed in collapsed blocks by default since front-end code examples are not the main focus of this cookbook.

示例旨在扩展 [FoodAdvisor](https://github.com/strapi/foodadvisor)的功能，这是官方的 Strapi 演示应用。FoodAdvisor 构建了一个现成的餐馆目录，由 Strapi 后端驱动（包含在 `/api` 文件夹中），并呈现由  [Next.js](https://next.nodejs.cn/) 驱动的前端网站（包含在 `/client` 文件夹中）。

:::prerequisites

- 👀 你已经阅读了 [快速入门指南](/cms/quick-start) 和/或理解了 Strapi 是一个 **无头 CMS** <Annotation>无头 CMS 是一种将呈现层（即前端，内容展示的地方）与后端（内容管理的地方）分离的内容管理系统。<br /><br/>Strapi 是一个无头 CMS，它提供：<ul><li>一个用于你内容的后端服务器 API，</li><li>以及一个图形用户界面，称为管理面板，用于管理内容。</li></ul>呈现层应由其他框架处理，而不是由 Strapi 处理。 它帮助你通过 [内容类型构建器](/cms/features/content-type-builder) 创建内容结构，并通过 [内容管理器](/cms/features/content-manager) 添加一些内容，然后通过 API 公开内容。
- 👀 你已经阅读了[后端自定义介绍](/cms/backend-customization)，以便对 Strapi 中的路由、策略、中间件、控制器和服务有一个大致的了解。
- 👷 如果你想自己测试和玩这些代码示例，请确保你已经克隆了 [FoodAdvisor](https://github.com/strapi/foodadvisor) 仓库，设置了项目，并启动了前端和后端服务器。Strapi 管理面板应该可以从 [`localhost:1337/admin`](http://localhost:1337/admin) 访问，而基于 Next.js 的 FoodAdvisor 前端网站应该在 [`localhost:3000`](http://localhost:3000) 运行。

:::

你可以从头到尾阅读本节，或者你可能想直接跳转到特定页面以了解如何使用 Strapi 后端的给定核心元素来解决实际用例示例：

🌐 This section can be read from start to finish, or you might want to jump directly to a specific page to understand how a given core element from the Strapi back end can be used to solve a real-world use case example:

| 我想了解… | 专用页面 |
|------------|---------------|
| 如何验证我的查询 | [使用 JWT 的身份验证流程](/cms/backend-customization/examples/authentication) |
| 如何以及何时使用<br />自定义控制器和服务 | [自定义控制器和服务示例](/cms/backend-customization/examples/services-and-controllers) |
| 如何使用自定义策略<br />并发送自定义错误 | [自定义策略示例](/cms/backend-customization/examples/policies) |
| 如何配置和使用自定义路由 | [自定义路由示例](/cms/backend-customization/examples/routes) |
| 如何以及何时使用<br />自定义全局中间件 | [自定义中间件示例](/cms/backend-customization/examples/middlewares) |
