npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

douh

v0.1.3

Published

http based node.js web server framework

Downloads

27

Readme

Node.js Server Framework douh

Introduction

douh is node.js server framework. super slow and heavy. but want to be fast and light. Contributions are always welcome!

Installation

$ npm install douh

Usage

Hello world

when return, douh will send response body.

import App from 'douh';

const app = new App();

app.use(() => {
  return 'hello world!';
});

app.listen(3000);

Middleware

douh supports async middleware.

app.use(async (req, res, next) => {
  console.time('start');
  await next();
  console.timeEnd('end');
});

Use Router

import App, { Router } from 'douh';

const app = new App();
const router = new Router();

router.get('/ping', (req, res, next) => {
  return 'pong';
});

app.use(router.middleware());

app.listen(3000);

bodyParser

you can use bodyParser middleware.

import App, { bodyParser, Router } from 'douh';

const app = new App();
const router = new Router();

router.post('/ping', (req, res, next) => {
  console.log(req.body);
  console.log(req.files); // when content type is multipart/form-data
  return 'pong';
});

app.use(bodyParser);
app.use(router.middleware());

app.listen(3000);

Use Service

you can use service with @Service decorator. access service with req.service.

import App, { Service } from 'douh';

@Service()
class DouhService {
  public hello(name: string) {
    return `hello ${name}`;
  }
}

const app = new App();
app.use(async (req, res) => {
  const result = req.service.userService.hello('douh');
  return result; // hello douh
});

Use Repository

you can use repository with @Repository decorator. access repository in service constructor.

@Repository()
class DouhRepository {
  hello(name) {
    return `hello ${name}`;
  }
}

@Service()
class DouhService {
  constructor(private readonly douhRepository: DouhRepository) {}

  hello(name: string) {
    return this.douhRepository.hello(name);
  }
}

const app = new App();
app.use(async (req, res) => {
  const result = req.service.douhService.hello('douh');
  return result; // hello douh
});

Use File Service

you can use file service with middleware.

import App, { serveStatic } from 'douh';

const app = new App();

app.use(serveStatic('public')); // it must be placed before bodyParser
app.use(bodyParser);

app.listen(3000);