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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@luilautre/jst

v1.1.4

Published

Serveur web avec préprocesseur de templates {{variables}} — compatible Node.js, Express et Vercel

Downloads

811

Readme

JST Server

Serveur web Node.js avec préprocesseur de templates {{variables}}.
Compatible local, Vercel et importable via npm.


Installation

npm install @luilautre/jst

Ou directement depuis GitHub :

npm install luilautre/jst

Utilisation

1. Middleware sur app Express existante (recommandé)

Applique JST comme middleware sur ton serveur Express :

const express = require('express');
const path = require('path');
const { jstMiddleware } = require('@luilautre/jst');

const app = express();

// Applique JST sur tous les fichiers
app.use(jstMiddleware({
  racine: path.resolve('./'),                 // variables.json, functions.js ici
  public: path.join(path.resolve('./'), 'public'),  // fichiers HTML/CSS/JS ici
  page404: '404.html'                         // optionnel, défaut: '404.html'
}));

// Routes personnalisées (optionnel)
app.get('/api/hello', (req, res) => {
  res.json({ message: 'Hello' });
});

app.listen(3000);

Gestion automatique de la 404 : Si un fichier n'existe pas, JST cherche automatiquement 404.html dans le dossier public/ et l'affiche avec toutes les variables/fonctions JST. Personnalisable avec l'option page404.

JST traitera automatiquement tous les fichiers HTML/CSS/JS avant de les envoyer !

2. En ligne de commande (local)

npx jst          # port 3000 par défaut
npx jst 8080     # port au choix

3. App Express complète (legacy)

const path = require('path');
const { creerApp } = require('@luilautre/jst');

const app = creerApp({
  racine: path.resolve('./'),
  public: path.join(path.resolve('./'), 'public')
});

module.exports = app; // pour Vercel

if (require.main === module) {
  app.listen(3000, () => console.log('Serveur sur http://localhost:3000'));
}

Fonctionnement

À chaque requête, JST Server :

  1. Lit le fichier demandé dans le dossier public/
  2. Remplace les {{variables}} avec le contenu de variables.json
  3. Remplace les {{_constantes_}} internes (date, URL, heure...)
  4. Appelle les {{fonctions()}} déclarées dans functions.js
  5. Injecte les {{include: fichier}}
  6. Envoie le résultat au client — aucun fichier généré sur le disque

variables.json

Définis tes variables globales dans un fichier variables.json à la racine :

{
  "SiteTitle": "Mon Site",
  "ThisURL": "https://monsite.com",
  "SiteHeader": "<header><a href=\"{{ThisURL}}\">Accueil</a></header>",
  "SiteFooter": "<footer>&copy; 2025</footer>"
}

Les variables peuvent s'imbriquer ({{ThisURL}} dans SiteHeader est résolu automatiquement).


Constantes internes

JST fournit des constantes automatiques utilisables dans tous les fichiers :

{{_thisURL_}}      URL de la requête courante
{{_thisFile_}}     Nom du fichier
{{_thisDir_}}      Dossier du fichier
{{_host_}}         Nom d'hôte
{{_protocol_}}     http ou https
{{_method_}}       GET, POST...
{{_ip_}}           IP du visiteur
{{_date_}}         Date (YYYY-MM-DD)
{{_time_}}         Heure (HH:MM:SS)
{{_datetime_}}     Date et heure ISO
{{_timestamp_}}    Timestamp Unix
{{_year_}}         Année
{{_month_}}        Mois
{{_day_}}          Jour
{{_weekday_}}      Jour de la semaine (ex: Lundi)
{{_env_}}          development ou production
{{_jstVersion_}}   Version de JST

Fonctions

Déclare des fonctions dans functions.js à la racine :

module.exports = {
  // Usage : {{lien(/contact.html, Contactez-nous)}}
  lien([href, texte]) {
    return `<a href="${href}">${texte || href}</a>`;
  },

  // Usage : {{header(Mon Site, /logo.png)}}
  header([titre, logo], contexte, vars) {
    return `<header><a href="${vars._protocol_}://${vars._host_}/">${titre}</a></header>`;
  },

  // Usage : {{dateFormatee(fr-FR)}}
  dateFormatee([locale]) {
    return new Date().toLocaleDateString(locale || 'fr-FR', {
      weekday: 'long', year: 'numeric', month: 'long', day: 'numeric'
    });
  }
};

Chaque fonction reçoit (args, contexte, variables) et retourne une string HTML.


{{include: fichier}}

Inclure un fichier entier dans une page :

<head>
  {{include: partials/meta.html}}
  {{include: partials/style.css}}
</head>

.jstignore

Les fichiers listés dans .jstignore sont servis tels quels, sans traitement :

variables.json
*.min.js
*.min.css
libs/

Déploiement sur Vercel

  1. Crée server.js à la racine :
const path = require('path');
const { creerApp } = require('@luilautre/jst');

const app = creerApp({
  racine: path.resolve('./'),
  public: path.join(path.resolve('./'), 'public')
});

module.exports = app;
  1. Ajoute vercel.json :
{
  "builds": [{
    "src": "server.js",
    "use": "@vercel/node",
    "config": {
      "includeFiles": ["variables.json", "public/**"]
    }
  }],
  "routes": [{ "src": "/(.*)", "dest": "server.js" }]
}
  1. Structure du projet :
mon-projet/
├── server.js          ← point d'entrée
├── vercel.json
├── package.json
├── variables.json     ← variables globales
├── functions.js       ← fonctions JST (optionnel)
├── .jstignore         ← fichiers à ne pas traiter (optionnel)
└── public/            ← tes fichiers HTML/CSS/JS
    ├── index.html
    └── style.css

Auteur

luilautre
Licence MIT