Skip to content

Fragments Microservice is a cloud-based solution that provides a REST API for creating, retrieving, updating, and deleting text and image fragments, with robust authorization, format conversion, and scalability features.

Notifications You must be signed in to change notification settings

alexsam29/fragments

Repository files navigation

Fragments Microservice

A cloud-based solution that provides a REST API for creating, retrieving, updating, and deleting text and image fragments, with robust authorization, format conversion, and scalability features.

Scripts

Run Lint

npm run lint

Run this script to identify errors and potential issues in the source code via ESLint.

ESLint documentation can be found here.

Run Server

npm start

This will run the server normally on http://localhost:8080.

Run Dev Server

npm run dev

The dev script will run the server on http://localhost:8080 via Nodemon. It will monitor for any changes in the source code and automatically restart the server.

Run Debugger

npm run debug

The debugging script is similar to the dev script, but connects a debugger to the process currently running on http://localhost:8080.

For instructions on using the VSCode debugger:

Unit Testing Scripts

Run All Unit Tests

This script runs all unit tests for all testing files serially.

npm test

Run Unit Tests for Specified File

This script runs unit tests only for the testing file specified at the end of the command.

npm test filename.test.js

Run Unit Tests & Watch for File Changes

Similar to npm test, but will watch files for changes and re-run tests when a file is updated/saved without needing to input the command again.

npm run test:watch

Generate Coverage Report

Also similar to npm test, but this script will generate a coverage report. The coverage report lists all of the files affected during testing and what percentage of statements, branches, functions, and lines were touched during the tests. It also includes which lines have no coverage at all.

npm run coverage

In addition to the terminal, the coverage report can be accessed by opening the HTML file in a browser. The file can be accessed through the coverage directory generated by the script. File path --> coverage/lcov-report/index.html.

Docker

Build

docker build -t fragments:latest .

This command will build the Dockerfile located in the current directory (i.e., .). Gives it a tag using -t fragments:latest, which defines a name (i.e., fragments) and a version (i.e., latest).

Run

docker run --rm --name fragments fragments:latest

Flags:

  • --rm: Automatically clean up the container and remove the file system when the container exits.
  • --name: Add custom container name.
  • --env-file: Specify env file to use.
  • -p: Map a container’s port or a range of ports to the host explicitly.
  • -e: Pass environment variables to your containers.
  • -d: Detaches the container process and runs it in the background

Run with env file

docker run --rm --name fragments --env-file [ENV FILE] fragments:latest

Run on specified host and container port

docker run --rm --name fragments --env-file [ENV FILE] -p [HOST PORT #]:[CONTAINER PORT #] fragments:latest

Run with server logs

docker run --rm --name fragments --env-file [ENV FILE] -e LOG_LEVEL=debug -p [HOST PORT #]:[CONTAINER PORT #] fragments:latest

Run detached container with server logs

docker run --rm --name fragments --env-file [ENV FILE] -e LOG_LEVEL=debug -p [HOST PORT #]:[CONTAINER PORT #] -d fragments:latest

Tag Images

docker tag [IMAGE_NAME]:[TAG] [NEW_IMAGE_NAME]:[TAG]

Push to Docker Hub

docker push [USERNAME]/[IMAGE]:[TAG]

Push All Tags

docker push --all-tags [USERNAME]/[IMAGE]

About

Fragments Microservice is a cloud-based solution that provides a REST API for creating, retrieving, updating, and deleting text and image fragments, with robust authorization, format conversion, and scalability features.

Resources

Stars

Watchers

Forks

Packages

No packages published