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

Cookbook

H1

Cookbook is a documentation tool for Milkio that analyzes your code and generates online documentation based on comments. The request and response sections are automatically inferred, so you don’t need to write any explanations. It is currently in the alpha stage, and in the future, more features will be introduced to Cookbook to help you build your dreams more pleasantly.

For now, Cookbook is still in the early development stage, so there are some bugs and the documentation may not be very detailed. These will be improved in the future. You can currently use it by clicking here.

Usage

In your /src/apps directory, create a new API file named cookbook.ts and enter the following content:

import { defineApi, reject } from "milkio";
import { cwd } from "node:process";
import { join } from "path";
import type typia from "typia";
export const api = defineApi({
meta: {
//
},
async action(params: string, context) {
const password = "Pa$$w0rd!";
if (params !== password) throw reject("BUSINESS_FAIL", "Only with the correct parameters can Cookbook be accessed");
return Bun.file(join(cwd(), "generated", "cookbook.json")).json();
},
});

The password part is used to restrict the exposure of your cookbook.json. You can also freely write your own validation logic or choose not to validate it and make it accessible to anyone.

Open the Cookbook website and click on Edit Connect Config. Paste the following JSON, which is the configuration needed to connect to the API you just created.

{
"Local Origin": {
"cookbook": "http://localhost:9000/cookbook",
"base": "http://localhost:9000/",
"params": "Pa$w0rd!",
"headers": {}
}
}

If everything goes well, you can use Cookbook to read all the documentation for your Milkio.

For now, Cookbook is not yet perfect. If you want to improve it or fix some bugs, you can visit the Cookbook Repository.