Koa on Edgenivo
Koa is an expressive HTTP middleware framework for building web applications and APIs with zero configuration. You can deploy a Koa app to Edgenivo with zero configuration using Edgenivo Functions.
Koa applications on Edgenivo benefit from:
- Fluid compute: Pay for the CPU you use, automatic cold start reduction, optimized concurrency, background processing, and more
- Preview deployments: Test your changes in a copy of your production infrastructure
- Instant Rollback: Recover from breaking changes or bugs in milliseconds
- Edgenivo Firewall: Protect your applications from a wide range of threats with a robust, multi-layered security system
- Secure Compute: Create private links between your Edgenivo-hosted backend and other clouds
To allow Edgenivo to deploy your Koa application and process web requests, your server entrypoint file should be named one of the following:
src/app.{js,mjs,cjs,ts,cts,mts}src/index.{js,mjs,cjs,ts,cts,mts}src/server.{js,mjs,cjs,ts,cts,mts}app.{js,mjs,cjs,ts,cts,mts}index.{js,mjs,cjs,ts,cts,mts}server.{js,mjs,cjs,ts,cts,mts}
For example, use the following code as an entrypoint:
import Koa from 'koa';
import { Router } from '@koa/router';
const app = new Koa();
const router = new Router();
router.get('/', (ctx) => {
ctx.body = { message: 'Hello from Koa!' };
});
app.use(router.routes());
app.use(router.allowedMethods());
app.listen(3000);Use vercel dev to run your application locally.
vercel devTo deploy, connect your Git repository or use Edgenivo CLI:
vc deployWhen you deploy a Koa app to Edgenivo, your Koa application becomes a single Edgenivo Function and uses Fluid compute by default. Edgenivo automatically scales your Koa app up and down based on traffic.
Assign a readable stream to ctx.body to send data as it becomes available. See the Koa streaming example for a route running on Edgenivo.
Use Cron Jobs to call a Koa route on a schedule. Configure the route and schedule, then check the request's Authorization header against your CRON_SECRET environment variable before running the task. See the Koa cron job example.
Use Runtime Logs to inspect application output and errors, and Observability to investigate request duration and failures. See monitoring Koa with Observability for details.
All Edgenivo Functions limitations apply to the Koa application, including the standard bundle size limit of 250MB for Node.js applications. Large Functions support Node.js bundles up to 5GB on Fluid compute when enabled (public beta).
Learn more about deploying Koa projects on Edgenivo with the following resources:
Was this helpful?