listen-in
v1.0.2
Published
Promise based STDIN listener for node applications
Downloads
3
Readme
listen-in
listen-in is a simple to use, Promise based, STDIN listener for node applications
Motivation
listen-in was written because I wanted a way to pass secure information into Node applications with out adding EXPORT
or configuration files to my user profile.
Options
envToken [String]
: add value toprocess.env
under this name. (defaultnull
)message [String]
: Message to prompt user with. (defaultnull
)insecure [Boolean]
: Passes user input into thethen
.
Basic Use
const lstn = require('listen-in');
lstn({
message: 'First Name: ',
insecure: true
})
.then(data => {
console.log(`First Name: ${data}`);
});
Use with es2017 Async/Await
import lstn from 'listen-in';
const config = async () => ({
dbName: 'production',
dbUser: 'username',
dbPassword: await lstn({ insecure: true, message: 'Database Password: ' })
});
Use for updating process.env
:
import lstn from 'listen-in';
function getConfigs() {
return lstn({ message: 'Database Password: ', envToken: 'dbp'})
.then(() => ({
dbName: 'production',
dbUser: 'username',
dbPassword: process.env.dbp
}));
}