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

@axel669/hephaestus

v0.1.1

Published

Library for doing fast and dirty work with generating static content from svelte files on a server.

Readme

Hephaestus

Library for doing fast and dirty work with generating static content from svelte files on a server.

Installation

yarn add @axel669/hephaestus

Usage

Svelte Context Script

Hephaestus uses the <script context="module"> feature of Svelte to pass information to components when they are rendered (either on page load, or during the build proces).

A user should treat this script as a hook that runs when a page is loaded as a component, before it is rendered in any context.

The buildProps and get functions are optional exports for build-time and http GET requests to render, but post must be exported if the page needs to respond to a POST request.

<script context="module">
    //  buildProps runs during the build phase (never during dynamic renders
    //  in a server). The return value is an object that will be used as the
    //  props that are passed into the component when rendering it.
    export async function buildProps() {
        return {
            when: new Date()
        }
    }

    //  The get/post functions are used to respond to http requests to the page.
    //  Both functions can be optoinally async, and both take a single argument
    //  that is the Express Request object, unmodified.
    //  The return value should have a "status" property that is an http status
    //  code to use for the response, and either a "redirect" or "props"
    //  property.
    //  The "redirect" property should be a URL to redirect to, and the status
    //  property should say which kind of redirection it is (will default to
    //  302 if one is not given).
    //  The "props" property is an object that will be passed as the props to
    //  the component when it is rendered and sent.
    export async function get(req) {
        return {
            status: 200,
            props: {
                when: new Date(),
                who: req.query.user,
            }
        }
    }

    export function post(req) {
        return {
            status: 200,
            props: {
                name: req.body.name
            }
        }
    }
</script>

Express

import express from "express"
import heph from "@axel669/hephaestus"

const server = express()

server.use(
    await heph({
        source: "content",
        error: "$error.svelte",
        pass: /^api\//,
    })
)

Expess API

heph(config)

config {
    //  source is the directory where the svelte files are.
    //  Files named $layout are automatically wrapped around page files inside
    //  the given folder, and are nested in the order of the folders.
    //  files that are prefixed with "$" will not be loaded as pages, but can
    //  still be imported as components normally.
    "source": String,

    //  The filename of the error page (recommended to use $error.svelte).
    //  The error page does not have any layout applied to it, and is sent
    //  for any non 2xx response that is not a redirect.
    //  Optional
    "error?": String,

    //  Any route that matches the given regex will not be processed at all
    //  and handed to the next middleware function as normal for express.
    //  If a route is not passed on and is not found as a page, a 404 is
    //  returned even if a later piece of middleware might have it.
    //  Optional
    "pass?": RegExp,
}

Static Build

package.json

{
    "scripts": {
        "build-static": "heph config.mjs"
    }
}

CLI Config

.mjs file

export default {
    //  source is the directory where the svelte files are.
    //  Files named $layout are automatically wrapped around page files inside
    //  the given folder, and are nested in the order of the folders.
    //  files that are prefixed with "$" will not be loaded as pages, but can
    //  still be imported as components normally.
    "source": "content",

    //  The filename of the error page (recommended to use $error.svelte).
    //  The error page does not have any layout applied to it.
    //  Optional
    "error?": "$error.svelte",

    //  The output folder for the static files.
    "dest": "public",

    //  Hooks that are run at specific times in the build process.
    "hooks?": {
        //  Hook that is run at startup, before any files are loaded or
        //  processed.
        async init() {
        },
        //  Hook that is run after all files have been written to disk.
        async done() {
        }
    },

    //  Directory for static files that will be copied into the output folder
    //  after building the html files.
    //  Optional
    "staticFiles?": "static"
}

TODO

  • possibly add more hooks around build events Open to sugestions for features.