# 快速上手

本文主要介绍从初识飞布到快速了解飞布功能从而搭建第一个API并有效访问的完整流程。

## 前置知识

### 公共知识

* GraphQL：了解什么是GraphQL，掌握基本概念就行，推荐教程 [前往](https://graphql.cn/learn/)
* Prisma ORM：了解Prisma的基本函数签名，推荐教程 [前往](https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#findunique)

## 快速使用

简单使用，只需要观看本视频即可，后面内容可忽略。

{% embed url="<https://www.bilibili.com/video/BV1rM411u7e8>" %}
01入门教程-如何快速上手飞布？
{% endembed %}

## 环境准备

{% embed url="<https://www.bilibili.com/video/BV1mo4y1B78g>" %}
00功能介绍-如何安装或升级飞布？
{% endembed %}

### 在线体验

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/new/#https://github.com/fireboomio/init-todo)

> [gitpod 介绍](https://juejin.cn/post/6844903773878386701)：Gitpod是一个在线IDE，可以从任何GitHub页面启动。在几秒钟之内，Gitpod就可以为您提供一个完整的开发环境，包括一个VS Code驱动的IDE和一个可以由项目定制化配置的云Linux容器。

{% hint style="info" %}
启动成功后，在 gitpod 底部切换到`PORTS`面板，选择 `9123` 端口打开即可
{% endhint %}

### Docker运行

<pre class="language-bash"><code class="lang-bash"><strong># 开发模式运行
</strong>docker run -it -p 9123:9123 -p 9991:9991 fireboomapi/fireboom_server:latest dev 
</code></pre>

打开控制面板，使用如下地址进行访问：

<http://localhost:9123>

### 本地安装

#### 脚本安装

{% hint style="info" %}
如果你使用的是Windows系统，建议使用 Git bash 执行脚本，或者在`MSYS2`等环境下执行脚本，不支持在`CMD`或者`PowerShell`终端中执行
{% endhint %}

```bash
curl -fsSL fireboom.io/install | bash -s project-name -t init-todo --cn
```

* 项目名称：`project-name`，可根据需求修改
* 初始化模板：`-t init-todo`，省略后默认创建空项目
* 选择源：`--cn` ，指定从国内源下载，省略后从 github源下载

{% hint style="info" %}
飞布采用golang语言编写，上述版本基于golang的跨平台编译构建。如果你的操作系统不在上述列表，请[联系我们](https://github.com/fireboomio/product-manual/discussions)兼容。
{% endhint %}

**模板列表：**

* [init-todo](https://github.com/fireboomio/init-todo)： 基础模板，只涉及 [OPERATION](https://docs.fireboom.io/he-xin-gai-nian/graphql#graphql-operation) ，不涉及钩子编写
* init-hooks：钩子模板，提供 golang 和 nodejs 的示例 （inprocess）

#### 升级飞布

```bash
# 升级飞布命令行
# cd project-name
curl -fsSL fireboom.io/update | bash
```

### 运行飞布

```shell
# 开发环境
# cd project-name
./fireboom dev
```

启动成功日志：

```
⇨ http server started on [::]:9123
```

打开控制面板

<http://localhost:9123>

### 高级特性

如果你要使用钩子等高级特性，则需要掌握一种后端开发语言。

如果你是前端开发者，推荐：

* TypeScript：了解node.js并熟悉TypeScript语法，推荐教程 [前往](https://typescript.bootcss.com/tutorials/typescript-in-5-minutes.html)

如果你是后端开发者，推荐：

* Golang：了解Golang基本语法即可，推荐教程 [前往](https://www.runoob.com/go/go-tutorial.html)

## 下一步

### 学习教程

体验fireboom更多特性，可前往B站查看完整教学视频，[前往](https://space.bilibili.com/3493080529373820)。

### 数据库操作

* [数据库建模](/ji-chu-ke-shi-hua-kai-fa/shu-ju-yuan/shu-ju-ku/shu-ju-jian-mo.md)：学习如何使用飞布建模数据库，参考[prisma文档](https://prisma.yoga/concepts/components/prisma-schema/data-model)
* [数据库CRUD](/ji-chu-ke-shi-hua-kai-fa/gai-lan/jie-mian-gai-lan/ke-shi-hua-kai-fa.md#chao-tu-schema-mian-ban)：了解数据库表结构和graphql的映射关系，参考[prisma文档](https://prisma.yoga/concepts/components/prisma-client/crud) 。

### 业务逻辑

实现自定义业务逻辑有几种不同的选项，具体取决于你的用例。

* [API钩子](/jin-jie-gou-zi-ji-zhi/gou-zi-ji-zhi.md)：在请求API的生命周期中，插入代码，以更改或扩展API行为，例如用户新建文章后，通过后置钩子发送邮件通知管理员审核。
* API数据源：除数据库外，飞布支持集成[REST API](/ji-chu-ke-shi-hua-kai-fa/shu-ju-yuan/rest-api.md)和[GraphQL API](/ji-chu-ke-shi-hua-kai-fa/shu-ju-yuan/graphql-api.md)，开发者可以自行用喜欢的方式实现自定义逻辑的API，但无需考虑权限问题。飞布此时变身API网关，作为BFF层对外提供接口。
* [自定义数据源](https://github.com/fireboomio/product-manual/blob/v2.0/kuai-su-ru-men/kuai-su-shang-shou/broken-reference/README.md)：飞布还内置了自定义数据源，开发者可以直接编写脚本扩展逻辑。它本质上也是一个GraphQL API。
* [组合式API](/jin-jie-gou-zi-ji-zhi/han-shu-gou-zi/zu-he-shi-api.md)：适用于复杂业务逻辑的构建，当前只支持TS hooks。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fireboom.io/kuai-su-ru-men/kuai-su-shang-shou.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
