Category: Blog

  • HouseholdOrganizer-App

    HouseholdOrganizer – App

    made-with-spring

    OpenGeoResearch Logo

    A progressive web app for collaborative digital management and dissolution of a household. I built this app to organize a household I needed to straighten and dissolute during the corona virus pandemic in 2020. By using this app I my family was able to select items they wanted to keep easily in a smartphone app. Furthermore, it allowed to pack everything together whilst storing the locatin information in a database to digitally search for stuff and getting a position in a shelf or box as a result.

    This app was built with Nuxt.js as a progressive web app and connects to a REST API written in Java.

    Features

    • Add stuff by taking a picture and adding some meta data
    • Save the location of stuff (shelf, box, Item-ID, …)
    • Enable people to select stuff they like to have
    • Search for stuff by category, historical location or keywords
    • See what’s inside of a box without opening it
    • Get an overview of stuff you marked to keep for your self

    Screenshots

    See details of stuff

    List your stuff

    Search for stuff and get it’s location

    Select stuff you want to keep

    Visit original content creator repository https://github.com/thlemm/HouseholdOrganizer-App
  • HouseholdOrganizer-App

    HouseholdOrganizer – App

    made-with-spring

    OpenGeoResearch Logo

    A progressive web app for collaborative digital management and dissolution of a household. I built this app to organize a household I needed to straighten and dissolute during the corona virus pandemic in 2020. By using this app I my family was able to select items they wanted to keep easily in a smartphone app. Furthermore, it allowed to pack everything together whilst storing the locatin information in a database to digitally search for stuff and getting a position in a shelf or box as a result.

    This app was built with Nuxt.js as a progressive web app and connects to a REST API written in Java.

    Features

    • Add stuff by taking a picture and adding some meta data
    • Save the location of stuff (shelf, box, Item-ID, …)
    • Enable people to select stuff they like to have
    • Search for stuff by category, historical location or keywords
    • See what’s inside of a box without opening it
    • Get an overview of stuff you marked to keep for your self

    Screenshots

    See details of stuff

    List your stuff

    Search for stuff and get it’s location

    Select stuff you want to keep

    Visit original content creator repository https://github.com/thlemm/HouseholdOrganizer-App
  • docker-stats-histo

    Ultra-light docker monitor

    This light tool permits:

    • to export docker container memory usage in a database data.sqlite
    • display curves of the memory usages in an interactive html report

    The export and the display are two different parts. This allows to run the display in another machine.

    Install python virtual env

    sudo apt install python3.8 python3.8-venv
    python3.8 -m venv venv
    . venv/bin/activate
    pip install --upgrade pip
    pip install -r requirements.txt

    The python env is now callable in venv/bin/python.
    Or by activating the virtual env:

    ./venv/bin/activate
    python --version
    ...
    deactivate

    Export stats

    ./save_docker_stats.sh
    or
    python save_docker_stats.py

    Display stats

    This step permits to generate an html interactive render from the sqlite stats file.
    It is simple, just run:

    ./generate_html.sh

    The report is now accessible in stats.html.

    Automations using cron

    Open the cron tab in edition mode:

    crontab -e

    Then add those lines (to run the check each 10 minutes and a html generation each hour)

    */10 * * * * /path/to/docker-stats-histo/save_docker_stats.sh > /dev/null  2>&1
    00 */1 * * * /path/to/docker-stats-histo/generate_html.sh > /dev/null  2>&1

    Note:

    • Normally cron send task outputs (echo) via mail. As the MTA (Mail Transfer Agent),
      may not be set up, the crontab line redirect the outputs into /dev/null.
      It can also be a path to a log file.
    • No sudo is needed, crontab is called with current user.

    Advanced parameters

    Both python scripts can have a finer configuration (sqlite and html paths).
    To see all accepted parameters use -h flag, like

    python save_docker_stats.py -h
    python generate_html.py -h

    Visit original content creator repository
    https://github.com/boonisz/docker-stats-histo

  • docker-stats-histo

    Ultra-light docker monitor

    This light tool permits:

    • to export docker container memory usage in a database data.sqlite
    • display curves of the memory usages in an interactive html report

    The export and the display are two different parts. This allows to run the display in another machine.

    Install python virtual env

    sudo apt install python3.8 python3.8-venv
    python3.8 -m venv venv
    . venv/bin/activate
    pip install --upgrade pip
    pip install -r requirements.txt

    The python env is now callable in venv/bin/python.
    Or by activating the virtual env:

    ./venv/bin/activate
    python --version
    ...
    deactivate

    Export stats

    ./save_docker_stats.sh
    or
    python save_docker_stats.py

    Display stats

    This step permits to generate an html interactive render from the sqlite stats file.
    It is simple, just run:

    ./generate_html.sh

    The report is now accessible in stats.html.

    Automations using cron

    Open the cron tab in edition mode:

    crontab -e

    Then add those lines (to run the check each 10 minutes and a html generation each hour)

    */10 * * * * /path/to/docker-stats-histo/save_docker_stats.sh > /dev/null  2>&1
    00 */1 * * * /path/to/docker-stats-histo/generate_html.sh > /dev/null  2>&1

    Note:

    • Normally cron send task outputs (echo) via mail. As the MTA (Mail Transfer Agent),
      may not be set up, the crontab line redirect the outputs into /dev/null.
      It can also be a path to a log file.
    • No sudo is needed, crontab is called with current user.

    Advanced parameters

    Both python scripts can have a finer configuration (sqlite and html paths).
    To see all accepted parameters use -h flag, like

    python save_docker_stats.py -h
    python generate_html.py -h

    Visit original content creator repository
    https://github.com/boonisz/docker-stats-histo

  • anyledger-hub-Pre-Alpha

    AnyLedger Hub

    Overview

    AnyLedger Hub is the bridge connecting the IoT device featuring the embedded wallet and a given blockchain. It consist of a series of moving pieces like the LWM2M server to remotely manage the devices (device lifecycle management, over-the-air updates, etc.), the blockchain nodes and decentralised storage solutions. It also includes a set of standard smart contracts implementing features like digital twin, decentralised access control, multisignature contracts, etc.

    What is inside the current repo:

    1. It is an umbrella repo for the following submodules:
    • anyledger-hub-web – AnyLedger Hub static HTML/JavaScript web page served by the IPFS

    • decentralized-storage – IPFS node responsible for hosting data in decentralised fashion. Can be used for instance to store IoT data, HTML/JavaScript web pages, object graphs and more.

    • ethereum-private-network – Private Ethereum full node. Currently not used.

    • leshan – LWM2M (Lightweight Machine 2 Machine) Server which is storing its object graph on IPFS and Ethereum

    • smart-contracts – Ethereum and HyperLedger Smart Contracts which are used for Digital Twin Root of Trust, Access Control, etc.

    1. This repo also contains Docker Composer file which spins the whole platform on a single machine. It is meant to be used for development and demo purposes.

    Example Features

    -Decentralised Access Control

    The device owner can be interested in setting an access control policy for the remote access of the device. This can be achieved in a decentralized fashion, that is relying on private keys authentication and without the need of a central server, by storing the access control policy on a smart contract.

    -Decentralised Digital Twin

    A way to achieve this with AnyLedger Hub is the following: the devices registered on Leshan are stored on IPFS together with their metadata. Moreover, thanks to another smart contract, every device id is associated to the respective IPFS hash. Every additional update of the device status can be included on IPFS by storing the previous hash together with the new metadata, therefore creating an immutable history of the device lifecycle.

    Prerequisites

    1. Install latest Java Development Kit
    1. Install Maven
    • On Linux: sudo apt install maven

    • On MacOS: brew install maven

    • On Windows:

    1. Install Docker and Docker Compose

    Installation

    1. Clone this repo: git clone https://github.com/AnyLedger/anyledger-hub --recursive. Notice that the repo has submodules

    2. Go to /anyledger-hub/leshan/ and build the project with mvn package

    3. Build Docker images by going to the folder containing docker-compose.yml and type docker-compose build

    4. Run Docker Compose in the root of the repo: docker-compose up

    The web app is hosted on IPFS. To visualize it, go to:

    http://0.0.0.0:8080/ipfs/QmSoQUcGK4zQ78zrqP5DskDNnJ9x3M7cwS5rz7v4WhPRQZ/

    but replacing this dummy hash with hash of the index.html file, which can be found after running docker-compose up.

    Tips

    To update all the submodules: git submodule update --remote --recursive

    Troubleshooting

    -In step 2, the leshan build can sometimes fail. Don’t panic and try again 🙂

    -In step 3, you should input eval $(docker-machine env default) after

    ERROR: Couldn't connect to Docker daemon - you might need to run docker-machine start default.

    if the machine is already running.

    • In step 3 of Installation, you may be encounter an error due to having a different installed version for openjdk. For instance:

    `apk add –no-cache openjdk8=8.151.12-r0

    ERROR: unsatisfiable constraints:

    ERROR: Service ‘lwm2m-client_1’ failed to build:…`

    To solve it, replace the old version in the project with the new one.

    -latest version of trufflesuite/ganache-cli may give errors in truffle like:

    Error: Invalid JSON RPC response: ""

    Use v6.1.0 instead.

    Visit original content creator repository
    https://github.com/Anylsite/anyledger-hub-Pre-Alpha

  • Bannerlord.MBOptionScreen


    CodeFactor Code Climate maintainability
    GitHub Workflow Status (event) GitHub Workflow Status (event)

    NexusMods Mod Configuration Menu NexusMods Mod Configuration Menu NexusMods Mod Configuration Menu NexusMods Mod Configuration Menu
    Steam Mod Configuration Menu Steam Downloads Steam Views Steam Subscriptions Steam Favorites

    AKA MBOptionScreen Standalone.
    Previously, a fork of ModLib that was de-forked.
    Sources available at GitHub!
    Credits to Drogean for the MCM Logos!

    MCM is a Mod Options screen library designed to let modders use its API for defining the options.

    MCM supports three setting types – Global, PerCampaign and PerSave. Global are shared across characters and saves, PerCampaign are persistent within a single campaign, PerSave are stored within the save file!

    It provides 5 types of options:

    • Bool
    • Int Slider / Textbox
    • Float Slider / Textbox
    • Textbox
    • Dropdown
    • Button

    The settings can be defined at compile time by using the Attribute API and at runtime by using the Fluent Builder.

    MCM uses the following 3 framework level libraries:

    • Harmony is used to have a single 0Harmony.dll across the game.
    • ButterLib is a general modding library that eases mod development.
    • UIExtenderEx is an general UI manipulation library.

    See the Docs for more details!

    Installation

    Players

    Requires Bannerlord.Harmony, Bannerlord.UIExtenderEx, Bannerlord.ButterLib.

    Developers

    Add this to your .csproj. Please not that IncludeAssets="compile" is very important!

      <ItemGroup>
        <PackageReference Include="Bannerlord.MCM" Version="4.3.16" IncludeAssets="compile" />
      </ItemGroup>

    FAQ

    How do I install it?

    1. Find the Modules folder in your Bannerlord installation location. For Steam users, this is usually here: C:\Program Files (x86)\Steam\steamapps\common\Mount & Blade II Bannerlord\Modules
    2. Download the latest version of this mod and drop the folder inside Modules from the archive into your game’s Modules folder.
    3. Start the Mount & Blade II: Bannerlord launcher and select all Mod Configuration Menu mods to be loaded.

    Your Modules folder structure should look something like this:
    Your mod order in the launcher should look something like this:

    Unblocking DLL’s

    You may need to right click on every *.dll files, click Properties, and click Unblock if you extracted the zip file with Windows Explorer or other programs that try to secure extracted files.

    Harmony installation issues:

    Check Harmony’s Troubleshooting for more info on how to fix it.

    Crashes on v1.0.0-v1.0.3 with Vortex used

    Check this comment

    Visit original content creator repository https://github.com/Aragas/Bannerlord.MBOptionScreen
  • Generative-Adversarial-Networks-Specialization-DeepLearning.ai

    Generative Adversarial Networks (GANs) Specialization


    Azmine Toushik Wasi – Certificate


    About this Specialization

    About GANs

    Generative Adversarial Networks (GANs) are powerful machine learning models capable of generating realistic image, video, and voice outputs.

    Rooted in game theory, GANs have wide-spread application: from improving cybersecurity by fighting against adversarial attacks and anonymizing data to preserve privacy to generating state-of-the-art images, colorizing black and white images, increasing image resolution, creating avatars, turning 2D images to 3D, and more.

    About this Specialization

    The DeepLearning.AI Generative Adversarial Networks (GANs) Specialization provides an exciting introduction to image generation with GANs, charting a path from foundational concepts to advanced techniques through an easy-to-understand approach. It also covers social implications, including bias in ML and the ways to detect it, privacy preservation, and more.

    Build a comprehensive knowledge base and gain hands-on experience in GANs. Train your own model using PyTorch, use it to create images, and evaluate a variety of advanced GANs.


    Applied Learning Project

    • Course 1: In this course, you will understand the fundamental components of GANs, build a basic GAN using PyTorch, use convolutional layers to build advanced DCGANs that processes images, apply W-Loss function to solve the vanishing gradient problem, and learn how to effectively control your GANs and build conditional GANs.

    • Course 2: In this course, you will understand the challenges of evaluating GANs, compare different generative models, use the Fréchet Inception Distance (FID) method to evaluate the fidelity and diversity of GANs, identify sources of bias and the ways to detect it in GANs, and learn and implement the techniques associated with the state-of-the-art StyleGAN.

    • Course 3: In this course, you will use GANs for data augmentation and privacy preservation, survey more applications of GANs, and build Pix2Pix and CycleGAN for image translation.


    There are 3 Courses in this Specialization

    COURSE 1

    Build Basic Generative Adversarial Networks (GANs)

    4.7stars – 1,653 ratings

    In this course, you will:

    • Learn about GANs and their applications
    • Understand the intuition behind the fundamental components of GANs
    • Explore and implement multiple GAN architectures
    • Build conditional GANs capable of generating examples from determined categories

    COURSE 2

    Build Better Generative Adversarial Networks (GANs)

    4.7stars – 573 ratings

    In this course, you will:

    • Assess the challenges of evaluating GANs and compare different generative models
    • Use the Fréchet Inception Distance (FID) method to evaluate the fidelity and diversity of GANs
    • Identify sources of bias and the ways to detect it in GANs
    • Learn and implement the techniques associated with the state-of-the-art StyleGANs

    COURSE 3

    Apply Generative Adversarial Networks (GANs)

    4.8stars – 459 ratings

    In this course, you will:

    • Explore the applications of GANs and examine them wrt data augmentation, privacy, and anonymity
    • Leverage the image-to-image translation framework and identify applications to modalities beyond images
    • Implement Pix2Pix, a paired image-to-image translation GAN, to adapt satellite images into map routes (and vice versa)
    • Compare paired image-to-image translation to unpaired image-to-image translation and identify how their key difference necessitates different GAN architectures
    • Implement CycleGAN, an unpaired image-to-image translation model, to adapt horses to zebras (and vice versa) with two GANs in one.

    Instructors

    Sharon Zhou

    Instructor Computer Science, Stanford University

    Eda Zhou

    Curriculum Developer

    Eric Zelikman

    Curriculum Engineer

    50,046 Learners


    Offered by

    DeepLearning.AI

    DeepLearning.AI is an education technology company that develops a global community of AI talent.

    Visit original content creator repository https://github.com/azminewasi/Generative-Adversarial-Networks-Specialization-DeepLearning.ai
  • Generative-Adversarial-Networks-Specialization-DeepLearning.ai

    Generative Adversarial Networks (GANs) Specialization


    Azmine Toushik Wasi – Certificate


    About this Specialization

    About GANs

    Generative Adversarial Networks (GANs) are powerful machine learning models capable of generating realistic image, video, and voice outputs.

    Rooted in game theory, GANs have wide-spread application: from improving cybersecurity by fighting against adversarial attacks and anonymizing data to preserve privacy to generating state-of-the-art images, colorizing black and white images, increasing image resolution, creating avatars, turning 2D images to 3D, and more.

    About this Specialization

    The DeepLearning.AI Generative Adversarial Networks (GANs) Specialization provides an exciting introduction to image generation with GANs, charting a path from foundational concepts to advanced techniques through an easy-to-understand approach. It also covers social implications, including bias in ML and the ways to detect it, privacy preservation, and more.

    Build a comprehensive knowledge base and gain hands-on experience in GANs. Train your own model using PyTorch, use it to create images, and evaluate a variety of advanced GANs.


    Applied Learning Project

    • Course 1: In this course, you will understand the fundamental components of GANs, build a basic GAN using PyTorch, use convolutional layers to build advanced DCGANs that processes images, apply W-Loss function to solve the vanishing gradient problem, and learn how to effectively control your GANs and build conditional GANs.

    • Course 2: In this course, you will understand the challenges of evaluating GANs, compare different generative models, use the Fréchet Inception Distance (FID) method to evaluate the fidelity and diversity of GANs, identify sources of bias and the ways to detect it in GANs, and learn and implement the techniques associated with the state-of-the-art StyleGAN.

    • Course 3: In this course, you will use GANs for data augmentation and privacy preservation, survey more applications of GANs, and build Pix2Pix and CycleGAN for image translation.


    There are 3 Courses in this Specialization

    COURSE 1

    Build Basic Generative Adversarial Networks (GANs)

    4.7stars – 1,653 ratings

    In this course, you will:

    • Learn about GANs and their applications
    • Understand the intuition behind the fundamental components of GANs
    • Explore and implement multiple GAN architectures
    • Build conditional GANs capable of generating examples from determined categories

    COURSE 2

    Build Better Generative Adversarial Networks (GANs)

    4.7stars – 573 ratings

    In this course, you will:

    • Assess the challenges of evaluating GANs and compare different generative models
    • Use the Fréchet Inception Distance (FID) method to evaluate the fidelity and diversity of GANs
    • Identify sources of bias and the ways to detect it in GANs
    • Learn and implement the techniques associated with the state-of-the-art StyleGANs

    COURSE 3

    Apply Generative Adversarial Networks (GANs)

    4.8stars – 459 ratings

    In this course, you will:

    • Explore the applications of GANs and examine them wrt data augmentation, privacy, and anonymity
    • Leverage the image-to-image translation framework and identify applications to modalities beyond images
    • Implement Pix2Pix, a paired image-to-image translation GAN, to adapt satellite images into map routes (and vice versa)
    • Compare paired image-to-image translation to unpaired image-to-image translation and identify how their key difference necessitates different GAN architectures
    • Implement CycleGAN, an unpaired image-to-image translation model, to adapt horses to zebras (and vice versa) with two GANs in one.

    Instructors

    Sharon Zhou

    Instructor Computer Science, Stanford University

    Eda Zhou

    Curriculum Developer

    Eric Zelikman

    Curriculum Engineer

    50,046 Learners


    Offered by

    DeepLearning.AI

    DeepLearning.AI is an education technology company that develops a global community of AI talent.

    Visit original content creator repository https://github.com/azminewasi/Generative-Adversarial-Networks-Specialization-DeepLearning.ai
  • fsa-group4

    Game of Treasures Website shields.io

    Project on location-based gaming App. It is a full stack gaming application which progresses with directions.

    Group Members


    Rajeshwari Rudravaram

    💻 linkedin

    Bhaskharm

    💻 linkedin

    Full Stack App

    • A touch-based gaming app, where a user will find the target location with the help of directions provide by the app with respect to User location.
    • If a user touches or clicks the first color of app then it provides a valid treasure location from the given set of locations.
    • If a user touches or clicks repeatedly on second color then the device compares the current location coordinates with the target location and tells the user whether they are inside or outside the treasure location.
    • If a user is far from target location then, User will hear and see the directions in which he/she needs to move to reach the treasure location.
    • Finally, when user reaches the destination then the user will hear and see the confirmation of reaching the selected treasure location.

    Stack

    • Platform: Node(Version – v15.1.0)
    • Web Framework : Express
    • View engine : EJS
    • ORM(Object Relational Mapping) : Sequelize
    • Data store: PostgreSQL
    • API : Google Maps
    • Coding standards : Enforce AirBnB/Prettier/ESlint

    CI/CD

    • Auto-deploy from main repo is required.

    Prerequisites

    • Node.js(comes with npm)
    • GitHub
    • TortoiseGit
    • VS Code

    Development of App

    • Data store for Development: PostgreSQL

    Hosted App Link:

    Heroku hosted app link

    Project

    User Stories

    1. As a player, I want to touch/click the first color to request a valid (treasure) location.
    2. As a player, I want to hear confirmation that a location has been selected (so I can I can begin searching).
    3. As a player, I want to touch/click the second color: If I am outside the treasure location, I want to hear information to help me find the treasure location (clue? how far away? what direction to walk?)
    4. As a player, I want to touch/click the second color: If I am inside the treasure location, I want to hear and see confirmation that I have earned this treasure.
    5. As a player, after confirmation that I have earned a location, I can start a new game again.

    CRUD operations for Location

    • User can enable all CRUD options (create, read, update, delete,list) on locations.
      • create.ejs
      • delete.ejs
      • details.ejs
      • edit.ejs
      • index.ejs
      • list.ejs
    • Locations are based on circles.

    Guidelines to Contribute

    • In order to get someone’s repo into your local machine you should first fork it into repo then Clone it to your local machine.

    Step 1 – To get the fresh code

    1. Everytime you should pull the fresh code from shared cloud repo and then add or modify the code then commit it by using git add and git push commands below line interface
    2. Update your cloud repo by using git add and git push commands in command .
    git clone "https://github.com/Bhaskar2909/fsa-group4"
    git pull 
    git add .
    git push

    Step 2 – Make your contributions

    You can test the code by formatting it with Prettier and lint (clean it up) with ESLint. You can check the scripts in package.json.

    • Add required dependencies by installing them.
    1. While code is fresh, make your local edits.
    2. Verify the app still runs & standarize your code.
    npm install
    npm run start
    
    npm run prettier
    npm run lint
    npm run lint-fix

    Fix your code as suggested by the linter.

    Step 3 – To save and share your work

    1. Git add & git commit locally.
    2. Git push to the origin.
    3. In your updated GitHub repo look for “Pull Request”.

    Step 4 – Refresh the code before making any new contributions

    1. Git pull from shared repo to your local machine
    2. Git add by new files from root folder on down (git add .)
    3. Git push to your origin repo (your forked repo in the cloud)
    git pull "https://github.com/Bhaskar2909/fsa-group4.git"
    git add .
    git push

    Start Options

    Start the app by running npm run start. Until error handling is complete, a clean shutdown is better. Once error handling is complete, use npm run dev to start with nodemon. In order to update the code and see the changes evrytime locally then use the command “npm run dev” .

    npm run start

    View the application locally at http://localhost:3000/

    To Publish an App

    • Data store for production: PostgreSQL

    References

    Remainders

    • Avoid spaces in folders and file names.
    • Don’t work on stale code – “ALWAYS PULL FIRST”
    • Repo name has to be unique. and use lower case for naming convention.
    • Don’t work on your desktop – organize your repos either by class or under a common folder (e.g., github or other).
    • Deploy as you work – if everything passes tests, do add / commit / push and deploy frequently (several times a week).
    • Do hard things early. Do not delay figuring out the hard questions.
    • While adding or creating a new location, add the valid cordinates for the latitude and longitude.
    Visit original content creator repository https://github.com/baskharm/fsa-group4
  • nodejs-encryption-api-example

    Encryption API endpoints with Node.js

    Latest Release Build Status Docker Pulls

    Quality Gate Status Security Rating Maintainability Rating

    Bugs Code Smells Coverage Duplicated Lines (%)

    Introduction

    Example of encrypting/decrypting data thru an API using node.js.

    The idea with this example is to test how to store encrypted data under a datastore (ex. MongoDB) and keep control of your data by providing the encryption key for each call.

    This project doesn’t cover encryption in transit (SSL) and not meant to be used in production.

    Features

    • API storing endpoint that encrypts data with the provided key and stores it into a MongoDB collection (AES-256-GCM encryption)
    • API retrieval endpoint that decrypts data with the provided key and returns the data
    • AES-256-GCM encryption that uses a random Initialization Vector (IV) and Auth TAG
    • IV and Auth TAG stored with the encrypted data (separated by a : character)
    • Logs with correlation ID
    • Hardening of the HTTP Headers with Helmet
    • MongoDB as a data store (using Mongoose)
    • Swagger support for API specifications/documentation (WIP)
    • Health check endpoint to check if the app is still alive
    • Dockerfile to generate the Docker image
    • Docker Compose file to launch the API and MongoDB official Docker images
    • Build, test and deploy to Docker Hub with GitHub Actions
    • SonarQube code quality check (SonarCloud)
    • Unit tests and functional tests
    • Postman collection and environment

    Run locally

    Install

    node install

    Run

    npm start

    Tests

    npm test

    Tests coverage

    npm run test:coverage

    Functional tests

    npm run test:functional

    Run all the tests

    npm run test:all

    Docker

    Docker Compose

    Be sure that you are not running MongoDB + another node.js app that uses the 3000 port

    docker-compose up

    Test with Postman

    First, you need to import the Postman environment.

    There is a default encryption key and ID to have a quick look to the API.

    Download and Import the Postman environment

    Download the Postman Environment

    Run the Postman collection

    Run in Postman

    Documentation / Specifications

    You can access the documentation (Swagger) here:

    http://localhost:3000/swagger

    How it works

    Generate an Encryption key (256 bit / 32 chars length)

    You need to generate an encryption key that you will use to encrypt the data saved in MongoDB.

    You can use this online website to create your key (256 bit):

    https://www.allkeysgenerator.com

    Add secret

    Fill the following curl command with your key and value is the JSON data you want to encrypt.

    curl -X POST \
      http://127.0.0.1:3000/api/secrets/add \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -d '{
        "id": "test-01",
        "encryption_key": "p2s5v8y/B?E(H+MbQeShVmYq3t6w9z$C",
        "value": {
            "first_name": "firstname",
            "last_name": "lastname",
            "email": "email@email.com",
            "password": "app123",
            "password_confirmation": "app123"
        }
    }'

    Payload with the encryption key used in the example (will be different for you since we use a random IV):

    {
        "_id": "5c61979c82126860464dd0e8",
        "id": "test-01",
        "value": "42d0f6eb0810caaaaf5bad7477ebfc44:3572036ad7b4d77959cbc85feb364bf2c3442f7290ab210e88b00aae5a8122509df282db39ffcd092a927c4f302b93ba87f70563af8a51b29577196cc010d5514d29351ee74b64538d9004f581c911ea059be8769520075659e497a6b716ab95af692b56326a682b443d05150e90d8b75c43eabe15a27c01f240eae9edecf345436bb294b28c41087629754b01ada42c",
        "__v": 0
    }

    Note that the IV is in the first part fo the encrypted data (42d0f6eb0810caaaaf5bad7477ebfc44)

    Get secret(s)

    Get a specific ID

    You can search by ID (test-01 in this example):

    curl -X POST \
      http://127.0.0.1:3000/api/secrets \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -d '{
        "id": "test-01",
        "encryption_key": "p2s5v8y/B?E(H+MbQeShVmYq3t6w9z$C"
    }'

    This will return an array with a unique result:

    [
        {
            "id": "test-01",
            "value": {
                "first_name": "firstname",
                "last_name": "lastname",
                "email": "email@email.com",
                "password": "app123",
                "password_confirmation": "app123"
            }
        }
    ]

    Get ID with a wildcard *

    You can also search by using a wildcard * at the end of your ID (test-01-* in this example):

    curl -X POST \
      http://127.0.0.1:3000/api/secrets \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -d '{
        "id": "test-01-*",
        "encryption_key": "p2s5v8y/B?E(H+MbQeShVmYq3t6w9z$C"
    }'

    This will return an array of results:

    [
        {
            "id": "test-01-01",
            "value": {
                "first_name": "firstname",
                "last_name": "lastname",
                "email": "email@email.com",
                "password": "app123",
                "password_confirmation": "app123"
            }
        },
        {
            "id": "test-01-02",
            "value": {
                "first_name": "firstname",
                "last_name": "lastname",
                "email": "email@email.com",
                "password": "app123",
                "password_confirmation": "app123"
            }
        },
        {
            "id": "test-01-03",
            "value": {
                "first_name": "firstname",
                "last_name": "lastname",
                "email": "email@email.com",
                "password": "app123",
                "password_confirmation": "app123"
            }
        }
    ]

    TODO

    • Return an empty array if wrong encryption key instead of error
    • Swagger detailed schema
    • PM2 support under the Docker container (to restart the app in case of crash)
    Visit original content creator repository https://github.com/timoa/nodejs-encryption-api-example