cdless
v0.2.1
Published
<img width="50" height="50" alt="codeless-c" src="https://github.com/user-attachments/assets/d71305b3-8588-4624-928d-42ad88574b9d" />
Readme
cdless
Instant serverless functions — no setup, no servers, no dependencies.
cdless lets anyone create and run powerful serverless functions instantly, without writing a single line of code. Just describe what you want, or pick from the library, and it works.
Install
npm install cdlessQuick Start
import cdless from 'cdless';
const echo = cdless('util/echo');
const result = await echo({ hello: 'world' });
console.log(result); // { hello: 'world' }All cdless functions live on the edge by default
This means that we can call the same util/echo function using a simple curl command:
curl -X POST https://cdless.com/@cdless/util/[email protected] \
-H "Content-Type: application/json" \
-d '{ "hello": "world" }'This same behavior applies to all functions, whether official or user-scoped.
Core Concepts
1. Edge-First Execution
All functions run on the global edge network by default.
const chat = cdless('ai/chat'); // runs on edge
const uuid = cdless('util/uuid'); // runs on edge2. No Installs Required
Functions are versioned, cached, and executed instantly via CDN.
cdless('util/[email protected]') // pinned version
cdless('util/uuid@latest') // latest stable3. Official Standard Library
Top-level scoped functions are official, curated, and maintained by cdless.
cdless('ai/chat')
cdless('util/echo')
cdless('http/fetch')4. User & Org Functions
Your functions live under your username or org.
cdless('@Marak/triforce')
cdless('@acme/analytics')SDK API
cdless(name: string, options?: { mode?: 'edge' | 'local' // default: 'edge' })
Examples
// Official function const chat = cdless('ai/chat'); let response = await chat({ content: "Hello, world!" });
// User scoped function const triforce = cdless('@Marak/triforce'); let svg = await triforce({ size: 100 });
// Pinned version const uuid = cdless('util/[email protected]'); let id = await uuid();
// Local execution (rare) const echo = cdless('util/echo', { mode: 'local' }); let msg = await echo({ hello: "world" });
Function URLs
All functions are accessible via CDN:
https://cdless.com/{scope}/{name}@{version}.js
Examples:
- https://cdless.com/util/[email protected]
- https://cdless.com/@Marak/triforce
Publish Your Own
- Go to cdless.com
- Write a function
- Deploy instantly
- Use it anywhere
Codeless Function this.ctx Context
When writing functions for cdless, you have access to a special this.ctx object that provides useful utilities and information about the execution context.
this.ctx.env
Access environment variables set in the cdless dashboard or API
const apiKey = this.ctx.env.API_KEY;this.ctx.import
Dynamically import another cdless function
const randomBytes = this.ctx.import('crypto/randomBytes');
const { encoding, data } = await randomBytes({ size });this.ctx.request
Access the original request object
const userAgent = this.ctx.request.headers.get('User-Agent');this.ctx.request.geo
Access geo-location information about the request
const geo = this.ctx.request.geo;this.ctx.state
Access stateful storage (Durable Object)
await this.ctx.state.put('count', 1);
const count = await this.ctx.state.get('count');this.ctx.params
Same as the function's input parameters, copied for convenience
const { url, width, height } = this.ctx.params;this.ctx.image
Access image manipulation utilities
const img = await this.ctx.image({
url: "https://files.buddypond.com/Marak/Souvlaki_in_Athens.jpg",
});
const resized = await img.resize({ width: 64, height: 64, fit: "cover" });Response Types
Functions may return different types of response data:
- JSON: Standard JavaScript objects
- Text: Plain text strings
- Binary: ArrayBuffer for images, files, etc.
- HTTP Response: Full control over status, headers, body
When running in edge mode, the function's output type will be auto-detected and the API will return the correct Response object with content-type headers.
Roadmap
- [X] Function forking
- [ ] Core library
- [ ] Private functions
- [ ] CLI:
cdless deploy
License
GPLv3 © cdless.com
Built for the edge. Built for everyone.
