Β Server Β Β Routing Β Β Request handling Β Β Response caching Β
Β API DOCS Β Β COMMUNITY TOOLS Β
Stateless HTTP(S) apps that are:
-
Featherweight - Browser-native JavaScript + Deno std library
-
Functional - Express-like API + full-stack tooling
-
Production-ready - High test coverage + stable APIs + server profiling
-
Community-driven - Popular tool integrations + contributions encouraged
Getting started
import * as Peko from "https://deno.land/x/peko/mod.ts";
// import from ".../peko/lib/Server.ts" for featherweight mode
const server = new Peko.Server();
server.use(Peko.logger(console.log));
server.get("/hello", () => new Response("Hello world!"));
server.listen(7777, () => console.log("Peko server started - let's go!"));
App showcase
PR to add your project
iiisun.art - artistic storefront
- Stack: React, ImageMagick_deno
- Features: CI resized-image precaching, Gelato & Stripe integrations, Parallax CSS
- source
shineponics.org - smart-farming PaaS
- Stack: React, Google Cloud Platform
- Features: Google Sheet analytics, GCP email list, Markdown rendering
- source
peko-auth.deno.dev - basic authentication demo
- Stack: HTML5
- Features: JWT-based auth
- source
Note: lit-html and es6-string-css VS Code extensions recommended.
Deployment
- Deno Deploy (fork and deploy the examples if you fancy
π ) - Docker (coming soon...)
What does stateless mean?
Peko apps are designed to boot from scratch at request time and disappear once the request is served. Therefore, storing data in memory between requests (stateful logic) is not reliable. Instead we should use stateless logic and store data within the client or external services.
This paradigm is often referred to as "serverless" or "edge computing" on cloud platforms, which offer code execution on shared server hardware. This is much more resource efficient than traditional server provisioning.
Because our stateless apps cold-start it is important to keep their codebases small. The preact demo app only imports Peko and Preact as external dependencies and is very fast as a result - https://peko.deno.dev!
Note: In reality a single app instance will serve multiple requests, we just can't guarantee it. This is why caching is still an effective optimization strategy but in-memory user sessions are not an effective authentication strategy.
Motivations
The modern JavaScript edge rocks because the client-server gap practically disappears. We can share modules across the client and cloud. If we want TS source we can emit JS. This eliminates much of the bloat in traditional JS server-side systems, increasing project simplicity while making our software faster and more efficient.
This is made possible by engines such as Deno that are built to the ECMAScript specification (support for URL module imports is the secret sauce). UI libraries like Preact combined with htm offer lightning fast client-side hydration with a browser-friendly markup syntax. Deno also has native TypeScript support, a rich runtime API and loads of community tools for your back-end needs.
If you are interested in contributing please submit a PR or get in contact ^^
Read overview.md
for a more detailed guide on using Peko.