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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nghost

v1.1.15

Published

Host Angular html prod files

Readme

nghost

Install


$ npm i nghost

Description

Allows you to host web files such as the files generated by Angular from ng build --prod command.

Default content type

| Name | Content type | Encodage type | | ------------------------ | --------------------------------- | ------------- | | html | text/html | text | | javascript | application/javascript | text | | style sheet | text/css | text | | favicon | image/x-icon | binary | | Javascript notation | application/json | text | | Web Open Font Format | application/font-woff woff | binary | | Web Open Font Format 2 | application/font-woff2 | binary | | Embedded OpenType | application/vnd.ms-fontobject eot | binary | | True Type | application/octet-stream | binary | | Map | application/octet-stream | binary | | MPEG-4 | video/mp4 | binary | | Adobe Flash | video/x-flv | binary | | Scalable Vector Graphics | image/svg+xml | binary | | Jpg | image/jpg | binary | | Jpeg | image/jpeg | binary | | Png | image/png | binary |

How to use

var nghost = require("nghost");

//Set Options

var options = {
  publicFolder: __dirname + "/dist",
  port: 8080,
  favicon: __dirname + "/dist/favicon.ico",
};

//Init Server

//nghost() function return Express application server.

var app = nghost(options);

//It's Done, Have a fun

Options

Here is all options params.


var  options = {
	publicFolder: path.join(__dirname, 'public'),
	hostname: 'localhost',
	favicon: path.join(__dirname, 'favicon.ico'),
	port: 80,
	https: false,
	key: path.join(__dirname, 'security', 'server.key'),
	cert: path.join(__dirname, 'security', 'server.crt'),
	ca: path.join(__dirname, "security", "chain.pem"),
	bodyParser: true,
	encode: 'utf-8',
	session: '',
	contents: [
		...
		//all content filter
		...
	],
	gets: [],
	posts: [],
	puts: [],
	deletes: [],
	"Access-Control-Allow-Origin": "*",
	"Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept",
	simpleAuth: {
		enable: false,
		username: "",
		password: "",
		allowip: []
	},
	auth0: { //Auth0 login
		enable: false,
		AUTH0_DOMAIN: "",
		AUTH0_CLIENT_ID: "",
		AUTH0_CLIENT_SECRET: "",
		AUTH0_CALLBACK_URL: "",
	}
}

NgHost and Auth0

Default login system are append in project, "Auth0". For starting to use, change state of options.auth0.enable to true and complete your tenant information. If you not have, create an account on "Auth0.com"

Reserved route

  • (hostname):(port)/login
  • (hostname):(port)/logout

How it work

once logged user information stored in req.oidc.user, and auth status can check in req.oidc.isAuthenticated()

Simple Auth

Basic authorisation to acces on the web page.

...
simpleAuth: {
		enable: false,
		username: "",
		password: "",
		allowip: []
	},
...

Set enable to true and define username, password. if you want allow specific ip or network, add it in allowip array example:

	...
	allowip: [
		"192.168.1.1",
		"10.0.0.*"
	]
	...

in this example, ip 192.168.1.1 and all 10.0.0.* client can access without password.

Advance

To Add new requests, you must specify it in the Gets or Posts array in the options

//Example
//Traditionnal get and post
app.get("/foo", function(req, res){
	console.log("Your request is:", req.url);
	res.end();
})

app.post("/foo", function(req, res){
	console.log("your post var is:", req.body);
	res.end();
})

//nghost get and post
var options = {
....
	gets:[
		{
			key: "/foo",//regex
			function:  function (req, res) {
				console.log("Your request is:", req.url);
				res.end();
			}
		}
	],
	posts:[
		{
			key: "/foo",//regex
			function:  function (req, res) {
				console.log("your post var is:", req.body);
				res.end();
			}
		}
	]
....
}

Do not forget to add req and res arguments.

To Add new content-Type

var options = {
	....
	contents: [
		{
			key: /\.html$/,
			type:  'text',
			contentType:  'text/html'
		}
	]
	....
}

Place all web file in your specified public folder.

Change Log

######v. 1.0.2

  • debug: add body-parser for getting post value
//new options
var options = {
	....
	bodyParser: true, // True or False
	....
}

######v. 1.0.3

  • add: Session management
//new options
var options = {
	....
	session: 'SESSION_SECRET_KEY',
	....
}

######v. 1.0.5

  • debug: correction Post and Get Matching

######v. 1.0.10

  • debug: correction regex matching Post and Get in query

######v. 1.0.11

  • debug: correction binary content type

######v. 1.0.12

  • add: Access-Control-Allow-Origin headers params added

######v. 1.1.0

  • add: Auth0 authentification
  • debug: options merge
  • debug: binary content-type

######v. 1.1.7

  • add: Simple authentification

######v. 1.1.10

  • add: Https protocol Change https to true and set key and cert location

######v. 1.1.13

  • add: put,delete request

######v. 1.1.15

  • add: option ca for https credential