Skip to main content

后端定制:使用 FoodAdvisor 的示例秘诀

¥Backend customization: An examples cookbook using FoodAdvisor

本文档的当前部分面向希望更深入了解 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.

示例旨在扩展官方 Strapi 演示应用 FoodAdvisor 的功能。FoodAdvisor 构建一个由 Strapi 后端(包含在 /api 文件夹中)提供支持的现成餐馆目录,并渲染一个由 Next.js 提供支持的前端网站(包含在 /client 文件夹中)。

¥Examples are meant to extend the features of FoodAdvisor, the official Strapi demo application. FoodAdvisor builds a ready-made restaurants directory powered by a Strapi back end (included in the /api folder) and renders a Next.js-powered front-end website (included in the /client folder).

Prerequisites

它可以帮助你使用 内容类型生成器 创建数据结构并通过 内容管理者 添加一些内容,然后通过 API 公开内容。

¥that helps you create a data structure with the Content-Type Builder and add some content through the Content Manager, then exposes the content through APIs.

  • 👀 你已阅读 后端定制介绍 以大致了解 Strapi 中的路由、策略、中间件、控制器和服务。

    ¥👀 You have read the back-end customization introduction to get a general understanding of what routes, policies, middlewares, controllers, and services are in Strapi.

  • 👷 如果你想自己测试和使用代码示例,请确保你已克隆 FoodAdvisor 存储库、设置项目并启动前端和后端服务器。Strapi 管理面板应可从 localhost:1337/admin 访问,并且基于 Next.js 的 FoodAdvisor 前端网站应在 localhost:3000 上运行。

    ¥👷 If you want to test and play with the code examples by yourself, ensure you have cloned the FoodAdvisor repository, setup the project, and started both the front-end and back-end servers. The Strapi admin panel should be accessible from localhost:1337/admin and the Next.js-based FoodAdvisor front-end website should be running on 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 的身份验证流程
如何以及何时使用
自定义控制器和服务
自定义控制器和服务示例
如何使用自定义策略
并发送自定义错误
自定义策略示例
如何配置和使用自定义路由自定义路由示例
如何以及何时使用
自定义全局中间件
自定义中间件示例