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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sss2sssss/bank_cli

v1.0.1

Published

bank cli demo

Downloads

4

Readme

Simple Bank CLI developed by using commander, sqlite, and bcrypt (for password authentication) with Node.js.

It allow user to type bank command on command prompt without have any active windows need to run with.

Before Start

You will need to download and install Node.js first before running the code. The link to download is on below: https://nodejs.org/en/download/

After download the installer, double click and follow the instruction to complete.

Then download the project zip file, extract it and went to the root of project folder (where you can see index.js at there), open terminal/ command prompt and type following script command to initiate project: npm run first-initiate

Available Scripts

In the project directory, you can run:

npm run first-initiate

This script command helps you to install all the node modules that's required to run. And make the cli available to global environment.

Database

In this project, SQLite is used for any transaction and user logging. The database named bank.db will auto created if any command is fired up and there's no database exists.

Table(s)

Here are the list of table been used and column defined

user

  1. id (INTEGER, PRIMARY KEY, AUTO INCREMENTAL, index id)
  2. name (TEXT, NOT NULL, user name)
  3. passwordHashed (TEXT NOT NULL, password hashed by bcrypt)
  4. status (TEXT NOT NULL, user status ['Online', 'Offline'])
  5. totalAmountAvailable (TEXT NOT NULL, current available amount)

debtTransaction

  1. id (INTEGER, PRIMARY KEY, AUTO INCREMENTAL, index id)
  2. performUserId (INTEGER, NOT NULL, own from person id)
  3. toUserId (INTEGER NOT NULL, own to person id)
  4. debtAmount (TEXT NOT NULL, debt amount)
  5. lastUpdateTimestamp (TEXT NOT NULL, last update timestamp by ISO string with GMT timezone)

transactionLog

  1. id (INTEGER, PRIMARY KEY, AUTO INCREMENTAL, index id)
  2. performUserId (INTEGER, NOT NULL, person id to view the log)
  3. event (TEXT NOT NULL, event detail)
  4. transactionTimestamp (TEXT NOT NULL, transaction timestamp by ISO string with GMT timezone)

Available Commands

All the commands need to be start with 'bank', example: bank login Alice 1234567b bank pay Bob 20

bank -h, --help

To call up the help content for all the commands availble inside this cli

bank -V, --version

To give the current cli version

bank login <name> <password>

name - required, password - required To login to certain user if password is matched with password hash by bcrypt If there's no user matched with the name provided, it will auto register a new profile The password need to have at least 8 characters, one number and one character

Possible Output(s)

  1. When the password provided is less than 8 character: "Password length should need to have at least 8 character." "Which consists at least one character and one number."

  2. When the password provided doesn't contain at least one character and one number: "Password doesn't contain at least one character and one number."

  3. When password provided doesn't matched with existed user profile password hash: "Incorrect Password.

  4. If login perform successfully: "Hello, <'name'>!" (If have someone own you money) "Owing <'debt amount'> from <'own person'>." "Your balance is <'available value'>." (If have you own someone money) "Owing <'debt amount'> to <'debt person'>."

bank topup <amount>

amount - required To topup amount provided to active user login A active user session must exists, if doesn't have you will have need to login with any user to perform The topup will only applied to most recent user session The amount provided must need to be greater than 0, can accept numeric and / or decimal with two decimal places If the active user session have own any other user money, it will priority to transfer the money to that user first

Possible Output(s)

  1. When amount provided is not numeric / there's other than decimal separator appear / more than two decimal typed: "Amount enter allowed only numeric and / or decimal with two decimal places."

  2. When the amount provided is less or equal to 0.00 "Amount enter need to be greater than 0.00."

  3. When there's no any active user login: "No user login at the moment." "Please login to perform this command."

  4. If have active user login: (If you need to pay debt to own person) "Transferred <'amount need to pay'> to <'own person'>." "Your balance is <'final available value (previous available value + (topup amount - total amount need to pay))'>."

bank pay <user> <amount>

user - required, amount - required To transfer your available amount to certain user A active user session must exists, if doesn't have you will have need to login with any user to perform The targeted user must not be same user as requested user The targeted user must be valid user, if the targeted user is not exists it will not allowed to transfer If targeted user own this user money, it will priority reduce the own amount first If there's no any available amount to transfer (0.00), it will stop the operation and request user to topup first If the amount is not enough to make the full amount to transfer, it will first transfer all the available amount then create debt tranaction to own the targeted user remaining money

Possible Output(s)

  1. When amount provided is not numeric / there's other than decimal separator appear / more than two decimal typed: "Amount enter allowed only numeric and / or decimal with two decimal places."

  2. When the amount provided is less or equal to 0.00 "Amount enter need to be greater than 0.00."

  3. When there's no any active user login: "No user login at the moment." "Please login to perform this command."

  4. When same user is typed on pay command: "Pay function cannot be use on same user." "Please type another username to perform this command."

  5. When targeted user is not exists: "Please first login to that user first to perform auto register."

  6. When your remaining amount reach 0 and you don't have any debt from targeted user: "Your balance is reached 0.00." "And your had no remaining debt from <'targeted user'>." "Please topup before perform this command.";

  7. When your remaining amount reach 0 and the debt amount is already been paid off: "Your balance is reached 0.00." "Your remaining pay balance <'pay balance'> cannot be pay now." "Please topup then perform the pay command again.";

  8. If pay amount can proceed: (If there is debt from targeted person need to deduct) "Owning <'new debt amount'> from <'targeted user'>." (If there is have amount remaining need to transfer) "Transferred <'amount need transfer'> to <'targeted user'>." "Your balance is <'final available value (previous available vlue - (amount need transfer))'>." (If there is still have amount remaining cannot pay and need to perform debt) "Owing <'amount to own'> to <'targeted user'>."

bank history [limit]

limit - optional; if not specific default to 10 To view recent transaction history for active user login A active user session must exists, if doesn't have you will have need to login with any user to perform Limit is to specific maximun transaction shown, need to more than 0 if specific If there's no transaction history to show, it will show no history appear Else it will show table list wiith event detail and transaction time

Possible Output(s)

  1. If limit supplied less than 0: "Limit need to set more than 0."

  2. When there's no any active user login: "No user login at the moment." "Please login to perform this command."

  3. When there is no record: "Hello, <'name'>!" "There's no record at the moment."

  4. If there is have any transaction record: Example: Hello, Bob! Here's your last 7 transaction(s) performed. Event Log Timestamp =========================================================== Top up 90.00. 2020-04-08T12:00:37.644Z Transferred 10.00 to Alice. 2020-04-08T12:00:37.612Z Owing 10.00 to Alice. 2020-04-08T12:00:14.787Z Transferred 30.00 to Alice. 2020-04-08T11:59:49.831Z Owing 70.00 to Alice. 2020-04-08T11:59:36.038Z Transferred 30.00 to Alice. 2020-04-08T11:59:35.980Z Top up 80.00. 2020-04-08T11:59:25.385Z