Skip to content

techmateTristan/inventory-control

Repository files navigation

TechMate Inventory Management Project

author: Tristan Garside
date: 27-12-2022

Overview

A small database with a web frontend to manage an inventory, principally of devices (laptops, desktops, tablets and phones). Additionally the inventory will include office furniture, stationery and miscellaneous items.

As the main focus 'devices' will be richer with fields such as product IDs, OS, unique IDs, and fields relating to state and pending maintenance etc.

All CRUD operations are to be supported, and with a range of useful views.

Installation and Setup of tools

Installation on Fedora 37 as at 27-12-2022

  1. install snap if not already done so
    $ sudo dnf install snapd
  2. Follow the exact instructions as described in this page in the couchdb github repo

Setup

Opening interface to local network

  1. Stop couchdb $ sudo snap stop couchdb
  2. edit the local.ini file to change the bind address:

    sudo micro /var/snap/couchdb/9/etc/local.ini
[chttpd]
port = 5984
bind_address = 0.0.0.0
...

[httpd]
bind_address = 0.0.0.0
...
  1. Open port 5984 in zone 'home' and limit ip range to local network only, via firewalld:
    $ sudo firewall-cmd --zone=home --add-source=192.168.100.0/24
    $ sudo firewall-cmd --zone=home --add-port=5984/tcp
    $ sudo firewall-cmd --zone=home --list-all
    $ sudo firewall-cmd --runtime-to-permanent
    $ sudo systemctl restart firewalld

optionally pen-test the port from a computer external to the network (when couchdb service is running):
$ sudo nmap -sT -p 5984 <ip-address>

port should return "filtered"

  1. Find and note down server ip:
    ip addr | grep "inet " | tail -1

  2. Restart couchdb:
    sudo snap start couchdb

Interacting with couchdb via cURL

  • See top-level view (pipe through python -mjson.tool to prettify JSON response)
    curl -X GET 'http://admin:<password>@<ip-address>:5984' | python -mjson.tool
  • Create a test database:
    curl -X PUT 'http://admin:<password>@<ip-address>:5984/test
  • Create a document:
    curl -X PUT 'http://admin:<password>@<ip-address>:5984/test/doc1' -d {"name": "Polly"}
  • View that document:
    curl -X GET 'http://admin:<password>@<ip-address>:5984/test/doc1' | python -mjson.tool

Interacting with couchdb via Browser ("Fauxton ")

url: <ip-address>:5984/_utils

NodeJS and npm

$ sudo dnf install nodejs
npm (node package manager) is installed at ther same time as a (weak) dependency

$ npm init
initialises the package.json which organises all the modules (dependencies) the project will use

Node Dependencies

$ npm install express body-parser ejs node-couchdb --save

About

Work in progress

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published