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

@zbryikt/template

v2.3.46

Published

simple, quick template for bootstrap a page

Downloads

168

Readme

template

Features

  • simple web server
  • easy to extend with API
  • auto watch / build, recursive tree parsing
  • as a module, but extensible.

Usage

install required modules

npm install --save @zbryikt/template

start server ( -r, -p and -c are optional ):

npx server -r <your-web-root> -c <your-server-config> -o <auto-open:true/false> -p <port>

you can also add following in your own package.json:

"scripts": {
    "start": "npx server"
},

optional server config json file specified via -c option for altering default port and other config:

{ "port": 3012 }

Port will be randomized unused port if not specified. For more about options, see the Options section below.

Start Kit

sample folder serves as a starting point to bootstrap a project. It contains following files:

  • package.json: a simple package.json with necessary dependencies. You need to update repo info in this.
  • LICENSE: default MIT.
  • config.json: config file used by template.
  • deploy: if you use gh-pages of github, this automatically push your static/ directory to gh-pages branch. you need to have a gh-pages branch at first.
  • README.md: a dummy readme. edit it as necessary.
  • src/: template style source code folder. check @plotdb/srcbuild for more information.
    • src/ls/: LiveScript code, built to static/js/
    • src/pug/: Pug code, built to static/
    • src/styl/: Stylus code, built to static/css/
  • static/: generated files or other assets.
  • locales/: i18n translation files based on i18next.

Custom API

run template with customized web api by manually initing server:

require("template")
template.server.init({
    api: function(server) {
        server.app.get("/custom-api", function(req, res) {
            return res.send("custom api response");
        });
    }
});

in this case you will have to watch source files manually:

template.watch.init({ ... });

Options

server.init accepts config with following options:

  • port - port to listen. when omitted, random unused port is used.
  • startTime - optional time for providing initialization elapsed time information.
  • api - functions for customizing server. executed before server started
  • open - true to open browser page when server starts. default false
  • feroot - frontend root for serving static file and building view files. default ..
  • i18n - i18n options including:
    • enabled - true if i18n is enabled. default true.
    • lng - list of locales. default ['zh-tw']. mapped to folders under locales/ directory.
    • fallbackLng - fallback locales. default zh-tw.
    • preload - list of locales to preload. defalt ['zh-tw'].
    • ns - list of namespaces. default ['default']. mapped to files under specific locale directory.
    • defaultNS - default namespace. default default
    • fallbackNS - fallback namespace when failed to match with desired namespace. default default.

for using @zbryikt/template as a command line tool, config file specified by -c option also support following options:

  • lsp: an object passed to srcbuild.lsp as options. check @plotdb/srcbuild for more information.

watch.init accepts config with following options:

  • watcher
    • ignores: files to ignored ( not watched ). array of regular expression against file names.
  • assets: (deprecated) array of node module names to be copied to static/assets folder.
    • replaced by fedep. will be removed in future release

Additional information

template now use @plotdb/srcbuild for source building, and thus there are some additional features available and documented in @plotdb/ssrcbuild. Please refer to @plotdb/srcbuild for more information.

TODO

  • support both indir building or src / static building.
  • api style invocation

Note

  • To optimize Pug building, keep an eye on the Pug inclusion tree, and prevent unnecessary include if possible.

License

MIT