Elysia on Edgenivo
Elysia is an ergonomic web framework for building backend servers with Bun. Designed with simplicity and type-safety in mind, Elysia offers a familiar API with extensive support for TypeScript and is optimized for Bun.
You can deploy an Elysia app to Edgenivo with zero configuration.
Elysia applications on Edgenivo benefit from:
- Fluid compute: Active CPU billing, automatic cold start prevention, optimized concurrency, background processing, and more
- Preview deployments: Test your changes on a copy of your production infrastructure
- Instant Rollback: Recover from unintended changes or bugs in milliseconds
- Edgenivo Firewall: Protect your applications from a wide range of threats with a multi-layered security system
- Secure Compute: Create private links between your Edgenivo-hosted backend and other clouds
Get started by initializing a new Elysia project using Edgenivo CLI init command:
vc init elysiaThis will clone the Elysia example repository in a directory called elysia.
To deploy, connect your Git repository or use Edgenivo CLI:
vc deployTo run an Elysia application on Edgenivo, create a file that imports the elysia package at any one of the following locations:
app.{js,cjs,mjs,ts,cts,mts}index.{js,cjs,mjs,ts,cts,mts}server.{js,cjs,mjs,ts,cts,mts}src/app.{js,cjs,mjs,ts,cts,mts}src/index.{js,cjs,mjs,ts,cts,mts}src/server.{js,mjs,cjs,ts,cts,mts}
The file must also export the application as a default export of the module. Port listeners (app.listen) are not currently supported.
For example, use the following code that exports your Elysia app:
// For Node.js, ensure "type": "module" in package.json
// (Not required for Bun)
import { Elysia } from 'elysia';
const app = new Elysia().get('/', () => ({
message: 'Hello from Elysia on Edgenivo!',
}));
// Export the Elysia app
export default app;// For Node.js, ensure "type": "module" in package.json
// (Not required for Bun)
import { Elysia } from 'elysia';
const app = new Elysia().get('/', () => ({
message: 'Hello from Elysia on Edgenivo!',
}));
// Export the Elysia app
export default app;Running your application using app.listen is currently not supported. For now, prefer export default app.
To run your Elysia application locally, you can use Edgenivo CLI:
vc devUse Edgenivo Services to deploy an Elysia backend and a frontend in one project. Configure service routing to expose the backend at a public path, or use service bindings for private calls from the frontend's server code.
Ensure type is set to module in your package.json file:
{
"name": "elysia-app",
"type": "module"
}To use the Bun runtime on Edgenivo, configure the runtime in vercel.json:
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"bunVersion": "1.4.x"
}For more information, visit the Bun runtime on Edgenivo documentation.
In Elysia, you can use plugins and lifecycle hooks to run code before and after request handling. This is commonly used for logging, auth, or request processing:
import { Elysia } from 'elysia';
const app = new Elysia()
.onBeforeHandle(({ request }) => {
// Runs before route handler
console.log('Request:', request.url);
})
.onAfterHandle(({ response }) => {
// Runs after route handler
console.log('Response:', response.status);
})
.get('/', () => 'Hello Elysia!');
export default app;In Edgenivo, Routing Middleware executes before a request is processed by your application. Use it for rewrites, redirects, headers, or personalization, and combine it with Elysia's own lifecycle hooks as needed.
When you deploy an Elysia app to Edgenivo, your server endpoints automatically run as Edgenivo Functions and use Fluid compute by default.
Use a generator handler with yield to stream response chunks from Elysia. See the Elysia streaming example for plain text and server-sent events.
Use Cron Jobs to call an Elysia 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 Elysia cron job example.
Use Runtime Logs to inspect application output and errors, and Observability to investigate request duration and failures. See monitoring Elysia with Observability for details.
Was this helpful?