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

@cortec/storage

v1.5.2

Published

<description>

Readme

@cortec/storage

Module Overview

The @cortec/storage package provides a unified interface for managing file storage backends. It currently supports disk-based storage and is designed to be extensible for other storage providers. The module allows you to configure multiple storage instances, each with its own directory and options, and access them by name.

Configuration Options

Where to put config: Place your storage config in config/default.yml (or your environment-specific config file).

Schema:

storage:
  uploads:
    dir: '/var/app/uploads'
    makeParent: true
  logs:
    dir: '/var/app/logs'
    makeParent: false

Field-by-field explanation:

  • storage: Root key for Storage config.
  • uploads, logs: Identity/name for each storage instance (can be any string).
  • dir: Directory path for storage. This is where files will be read/written.
  • makeParent: If true, parent directories will be created automatically if missing.

How config is loaded: The config is loaded automatically by the @cortec/config module and validated at runtime. Access it in code via:

import { Config } from '@cortec/config';
const storageConfig = Config.get('storage');

If config is missing or invalid, an error is thrown at startup.

Example YAML:

storage:
  uploads:
    dir: '/var/app/uploads'
    makeParent: true
  logs:
    dir: '/var/app/logs'
    makeParent: false

Example Usage

import Storage from '@cortec/storage';

// After context is loaded and storage module is initialized
const storage = new Storage();

// Get a storage instance by name
const uploadsStorage = storage.get('uploads');

// Use the storage instance (DiskStorage API)
await uploadsStorage.writeFile('example.txt', 'Hello, world!');
const content = await uploadsStorage.readFile('example.txt');
console.log(content); // "Hello, world!"

// Dispose all storage instances when shutting down
await storage.dispose();

API

storage.get(name: string): IBaseStorage

Returns the storage instance for the given name. Throws if not found.

DiskStorage Methods

The returned IBaseStorage instance supports typical file operations such as:

  • writeFile(filename: string, data: string | Buffer): Promise<void>
  • readFile(filename: string): Promise<string | Buffer>
  • deleteFile(filename: string): Promise<void>
  • dispose(): Promise<void>

Notes

  • Each storage instance is independent and configured via the main configuration file.
  • The module is designed to be extensible for cloud or remote storage providers in the future.