Backends
EdgeOne Makers provides premium support for mainstream backend frameworks, aiming to optimize your backend development and runtime experience. In most cases, you can complete deployment without any additional configuration.
Express | Koa | MySQL |
| | |
Express/Koa framework:
ALL routing services are consolidated in a function file, and the file name must be in [[]] format, such as [[default]].js.
No need to start up an HTTP Server or set port listening.
The framework instance must be exported, otherwise the builder will not recognize it as a function
export default app.Express.js
Express.js is a Node.js-based Web application framework that provides a series of powerful features to build single-page, multi-page, and composite Web applications. It is known for its flexibility and minimalistic features, allowing developers free choice of components based on project requirements.
Refer to the following example to quickly create an Express.js app:
// ./node-functions/express/[[default]].js// No need to start up an HTTP Serverimport express from "express";const app = express();app.use((req, res, next) => {console.log(`[Log] ${req.method} ${req.url}`);next();});app.get("/", (req, res) => {res.json({ message: "Hello from Express on Node Functions!" });});// The express instance must be exported, otherwise the builder will not recognize it as a functionexport default app;
Ensure all dependencies are installed before deployment, and use edgeo
dev for local development and testing.Koa.js
Koa.js is a next-generation Node.js Web framework developed by the Express team. It leverages async/await grammar to handle asynchronous operations via middleware in a more elegant way, thereby achieving more concise and expressive code. Koa.js is more lightweight, not bundled with any middleware, and provides larger freedom.
Refer to the following example to quickly create a Koa.js app:
// ./node-functions/koa/[[default]].jsimport Koa from 'koa';import Router from '@koa/router';const app = new Koa();const router = new Router();app.use(async (ctx, next) => {const start = Date.now();await next();const ms = Date.now() - start;ctx.set('X-Response-Time', `${ms}ms`);});router.get('/', async (ctx) => {ctx.body = { message: 'Hello from Koa on Node Functions!' };});app.use(router.routes());app.use(router.allowedMethods());// The express instance must be exported, otherwise the builder will not recognize it as a functionexport default app;
Koa.js is suitable for backend services that require high customization and performance. Before deployment, ensure all dependencies are installed and use
edgeone makers dev for local development and testing.
