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

vite.js

v1.0.1

Published

The simplest way to bootstrap a nodejs server and dive straight into coding.

Downloads

46

Readme

Vite.js

Build Status Actions Status NPM

Welcome

Vite.js is the simplest way for nodejs developers to bootstrap a web server and thus smoothen the process of project creation.
Vite.js has a documentation that is super easy to follow

Features

  • Built-in CLI
  • Optimized
  • Body parsing and Cooky paring
  • Built-in logging capabilities
  • Session
  • Helmet
  • Trust proxy
  • Plugin with a Mongo Database
  • Express connection
  • Production ready

Install

$ npm i -g --save vite.js

Basic Use

const ViteJS = require("vite.js");
const { app, database } = new ViteJS({ name: "test" });

Documentation

Startup

const ViteJS = require("vite.js");
new ViteJS({ name: "test" });

Options

Name

  • Kind: String
  • Description: Used for logging purposes
new ViteJS({ name: "test" });

Port

  • Kind: Integer (0-65536)
  • Description: Port to run web server on
  • Default: 8080
new ViteJS({ 
  name: "test",
  port: 8080
});

Log

  • Kind: Boolean
  • Description: If set to true, logs path of request, speed and status code sent to the console
new ViteJS({ 
  name: "test",
  port: 8080,
  log: true
});

Mongo

  • Kind: String
  • Description: MongoDB connection string
new ViteJS({ 
  name: "test",
  port: 8080,
  log: true,
  mongo: "mongodb://localhost:27017/"
});

Routes

  • Kind: Array
  • Description: Assigning routes to the application
new ViteJS({ 
  name: "test",
  port: 8080,
  log: true,
  routes: [
    {
     url:'/route1',
     router: require('./router1.js')
    },
    {
     url:'/route2',
     router: require('./router2.js')
    }
  ],
  mongo: "mongodb://localhost:27017/"
});

Views Directory

  • Kind: String
  • Description: Path to the views directory
new ViteJS({ 
  name: "test",
  port: 8080,
  log: true,
  viewsDir: "./views",
  mongo: "mongodb://localhost:27017/"
});

Public Directory

  • Kind: String
  • Description: Path to public directory for express for hosting static files
new ViteJS({ 
  name: "test",
  port: 8080,
  log: true,
  publicDir: "./public",
  mongo: "mongodb://localhost:27017/"
});

Express

Under the hood, Vite.js uses express with body parsing and cookie parsing capabilities to start a web server and control it. Additionally, it uses Helmet to keep the server secure and functional so that you can focus on the development and leave these to Vite.js .

  • Method 1
const app = require("vite.js").app;
  • Method 2
const ViteJS = require("vite.js");
const { app } = new ViteJS({ name: "test" });

Example usage

const ViteJS = require("vite.js");
const { app } new ViteJS({ name: "test" });

app.use(function(req, res, next) {
    req.session.name = "AlQaholic007";
    console.log("Sample use of middlewares with vite.js");
    next();
});

app.get("/", function(req, res) {
    res.status(200).send("This works!");
});

app.post("/body", function(req, res) {
    res.status(200).send(req.body);
});

app.get("/session", function(req, res) {
    res.status(200).send(req.session.name)
});

Database

Vite.js leverages enmap and enmap-mongo to connect to your mongo database in a fast and easy manner.

  • Method 1
const database = require("vite.js").database;
  • Method 2
const ViteJS = require("vite.js")
const { database } = new ViteJS({ name: "test" });

Example usage

const ViteJS = require("vite.js");
const { database } = new ViteJS({ name: "test" });

database.set("AlQaholic007", "Vite.js");

console.log("Welcome to " + database.get("AlQaholic007") + "!");

Advanced uses

EJS

const ViteJS = require("vite.js");
const { app, database } = new ViteJS({
  name: "ejs_setup",
  port: 8080,
  log: true,
  mongo: "mongodb://localhost:27017/",
  viewsDir: "./views",
  publicDir: "./public"
});

app.set("view engine", "ejs");

app.get("/", function(req, res) {
  res.render("index", { time: new Date() });
});

Sessions

const ViteJS = require("vite.js");
const { app, database } = new ViteJS({
  name: "session_setup",
  port: 8080,
  log: true,
  mongo: "mongodb://localhost:27017/",
  viewsDir: "./views",
  publicDir: "./public"
});

app.set("view engine", "ejs");
app.use(function(req, res, next) {
  req.session.username = "Tester";
  next();
});

app.get("/", function(req, res) {
  res.render("index", { name: req.session.username });
});

Authors

License

(The MIT License)

Copyright (c) 2020 AlQaholic007 [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.