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

@trivajs/shortcuts

v1.0.0

Published

IDE snippets/shortcuts for Triva framework - auto-installs to VS Code, VS Code Insiders, and Atom

Readme

@trivajs/shortcuts

IDE snippets and shortcuts for Triva framework. Automatically installs code snippets to VS Code, VS Code Insiders, and Atom.

Installation

npm install triva
npm install @trivajs/shortcuts

The snippets will automatically install to your IDE(s) on npm install and automatically uninstall on npm uninstall.

Supported IDEs

VS Code - Detects and installs to User/snippets/VS Code Insiders - Detects and installs separately ✅ Atom - Installs to ~/.atom/snippets.cson

Available Snippets

Server Setup

| Prefix | Description | |--------|-------------| | triva-build | Build and configure Triva server | | triva-server | Create basic Triva server | | triva-config | Full Triva configuration |

Routes

| Prefix | Description | |--------|-------------| | triva-get | Create GET route | | triva-post | Create POST route with body parsing | | triva-put | Create PUT route with params | | triva-del | Create DELETE route | | triva-auth | Protected route with authentication |

Middleware

| Prefix | Description | |--------|-------------| | triva-middleware | Create middleware function | | triva-cors | Add CORS middleware | | triva-cookies | Cookie parser middleware |

Cache

| Prefix | Description | |--------|-------------| | triva-cache-get | Get value from cache | | triva-cache-set | Set value in cache with TTL | | triva-cache-pattern | Cache pattern with get/set |

Database Adapters

| Prefix | Description | |--------|-------------| | triva-mongodb | Configure MongoDB cache | | triva-redis | Configure Redis cache | | triva-postgres | Configure PostgreSQL cache |

Features

| Prefix | Description | |--------|-------------| | triva-errors | Configure error tracking | | triva-logging | Configure request logging | | triva-throttle | Configure rate limiting | | triva-throttle-policy | Rate limiting with policies |

Usage

In VS Code or Atom, simply type the prefix and press Tab to expand the snippet.

Example: Create Basic Server

  1. Type triva-server and press Tab
  2. Fill in the placeholders (route, response, port)
  3. Press Tab to move between placeholders
import { build, get, post, listen } from 'triva';

await build({
  cache: { type: 'memory' }
});

get('/api', (req, res) => {
  res.json({ message: 'Hello' });
});

listen(3000);

Example: Add CORS

  1. Type triva-cors and press Tab
  2. Configure origin, credentials, methods
import { cors } from '@trivajs/cors';

use(cors({
  origin: 'https://example.com',
  credentials: true,
  methods: ['GET', 'POST', 'PUT', 'DELETE'],
  allowedHeaders: ['Content-Type', 'Authorization']
}));

Example: Cache Pattern

  1. Type triva-cache-pattern and press Tab
  2. Configure cache key, data source, TTL
const cacheKey = 'users:123';

const cached = await cache.get(cacheKey);
if (cached) {
  return res.json({ source: 'cache', data: cached });
}

const data = await db.getUser(123);
await cache.set(cacheKey, data, 3600000);

res.json({ source: 'database', data });

How It Works

Automatic Detection

The package automatically detects your IDE(s) by:

  1. Environment variables (high confidence)

    • VSCODE_CWD, TERM_PROGRAM, ATOM_HOME
  2. Filesystem checks (lower confidence)

    • VS Code config directories
    • Atom config directories
  3. Fallback behavior

    • If no IDE detected → installs to ALL supported IDEs
    • Ensures snippets are available even if detection fails

Installation Paths

VS Code (Windows):

%APPDATA%\Code\User\snippets\javascript.json
%APPDATA%\Code\User\snippets\typescript.json

VS Code (macOS):

~/Library/Application Support/Code/User/snippets/javascript.json
~/Library/Application Support/Code/User/snippets/typescript.json

VS Code (Linux):

~/.config/Code/User/snippets/javascript.json
~/.config/Code/User/snippets/typescript.json

Atom (All platforms):

~/.atom/snippets.cson

Update Behavior

When you update @trivajs/shortcuts:

  • New snippets are added
  • Changed snippets are updated
  • Existing snippets are preserved (no duplicates)
  • Removed snippets stay until package is uninstalled

Uninstallation

npm uninstall @trivajs/shortcuts

Automatically removes all Triva snippets from your IDE(s) on uninstall.

Manual Installation

If automatic installation doesn't work, you can manually add snippets:

VS Code

  1. Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
  2. Select "Preferences: Configure User Snippets"
  3. Choose "javascript.json" or "typescript.json"
  4. Copy snippets from triva/snippets/triva.json

Atom

  1. Open ~/.atom/snippets.cson
  2. Add Triva snippets under .source.js: or .source.ts:
  3. Save and reload Atom

Snippet Format

Snippets use standard VS Code format with:

  • Placeholders - ${1:default} - Tab to navigate
  • Choices - ${1|option1,option2|} - Select from list
  • Variables - $0 - Final cursor position

Troubleshooting

Snippets Not Appearing

VS Code:

  1. Restart VS Code
  2. Check: File > Preferences > User Snippets
  3. Verify snippets in javascript.json or typescript.json

Atom:

  1. Reload Atom (Ctrl+Shift+F5 / Cmd+Shift+F5)
  2. Check ~/.atom/snippets.cson
  3. Verify correct CSON syntax

Permission Errors

Run npm with appropriate permissions:

# Linux/macOS
sudo npm install @trivajs/shortcuts

# Windows (as Administrator)
npm install @trivajs/shortcuts

Multiple IDEs

If you have multiple IDEs, snippets install to all detected IDEs. This is intentional to ensure availability.

Development

Add New Snippets

Edit triva/snippets/triva.json:

{
  "Snippet Name": {
    "prefix": "trigger-text",
    "body": [
      "line 1",
      "line 2 with ${1:placeholder}",
      "$0"
    ],
    "description": "What this snippet does"
  }
}

Test Locally

cd extensions/shortcuts
npm install
# Snippets auto-install to your IDE

Contributing

To add snippets:

  1. Edit snippets/triva.json (in main Triva repo)
  2. Follow VS Code snippet format
  3. Test installation
  4. Submit PR

Related

Contributing

Issues and PRs welcome! See main Triva repository for contribution guidelines.

Triva Framework - Main framework

License

MIT License - see LICENSE file