Skip to content

Commit

Permalink
feat: use strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
montasim committed Aug 14, 2024
1 parent c16ca7e commit 3ba115e
Show file tree
Hide file tree
Showing 145 changed files with 290 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/__tests__/errorHandlingMiddleware.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

import request from 'supertest';
import express from 'express';

Expand Down
2 changes: 2 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file sets up the main Express application with various middleware for security,
* logging, body parsing, data sanitization, routing, and error handling. It imports configurations
Expand Down
2 changes: 2 additions & 0 deletions src/configuration/compression.configuration.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file configures and exports the compression middleware setup for the
* application server. The compression middleware is used to compress response bodies for
Expand Down
2 changes: 2 additions & 0 deletions src/configuration/configuration.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This module configures and validates environment variables for the application
* using dotenv and Joi. It imports configurations, applies environment-specific settings,
Expand Down
2 changes: 2 additions & 0 deletions src/configuration/cors.configuration.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the CORS (Cross-Origin Resource Sharing) configuration for the
* application's server. CORS is a security feature that allows or restricts requested resources on a web
Expand Down
2 changes: 2 additions & 0 deletions src/configuration/googleDrive.configuration.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This module sets up and configures the authentication mechanism for Google Drive API
* using JSON Web Tokens (JWT). It uses the @googleapis/drive package to interact with Google Drive,
Expand Down
2 changes: 2 additions & 0 deletions src/configuration/helmet.configuration.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This module configures the Helmet middleware settings for the application's Express server.
* Helmet helps secure Express apps by setting various HTTP headers to prevent common web vulnerabilities.
Expand Down
2 changes: 2 additions & 0 deletions src/configuration/hpp.configuration.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This module configures and extends the HTTP Parameter Pollution (HPP) protection
* middleware for an Express application. HPP attacks involve sending multiple HTTP parameters of the
Expand Down
2 changes: 2 additions & 0 deletions src/configuration/morgan.configuration.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This module configures the morgan logger middleware for use in an Express application.
* Morgan is a middleware that logs HTTP requests and responses, providing insights into the traffic
Expand Down
2 changes: 2 additions & 0 deletions src/configuration/sanitizeRequest.configuration.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This module configures and implements a sanitization middleware using DOMPurify with a JSDOM window object.
* It is designed to cleanse incoming request data (body, query parameters, and URL parameters) in an Express application
Expand Down
2 changes: 2 additions & 0 deletions src/constant/accessTypes.constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This module defines constants for different access types within the application.
* It provides a standardized way to reference user roles and permissions across the codebase,
Expand Down
2 changes: 2 additions & 0 deletions src/constant/constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This module defines a collection of constants used throughout the application.
* It centralizes various settings and predefined values, such as maximum and minimum lengths for user inputs
Expand Down
2 changes: 2 additions & 0 deletions src/constant/default.constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This module defines and exports default constants used throughout the application, specifically
* for default image URLs. It provides organized and easy-to-reference image links for various user profiles based
Expand Down
2 changes: 2 additions & 0 deletions src/constant/envTypes.constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This module defines and exports constants for different environment types used within the application.
* These environment constants are essential for configuring the application differently based on the current runtime
Expand Down
2 changes: 2 additions & 0 deletions src/constant/errorCodes.constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview Defines common Node.js system error codes for handling system-level errors.
* These error codes are used by the Node.js API in response to operations like file access,
Expand Down
2 changes: 2 additions & 0 deletions src/constant/fileExtensions.constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview Defines common file extension types for use in API responses.
* These file extension types represent various types of files that can be served by the API.
Expand Down
2 changes: 2 additions & 0 deletions src/constant/httpStatus.constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview Defines common HTTP status codes for use in API responses.
* These status codes represent various states of HTTP responses and are
Expand Down
2 changes: 2 additions & 0 deletions src/constant/mimeTypes.constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview Defines common MIME types for use in API responses.
* These MIME types represent various types of content that can be served by the API.
Expand Down
2 changes: 2 additions & 0 deletions src/constant/patterns.constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* Regular expression for validating email addresses.
*
Expand Down
2 changes: 2 additions & 0 deletions src/constant/routes.constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This module defines and exports a structured collection of constants for routing and permissions
* management in the application. It encapsulates route names and permission keys for various features within the system,
Expand Down
2 changes: 2 additions & 0 deletions src/middleware/authenticate.middleware.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This module implements a middleware function for role-based authentication and authorization
* within an Express application. It verifies the presence and validity of an authentication token, decodes it,
Expand Down
2 changes: 2 additions & 0 deletions src/middleware/cache.middleware.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This module provides caching middleware functionalities for an Express application using NodeCache.
* It includes functions to create cache entries based on request URLs and methods, and to invalidate cache entries
Expand Down
2 changes: 2 additions & 0 deletions src/middleware/upload.middleware.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This module configures and exports a middleware for handling file uploads in an Express application
* using the multer library. The configured middleware uses memory storage, which means that files are stored in
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/admin/admin.constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file exports an object `adminConstants` which contains various constants
* used for validating admin-related data. These constants include minimum and maximum lengths
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/admin/admin.controller.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file exports an object `adminController` which contains methods for managing admin-related operations.
* These methods are created by utilizing a shared controller utility and an admin service. The methods include creating a new admin,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/admin/admin.model.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the Mongoose schema for the Admin model. The schema includes
* fields for personal details, contact information, department, designation, authentication
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/admin/admin.routes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file sets up the Express router for admin-related routes. It includes routes for
* creating a new admin, verifying an admin, resending verification emails, requesting a new password,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/admin/admin.schema.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines and exports Joi validation schemas for admin-related operations.
* These schemas are used to validate the input data for various admin endpoints, including
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/admin/admin.service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines and exports the `adminService` object, which contains various
* asynchronous functions to manage admin-related operations. These functions include creating a new admin,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/admin/admin.validator.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines and exports the `adminValidator` object, which contains middleware functions
* for validating admin-related requests using Joi schemas. Each function validates a specific request property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines and exports constants used for logging admin activities.
* It includes various action types that represent different activities performed by admin users.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the Mongoose schema for logging administrative activities.
* The schema captures information about user actions, including the user ID, action type,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/api.routes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This module defines the main router for the application, which handles various routes for different functionalities.
* It includes routes for authentication, book management, detection services, publications, subjects, trending items, user management, writer management, permissions, roles, admin operations, pronouns, and user profiles.
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/auth/auth.controller.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines and exports the `authController` object, which contains methods for managing
* authentication-related operations. These methods are created by utilizing a shared controller utility and an
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/auth/auth.routes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file sets up the Express router for authentication-related routes.
* It includes routes for login, logout, requesting a new password, resending verification emails,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/auth/auth.schema.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines and exports Joi validation schemas for authentication-related operations.
* These schemas are used to validate the input data for various authentication endpoints, including
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/auth/auth.service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines and exports the `authService` object, which contains various
* asynchronous functions to manage authentication-related operations. These functions include
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/auth/auth.validator.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines and exports the `authValidator` object, which contains middleware functions
* for validating authentication-related requests using Joi schemas. Each function validates a specific request
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/detect/detect.controller.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines and exports the controller for handling detection-related requests.
* The controller uses an async error handler to process the incoming requests, invoke the detection service,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/detect/detect.routes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file sets up the Express router for handling detection-related HTTP requests.
* The router defines the routes and their corresponding handlers, utilizing the detect controller
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/detect/detect.service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the detectService, which processes incoming requests to detect
* user-agent data, including browser, OS, device type, IP address, and other relevant information.
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/permissions/permission.routes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file sets up the routes for permissions-related operations in an Express application.
* It defines the endpoints for creating, retrieving, updating, and deleting permissions,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/permissions/permissions.constant.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines constants for permissions-related operations.
* These constants include validation criteria for permission names, such as length
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/permissions/permissions.controller.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines and exports the controller for handling permissions-related operations.
* It utilizes a shared controller to define common CRUD operations such as creating, retrieving, updating, and deleting permissions.
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/permissions/permissions.model.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the Mongoose schema for the Permissions model. The schema includes
* fields for permission details, such as name and status, and includes shared schema components for
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/permissions/permissions.schema.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines various Joi schemas for validating permissions-related data. The
* schemas include base validation for permission fields, as well as specific schemas for creating,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/permissions/permissions.service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the service functions for managing permissions. These services include
* functions for creating, retrieving, updating, and deleting permissions. The services interact with the
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/permissions/permissions.validator.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines validation middleware for permissions-related API requests. The
* middleware functions use Joi schemas to validate request data for creating, retrieving, updating,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/privacySettings/privacySettings.constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the privacy settings for user profiles, including constants for
* profile visibility levels. The available visibility levels determine who can view a user's profile.
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/privacySettings/privacySettings.rules.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the rules for privacy settings based on the user's profile visibility
* level. The rules determine which fields are visible to different types of users, such as the public,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/pronouns/pronouns.constant.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines constants for validating pronouns-related data. It includes
* constraints on the length of names and a regular expression pattern for validating names
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/pronouns/pronouns.controller.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the controller functions for managing pronouns. These functions
* handle the creation, retrieval, updating, and deletion of pronouns by interacting with the
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/pronouns/pronouns.model.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the Mongoose schema for the Pronouns model. The schema includes
* fields for pronouns details, such as name and status, and includes shared schema components for
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/pronouns/pronouns.routes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the routes for managing pronouns using Express. It includes routes
* for creating, retrieving, updating, and deleting pronouns, and applies various middlewares for
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/pronouns/pronouns.schema.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines various Joi schemas for validating pronouns-related data. The
* schemas include base validation for pronouns fields, as well as specific schemas for creating,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/pronouns/pronouns.service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the service functions for managing pronouns. These services include
* functions for creating, retrieving, updating, and deleting pronouns. The services interact with the
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/pronouns/pronouns.validator.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines validation middleware for pronouns-related API requests. The
* middleware functions use Joi schemas to validate request data for creating, retrieving, updating,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/roles/roles.constant.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines constants for validating roles-related data. It includes
* constraints on the length of role names and patterns to ensure they adhere to the required
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/roles/roles.controller.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the controller functions for managing roles. These functions
* handle the creation, retrieval, updating, and deletion of roles by interacting with the
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/roles/roles.model.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the Mongoose schema for the Roles model. The schema includes
* fields for role details, such as name and permissions, and includes shared schema components
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/roles/roles.routes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the routes for managing roles using Express. It includes routes
* for creating, retrieving, updating, and deleting roles, and applies various middlewares for
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/roles/roles.schema.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines various Joi schemas for validating roles-related data. The
* schemas include base validation for role fields, as well as specific schemas for creating,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/roles/roles.service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the service functions for managing roles. These services include
* functions for creating, retrieving, updating, and deleting roles. The services interact with the
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/roles/roles.validator.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines validation middleware for roles-related API requests. The
* middleware functions use Joi schemas to validate request data for creating, retrieving, updating,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/userProfile/userProfile.controller.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the controller functions for managing user profiles. These functions
* handle the retrieval of user profiles by interacting with the userProfile service. Each function utilizes
Expand Down
2 changes: 2 additions & 0 deletions src/modules/api/userProfile/userProfile.routes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* @fileoverview This file defines the Express router for managing user profiles. It includes routes
* for retrieving a user profile by username and applies a methodNotSupported middleware for unsupported
Expand Down
Loading

0 comments on commit 3ba115e

Please sign in to comment.