temptrax
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Contributors Issues MIT License


Temptrax

About Temptrax

Temptrax is a Node.js module that allows you to generate entries which are valid for a specific amount of time. It was built with Postgresql as the storage but it also has an in-memory support. Built for Protonfile

Installation

Install the package with npm

npm install temptrax

Usage

import Temptrax from 'temptrax';

const expirationDate = new Date('Sun May 11,2025'); // this entry will expire on May 11, 2025

const temptrax = new Temptrax({
	databaseUrl: 'postgres://username:password@host:5432/dbname',
	tableName: 'temptrax',
	inMemory: false,
});
// databaseUrl and tableName not required if inMemory is true

await temptrax.add('entry_id', { key: 'value' }, expirationDate);

// Get the entry at some later point in time
try {
	const entry = await temptrax.get('entry_id');
} catch (error) {
	// entry is expired or doesn't exist
}

Contributing

Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/MyFeature)
  3. Commit your Changes (git commit -m 'Add MyFeature')
  4. Push to the Branch (git push origin feature/MyFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Readme

Keywords

Package Sidebar

Install

npm i temptrax

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

10.4 kB

Total Files

5

Last publish

Collaborators

  • jmax45