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

statikly

v0.0.19

Published

No hassle full stack framework

Downloads

11

Readme

statikly

No hassle full stack framework, for blog/static/content sites, amazing for prototype and build internal tools and seo optimize. Provide alternative for writing frontend "the old way", more and more hype is growing on server side ui, like next.js and remix, I wanted to simplified it event more.

statikly is just an opinionated warpper around fastify ecosystem.

when your app is growing you can always eject and control everting yourself.

Installation

npm i -g statikly

Configuration

environment variables:

STATIKLY_SESSION_SECRET= # optional: npx @fastify/secure-session
NODE_ENV=production # optional: set in production
STATIKLY_ROOT= # optional: set to override current folder
STATIKLY_STATIC_FOLDER=public # optional: for other public folder
STATIKLY_TEMPLATE=ejs # optional: template engine to use for the complete list @fastify/view
STATIKLY_LAYOUT= # optional: layout path
STATIKLY_VIEWS=views # optional: for other views folder
STATIKLY_PASSWORD=1234 # optional: basic auth
STATIKLY_USERNAME=user # optional: basic auth

defaults:

  • template engine ejs
  • views folder = views
  • api folder = api
  • public folder = public

All routes is file base:

views/notes/index.ejs => /notes views/note/[id].ejs => /note/:id

api/notes/index.js => api/notes api/note/[id].js => api/note/:id

Getting Started

Start with example app

mkdir my-first-statikly
cd my-first-statikly
statikly init # clone the demo from https://github.com/niradler/statikly-demo
statikly serve

Manual guide

Write your first view, create views/index.ejs and run statikly serve

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>statikly</title>
    <meta name="description" content="" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
  </head>
  <body>
    <h1><%= "query" %></h1>
    <h3><%= JSON.stringify(query,null,2); %></h3>
    <h1><%= "params" %></h1>
    <h3><%= JSON.stringify(params,null,2); %></h3>
    <h1><%= "data" %></h1>
    <h3><%= JSON.stringify(data,null,2); %></h3>
    <h1><%= "env" %></h1>
    <h3><%= JSON.stringify(env,null,2); %></h3>
  </body>

Passing server side data to views, create views/loader.js and run statikly

//views/index.js
module.exports = {
    loader: async (req, reply) => {
        return { todos }; // available in views data.todos
    },
};

Processing forms

//views/index.js
module.exports = {
    actions: async (req, reply) => {
        const title = req.body.title;
        if (title.length < 2) {
            req.flash('errors', ['title length should be longer then 2 characters']);
            return reply.redirect('/todos');
        }
        await db.add(title);
        reply.redirect('/todos');
    },
};

Api routes, create api/notes.js and run statikly

module.exports = {
    get: async (req, reply) => [{ id: 1, title: 'note1' }],
    post: async (req, reply) => [{ id: 1, title: 'note1' }],
};
curl http://localhost:3000/api/notes

Build on top of fastify, for more information, checkout the fastify docs

Recommended reading:

  • (Request)[https://www.fastify.io/docs/latest/Reference/Request/]
  • (Reply)[https://www.fastify.io/docs/latest/Reference/Reply/]

TODO:

  • advance form support (server/client)
  • static gen
  • auth / social login / jwt support
  • css and js minify / bundler (vite)
  • verify security features