Skip to content

🖼️Laughably minimal http framework combining the best parts of express and koa

Notifications You must be signed in to change notification settings

francisrstokes/frame-http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frame

Frame is <100 line, zero dependency, middleware only express/koa-like framework built on top of the http/https module.

Example

const http = require('http');
const Frame = require('frame-http');

const app = new Frame();
const server = http.createServer(app.handler);

// Time/Log Requests
app.use(async (ctx, next) => {
  const startTime = Date.now();
  await next();
  const endTime = Date.now();
  console.log(`[${ctx.method}] Took ${endTime - startTime}ms`);
});

// Add some headers
app.use((ctx, next) => {
  ctx.setHeader('X-Powered-By', 'Frame');
  next();
});

// Catchall endpoint, responding with JSON
app.use(ctx => {
  ctx.setStatus(200);
  ctx.send({ message: 'Hello world!' });
});

server.listen(3001);

About

🖼️Laughably minimal http framework combining the best parts of express and koa

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published