{"id":18850,"library":"test-backend-schema-library","title":"Career Edge Backend Auth Library","description":"A modular authentication library for Node.js backends integrating AWS Cognito JWT validation and MongoDB connectivity. Version 2.0.3 provides a registerable module with synchronous configuration. Features token verification, database connection management, and TypeScript-first design. Differentiates through opinionated module registration pattern and direct Cognito integration.","status":"active","version":"2.0.3","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install test-backend-schema-library","lang":"bash","label":"npm"},{"cmd":"yarn add test-backend-schema-library","lang":"bash","label":"yarn"},{"cmd":"pnpm add test-backend-schema-library","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for module registration and dependency injection","package":"@nestjs/common","optional":false},{"reason":"Used for MongoDB database connection","package":"mongoose","optional":false},{"reason":"JWT verification against Cognito JWKs","package":"jsonwebtoken","optional":false},{"reason":"AWS SDK for Cognito operations","package":"aws-sdk","optional":false}],"imports":[{"note":"Default export does not exist; use named import.","wrong":"import ValidateTokenModule from 'career-edge-backend-auth-library'","symbol":"ValidateTokenModule","correct":"import { ValidateTokenModule } from 'career-edge-backend-auth-library'"},{"note":"Package is ESM-only, requires import syntax.","wrong":"const { TokenService } = require('career-edge-backend-auth-library')","symbol":"TokenService","correct":"import { TokenService } from 'career-edge-backend-auth-library'"},{"note":"TokenGuard is re-exported from the main entry point, not a subpath.","wrong":"import { TokenGuard } from 'career-edge-backend-auth-library/guards'","symbol":"TokenGuard","correct":"import { TokenGuard } from 'career-edge-backend-auth-library'"}],"quickstart":{"code":"import { Module } from '@nestjs/common';\nimport { ValidateTokenModule } from 'career-edge-backend-auth-library';\n\n@Module({\n  imports: [\n    ValidateTokenModule.register({\n      AWS_COGNITO_JWK_URL: process.env.COGNITO_JWK_URL ?? '',\n      AWS_API_VERSION: process.env.API_VERSION ?? '2016-04-18',\n      AWS_REGION: process.env.AWS_REGION ?? '',\n      AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID ?? '',\n      AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY ?? '',\n      DATABASE_CONNECTION_STRING: process.env.MONGO_URI ?? '',\n      DATABASE_NAME: process.env.DATABASE_NAME ?? '',\n    }),\n  ],\n  providers: [],\n  controllers: []\n})\nexport class AppModule {}\n\n// In a service:\nimport { Injectable } from '@nestjs/common';\nimport { TokenService } from 'career-edge-backend-auth-library';\n\n@Injectable()\nexport class ExampleService {\n  constructor(private readonly tokenService: TokenService) {}\n\n  async validate(token: string) {\n    return this.tokenService.validateToken(token);\n  }\n}","lang":"typescript","description":"Shows module registration with all required configuration fields and TokenService injection in a NestJS service class."},"warnings":[{"fix":"Update the register() call to include all required fields as shown in the README.","message":"Configuration object changed between versions: removed optional fields and added DATABASE_CONNECTION_STRING and DATABASE_NAME. Existing code using older config will fail.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Use import statements instead of require. Ensure your project supports ESM (e.g., type: module in package.json).","message":"The library is ESM-only since v2. CommonJS require() statements will throw an error.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Provide valid AWS credentials or use AWS SDK credential chain on EC2/ECS.","message":"AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are required even if using IAM roles; passing empty strings may cause runtime errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure the MongoDB URI includes the database name. The separate DATABASE_NAME is optional and may override.","message":"DATABASE_CONNECTION_STRING must include the database name in the URI (e.g., mongodb://host/dbname) because DATABASE_NAME option is additional but may be ignored if present in the URI.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"No immediate action needed, but plan for migration when library updates.","message":"AwsSdk v2 is used internally. AWS SDK v3 is recommended; future versions will migrate.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install career-edge-backend-auth-library and ensure the import statement is correct.","cause":"Package not installed or import path incorrect.","error":"Cannot find module 'career-edge-backend-auth-library'"},{"fix":"Use named import: import { ValidateTokenModule } from 'career-edge-backend-auth-library'. If problem persists, check version >=2.0.0.","cause":"Likely using a default import instead of named import, or the module has changed its API.","error":"TypeError: ValidateTokenModule.register is not a function"},{"fix":"Provide a valid MongoDB URI that includes the database name (e.g., mongodb://localhost:27017/mydb).","cause":"DATABASE_CONNECTION_STRING does not contain the database name, and DATABASE_NAME is empty.","error":"MongooseError: Mongoose connection error: missing database name"},{"fix":"Verify AWS_COGNITO_JWK_URL is correct and the token is still valid.","cause":"JWT token does not match the JWK from Cognito; possibly wrong JWK URL or token expired.","error":"JsonWebTokenError: invalid signature"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}