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

@bottlejs/bottle.js

v0.0.3

Published

A fast and lightweight Node.js HTTP server framework.

Downloads

4

Readme

BottleJS

FOSSA Status Repository Size NPM Version

Bottle.js is a fast and lightweight Node.js HTTP server framework.

Installation

Using NPM

npm i @bottlejs/bottle.js

Using

Using bottle.js is easy! All you have to do is initialize the router, then add methods! Heres an example:

server.js

const bottle = require('bottle.js');
const router = bottle.Router;

router.get('/', (req, res) => {
  res.sendFile(__dirname + '/index.html')
});

router.listen({
  port: 3000
}, () => {
  console.log('Running! :o');
});

index.html

<!DOCTYPE html>
<html>
  <head>
    <title>Hello, world!</title>
  </head>
  <body>
    <h1>Hello, world!</h1>
  </body>
</html>

Important Features

  • bottle.Router: router, used for routing and listening servers
  • req.query: Get the query of a request
  • req.body: Get the body of a request
  • res.sendFile(filepath): Send a file's contents and headersd as a response
  • res.json(json): Send json content as a response, good for making APIs

Dev Tools

  • typescript: Great for a better development environment and better output code
  • nodemon: Great for restarting the srver every time the new typescript / file code is recompiled or saved
  • visual studio code: Great IDE for programming

Notice

Please note that this project is currently in progress and not all stated features are finished, you should avoid using Bottle.js in production as of this time, thank you.

For Hacktoberfest:

Hey there people coming in looks of getting your Hacktoberfest pull requests up! There are several features that I don't really know how to add but are extremely important to Bottle! Note, you don't have to completely make this on your own! You can just get started and have other build on top of your work and even add more to it later, any contribution helps!

Middleware

NOTE: BASIC SUPPORT FOR MIDDLEWARE HAS BEEN ADDED, YOU CAN STILL ADD ON TO IT

One feature that we need is middleware! Middleware would allow for a much better programming enviornment and allowing creators to publish 'extentsions' of the package! Here's an example of how middleware would work:

const bottle = require('@bottlejs/bottle.js');
const router = bottle.Router;

function yourMiddleware(req, res, next) {
  console.log(req);
}

router.get('/', yourMiddleware, (req, res) => {
  res.send('hi!');
});

// listen

Template Rendering

This is another major feature that Bottle is currently missing! This would allow for extentsions that would help with templating your views so you don't have to generate a whole new HTML file using fs and whatever other packages may be required. Here's an example of how template rendering would work:

(server.js)

const bottle = require('@bottlejs/bottle.js');
const router = bottle.Router;

router.renderer(function(req, res, next){
  // template engine code
});

router.get('/', yourMiddleware, (req, res) => {
  res.render('file.your_template_language', {message:'This is data!'});
});

(file.your_template_language)

{{message}}

Documentation

As of right now, Bottle has no documentation other than this README file, and that's not a good thing! If you would like to create documentation please create a pull request and add all of your HTML/CSS/JS code into a directory named docs! This directory will be reviewed and if the documentation (or the layout0 is good enough we will most likely merge! If you would like to take it a step further you could try and build a Node.js HTTP server (or a Bottle server) in a directory named webserver that would take all of the files in the docs folder and render them as HTML (from Markdown files) with an auto-generated sidebar.

Made with ❤️ by @bottlejs & contributors!

License

FOSSA Status