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.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/MyFeature
) - Commit your Changes (
git commit -m 'Add MyFeature'
) - Push to the Branch (
git push origin feature/MyFeature
) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE
for more information.