Files that declare API routes under the BFF Framework Mode. Except for convention files, files under the lambda/ directory will be registered as the routes.
Using the api directory requires enabling the BFF function, and you need to run the new command to enable the "BFF" function under the project.
This file supports using js or ts language, but must export functions using esm syntax.
The routing system will map files named index to the previous directory.
api/lambda/index.ts -> $BASENAME/api/lambda/user/index.ts -> $BASENAME/userThe routing system also supports parsing nested files. If you create a nested folder structure, the files will still automatically resolve routes in the same way.
api/lambda/hello.ts -> $BASENAME/helloapi/lambda/user/list.ts -> $BASENAME/user/listThe routing system supports generating dynamic routes through file directories named with [].
api/lambda/user/[username]/info.ts -> $BASENAME/user/:username/infoapi/lambda/user/[username]/delete.ts -> $BASENAME/user/:username/deleteapi/lambda/article/[id]/info.ts -> $BASENAME/article/:id/infoThe $BASENAME can be configured in modern.config.js, and the default value is /api.
By default, all files in the lambda directory are parsed as BFF function files, but we also set up a whitelist so that these files are not parsed:
_. For example: _utils.ts._. For example: _utils/index.ts, _utils/cp.ts.foo.test.ts.hello.d.ts.node_module.Completely consistent with the Function Definition under the function mode.