To Forget
In Milkio, we have ingeniously encapsulated the complexity of past developments. If you are an experienced developer, it may cause confusion as some of your experiences may not be applicable in Milkio. Please forget about them and enjoy the better way that Milkio provides for you!
This section primarily addresses common doubts and misconceptions for experienced developers who are new to Milkio. If you are a beginner and find some of the content below confusing, don’t be discouraged. This is actually a good thing, as one of Milkio’s design goals is to prevent beginners from having to spend effort learning outdated knowledge. You can skip this part.
Use VS Code Extension to Start an HTTP Server
The VS Code extension for Milkio is essential. To facilitate cross-runtime and provide a better development experience, Milkio has integrated features such as automatic reloading and automatic execution of the build phase into the VS Code extension. This means that after running bun dev
, changes to your code will not take effect automatically because the VS Code extension is not involved during this period. Therefore, please forget about the tedious process of opening a terminal and typing bun dev
to start the project. Instead, click a few times in VS Code.
When Accessing the Server, Do Not Use Fetch or Axios Directly
Each Milkio project has its own client package. By installing this package, the client can have full auto-completion and code hints, and can share types with the backend. Directly using Fetch or Axios to send requests will lose all these benefits.
Therefore, please be sure to use the client package of your Milkio project instead of directly using Fetch or Axios.
No HTTP Methods and form-data/urlencoded
In Milkio, there is no distinction between HTTP methods, or rather, all APIs are POST methods. At the same time, Milkio also does not have parameter passing methods like form-data or urlencoded, which is to achieve type safety, as form-data and urlencoded cannot preserve type information.
Therefore, please do not use form-data or urlencoded to pass data. Milkio is compatible with JSON and has expanded more types and file transfer capabilities on top of JSON. See TSON.
Test-Driven Development, Do Not Use Postman
In Milkio, you should not use tools like Postman to debug/test your APIs. You should use the built-in testing features of Milkio. You should use Milkio’s testing features to debug your API while it’s being developed, and after debugging, summarize it into a test case. This way, you can avoid redefining your API in Postman and miss out on the benefits of type safety. Milkio has the Cookbook, which can automatically generate documentation for you, so you no longer need to use tools like Postman.