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 🙏

© 2026 – Pkg Stats / Ryan Hefner

devops_assignment2

v1.0.8

Published

The **Bookstore Management System** is a TypeScript-based project designed to manage a simple bookstore. It provides essential functionalities such as adding new books to the inventory, borrowing books for temporary use, and returning borrowed books to th

Downloads

14

Readme

Bookstore Management System

The Bookstore Management System is a TypeScript-based project designed to manage a simple bookstore. It provides essential functionalities such as adding new books to the inventory, borrowing books for temporary use, and returning borrowed books to the bookstore. This project ensures the correctness of its core features through automated testing using Jest, a popular testing framework.

Features Overview

The system provides the following features:

1. Add Book

This feature allows administrators to add a new book to the bookstore's inventory. The book details, including the title, author, and availability status, are recorded.

2. Borrow Book

Customers can borrow a book from the bookstore if it is available. Once borrowed, the book is marked as unavailable in the inventory to prevent others from borrowing it until it is returned.

3. Return Book

Borrowed books can be returned to the bookstore, which updates their status in the inventory, making them available for borrowing again.

Technologies and Tools Used

The project is built using the following tools and technologies:

  • TypeScript: A strongly typed superset of JavaScript, used as the primary programming language for this project.
  • Jest: A testing framework that ensures the application’s functionality is working as intended by automating test cases.
  • Node.js: Provides the runtime environment to execute TypeScript and JavaScript code efficiently.

Project Setup Guide

To set up this project on your local machine, follow these steps:

Step 1: Clone the Repository

Start by cloning the repository from GitHub:

git clone https://github.com/your-username/bookstore-management.git
cd bookstore-management 

Step 2: Install Dependencies

Ensure you have Node.js installed. Then, install the required project dependencies using the following command:

npm install

This will install the following:

  • TypeScript
  • Jest
  • Other project dependencies

Step 3: Compile TypeScript

To compile your TypeScript code to JavaScript, run the following command:

npx tsc

Step 4: Run the Jest Tests

The core functionality of this project is tested with Jest. The following tests are implemented:

  • Add Book: Tests that a book is correctly added to the inventory.
  • Borrow Book: Tests that a book can be borrowed, and updates the inventory correctly.
  • Return Book: Tests that a borrowed book can be returned, and the inventory is updated. To run the tests, use
npm run test

This will run all Jest tests and display the results in your terminal.

Step 5: Run the Application

To run the application, use the following command:

ndoe dist/index.js

Make sure your main code is located in index.ts or modify the above path accordingly.

Project Structure

The project is organized as follows:

bookstore-management/
├── dist/               # Compiled JavaScript files
├── src/                # Source TypeScript files
│   ├── book.ts         # Defines the Book class
│   ├── bookstore.ts    # Implements the Bookstore class with add, borrow, return functionality
│   └── index.ts        # Entry point for the application
├── __tests__/          # Jest test files
│   ├── book.test.ts    # Test for the add book functionality
│   ├── borrow.test.ts  # Test for the borrow book functionality
│   └── return.test.ts  # Test for the return book functionality
├── package.json        # Project metadata and dependencies
└── tsconfig.json       # TypeScript configuration

File Descriptions

  • src/book.ts: Contains the definition of the Book class.
  • src/bookstore.ts: Contains the Bookstore class that manages the book inventory and handles add, borrow, and return operations.
  • src/index.ts: The entry point for running the application.

Test Files

-tests/book.test.ts: Contains tests for adding a book. -tests/borrow.test.ts: Contains tests for borrowing a book. -tests/return.test.ts: Contains tests for returning a book.

Example Code

Here is an example of how the core classes and tests are structured.

book.ts

export class Book {
    constructor(public title: string, public author: string, public available: boolean = true) {}
}

bookstore.ts

import { Book } from './book';

export class Bookstore {
    private inventory: Book[] = [];

    addBook(book: Book): void {
        this.inventory.push(book);
    }

    borrowBook(title: string): string {
        const book = this.inventory.find(b => b.title === title && b.available);
        if (!book) {
            return 'Book is not available';
        }
        book.available = false;
        return 'Book borrowed successfully';
    }

    returnBook(title: string): string {
        const book = this.inventory.find(b => b.title === title && !b.available);
        if (!book) {
            return 'Book was not borrowed';
        }
        book.available = true;
        return 'Book returned successfully';
    }
}

book.test.ts

import { Book } from '../src/book';
import { Bookstore } from '../src/bookstore';

test('Add a new book to the inventory', () => {
    const bookstore = new Bookstore();
    const book = new Book('The Great Gatsby', 'F. Scott Fitzgerald');
    bookstore.addBook(book);
    expect(bookstore['inventory'].length).toBe(1);
});

borrow.text.ts

import { Book } from '../src/book';
import { Bookstore } from '../src/bookstore';

test('Borrow a book from the inventory', () => {
    const bookstore = new Bookstore();
    const book = new Book('1984', 'George Orwell');
    bookstore.addBook(book);
    const result = bookstore.borrowBook('1984');
    expect(result).toBe('Book borrowed successfully');
});

return.text.ts

return.test.ts
import { Book } from '../src/book';
import { Bookstore } from '../src/bookstore';

test('Return a borrowed book to the inventory', () => {
    const bookstore = new Bookstore();
    const book = new Book('To Kill a Mockingbird', 'Harper Lee');
    bookstore.addBook(book);
    bookstore.borrowBook('To Kill a Mockingbird');
    const result = bookstore.returnBook('To Kill a Mockingbird');
    expect(result).toBe('Book returned successfully');
});

License

This project is licensed under the MIT License - see the LICENSE file for details.

This should give a clear description of your project, setup instructions, and an overview of the core functionality! Let me know if you'd like to make any changes.