Skip to content
当前有符合你浏览器所设置语言的版本,是否前往zh-CN版本的网站?
There is a version suitable for your browser's language settings. Would you like to go to the zh-CN language of the site?
HomeDocument

Install

H1

Every story has a grand prologue, and starting a new project with Milkio is no exception.

Install

By running it and answering a few questions, you can obtain a new Milkio project.

Terminal window
bun create milkio

Running

Open your Milkio project directory using VS Code, or add it to your VS Code workspace.

Now, Milkio is running on port 9000! You can send a POST request with your name to greet the world!

Terminal window
# For Linux or MacOS: You can use curl to quickly send a request
curl --request POST 'http://localhost:9000/hello-world/say' --data-raw '{"by":"milkio"}'
Terminal window
# For Windows: You can use Invoke-WebRequest to quickly send a request
Invoke-WebRequest -Uri "http://localhost:9000/hello-world/say" -Method Post -Body '{"by":"milkio"}'

API Testing

In the VS Code Explorer panel, open the /src/apps/hello-world/say.ts file to see its source code.

The code is divided into two parts, the action method executed when accessing the API above, and the test of the API below. You can write the logic of your API above and write the corresponding test code below.

/src/apps/hello-world/say.ts
export const test = defineApiTest(api, [
{
name: "Basic", // Test name
handler: async (test) => {
const result = await test.execute({ params: { by: "milkio" } });
if (!result.success) return test.reject(`The result was not success`);
},
},
]);

Client

Milkio can share types with clients and provides auto-completion and code hints. How to get started?

What’s Next?

Now that you have successfully created a Milkio project and understand the basic development pattern of Milkio, we recommend that you read the Essentials section and then explore the parts you are interested in.

If you are an experienced developer who has been using at least one other backend framework before, please read the To Forget chapter, which can help you avoid some confusion while learning Milkio.