Skip to main content

No project description provided

Project description

Commons

Commons is a set of functions that all the services share such as: field validations, authentification, password hashing and checking ...

Utils

The utils folder contains a collection of utility functions that provide standardized processing and validation across the entire project. These functions help ensure consistency, security, and reliability.

Email handeling

This module contains functions for validating email addresses to ensure they meet the required format and structure.

Password handeling

This module provides functions for securely managing user passwords, including hashing and verification.

Response handeling

Defines the common response formats returned by the API, ensuring uniformity across endpoints. Below are the standardized response types with examples:

  1. Base Success Response

General success response for API requests.

    "data": {"id": 1, "name": "John Doe"},
    "message": "Success",
    "status": True
}
  1. Base Success Response

General error response for client-side issues.

{
    "message": "Invalid request",
    "code": 400,
    "status": False
}
  1. Unauthorized Response

When authentication is required but missing or incorrect.

{
    "message": "Unauthorized access",
    "code": 401,
    "status": False
}
  1. Forbidden Response

When a user lacks the required permissions.

{
    "message": "Forbidden: Insufficient permissions",
    "code": 403,
    "status": False
}
  1. Not Found Response

When the requested resource does not exist.

{
    "message": "Resource not found",
    "code": 404,
    "status": False
}
  1. Validation Error Response

When input validation fails.

{
    "message": "Invalid input",
    "code": 422,
    "status": False,
    "errors": {
        "email": "Invalid email format",
        "password": "Too short"
    }
}
  1. Server Error Response

When an unexpected error occurs on the server.

{
    "message": "Internal Server Error",
    "code": 500,
    "status": False
}
  1. Conflict Response

When a request conflicts with existing data (e.g., duplicate entries).

{
    "message": "Conflict: Resource already exists",
    "code": 409,
    "status": False
}
  1. Created Response

When a new resource is successfully created.

{
    "data": {"id": 1, "name": "New User"},
    "message": "Resource created successfully",
    "code": 201,
    "status": True
}
  1. No Content Response

When a request is successful but has no content to return.

{
    "message": "No content available",
    "code": 204,
    "status": True
}

Validation

This module contains a set of validation tools to ensure the integrity of user-input data before it is processed or stored.

Supported Validations:

  • Full Name Validation: Ensures that names contain only letters, are properly formatted, and include at least two words.
  • Company Name Validation: Checks that company names are correctly structured, allowing only valid characters and ensuring they start with a letter.
  • Password Validation: Verifies that passwords meet security standards when first entered, enforcing rules such as length, uppercase/lowercase letters, digits, and special characters.

These validation functions help maintain data integrity and prevent improper or malicious input from entering the system.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coifstackcommons-1.0.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file coifstackcommons-1.0.tar.gz.

File metadata

  • Download URL: coifstackcommons-1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for coifstackcommons-1.0.tar.gz
Algorithm Hash digest
SHA256 a619c19e245268fa61a9812b76a8c7c74e101fbc0036b6204ba896a1d0204920
MD5 8a4c759b0b7e7a8c24b61776bc4fa209
BLAKE2b-256 2eb1e3fa9dc627e67799a363eb3aaf9b0dac558cbe4aff81ee52194235c7b952

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page