feat: Cấu hình ESLint flat config mới, thêm jsconfig.json, và sắp xếp lại các import tự động.
This commit is contained in:
23
services/_template/eslint.config.js
Normal file
23
services/_template/eslint.config.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// EN: ESLint v9 Flat Config for Template Service
|
||||
// VI: ESLint v9 Flat Config cho Template Service
|
||||
import goodgoConfig from '@goodgo/eslint-config';
|
||||
|
||||
export default [
|
||||
...goodgoConfig,
|
||||
{
|
||||
// EN: Service-specific overrides (exclude test files)
|
||||
// VI: Override riêng cho service (loại trừ test files)
|
||||
files: ['**/*.ts'],
|
||||
ignores: ['**/*.test.ts', '**/*.spec.ts', '**/__tests__/**'],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
project: './tsconfig.json',
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
// EN: Add service-specific rules here
|
||||
// VI: Thêm rules riêng cho service ở đây
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "@goodgo/service-template",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"description": "Template for creating new microservices",
|
||||
"main": "./dist/main.js",
|
||||
"scripts": {
|
||||
@@ -63,4 +64,4 @@
|
||||
"tsx": "^4.21.0",
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
23
services/iam-service/eslint.config.js
Normal file
23
services/iam-service/eslint.config.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// EN: ESLint v9 Flat Config for IAM Service
|
||||
// VI: ESLint v9 Flat Config cho IAM Service
|
||||
import goodgoConfig from '@goodgo/eslint-config';
|
||||
|
||||
export default [
|
||||
...goodgoConfig,
|
||||
{
|
||||
// EN: Service-specific overrides (exclude test files)
|
||||
// VI: Override riêng cho service (loại trừ test files)
|
||||
files: ['**/*.ts'],
|
||||
ignores: ['**/*.test.ts', '**/*.spec.ts', '**/__tests__/**'],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
project: './tsconfig.json',
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
// EN: Add service-specific rules here
|
||||
// VI: Thêm rules riêng cho service ở đây
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "@goodgo/iam-service",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"description": "Enterprise IAM (Identity and Access Management) Service",
|
||||
"main": "./dist/main.js",
|
||||
"scripts": {
|
||||
@@ -101,4 +102,4 @@
|
||||
"qs@<6.14.1": ">=6.14.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Application } from 'express';
|
||||
import swaggerJSDoc from 'swagger-jsdoc';
|
||||
import swaggerUi from 'swagger-ui-express';
|
||||
|
||||
import { appConfig } from '../config/app.config';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { logger } from '@goodgo/logger';
|
||||
import { prisma, connectDatabase } from './config/database.config';
|
||||
import { appConfig } from './config/app.config';
|
||||
|
||||
import { app } from './app';
|
||||
import { appConfig } from './config/app.config';
|
||||
import { prisma, connectDatabase } from './config/database.config';
|
||||
|
||||
const startServer = async () => {
|
||||
try {
|
||||
|
||||
@@ -10,7 +10,7 @@ import { getErrorMessage } from '../utils/error-utils';
|
||||
* VI: Interface Request mở rộng với thông tin người dùng
|
||||
*/
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
|
||||
namespace Express {
|
||||
interface Request {
|
||||
user?: {
|
||||
|
||||
@@ -15,7 +15,7 @@ export const REQUEST_ID_HEADER = 'x-request-id';
|
||||
* VI: Interface Request mở rộng với correlation ID
|
||||
*/
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
|
||||
namespace Express {
|
||||
interface Request {
|
||||
correlationId: string;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { Router } from 'express';
|
||||
|
||||
import { authenticate } from '../../middlewares/auth.middleware';
|
||||
import { requirePermission } from '../../middlewares/rbac.middleware';
|
||||
|
||||
import { accessAnalyticsController } from './analytics';
|
||||
import { accessRequestController } from './request';
|
||||
import { accessReviewController } from './review';
|
||||
import { accessAnalyticsController } from './analytics';
|
||||
|
||||
/**
|
||||
* EN: Create and configure Access Management routes
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Request, Response } from 'express';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
import { DateRangeDto, RiskFiltersDto } from '../access.dto';
|
||||
|
||||
import { accessAnalyticsService } from './analytics.service';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
|
||||
/**
|
||||
* EN: Access Analytics Controller
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Request, Response } from 'express';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { NotFoundError, BadRequestError } from '../../../errors/http-error';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
import { CreateAccessRequestDto, ApproveAccessRequestDto, RejectAccessRequestDto } from '../access.dto';
|
||||
|
||||
import { accessRequestService } from './request.service';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
|
||||
/**
|
||||
* EN: Access Request Controller
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Request, Response } from 'express';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { NotFoundError, BadRequestError } from '../../../errors/http-error';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
import { CreateAccessReviewDto, ReviewAccessItemDto } from '../access.dto';
|
||||
|
||||
import { accessReviewService } from './review.service';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
|
||||
/**
|
||||
* EN: Access Review Controller
|
||||
|
||||
@@ -3,9 +3,10 @@ import { z } from 'zod';
|
||||
|
||||
// import { cookieService } from '../token/cookie.service';
|
||||
|
||||
import { getErrorMessage } from '../../utils/error-utils';
|
||||
|
||||
import { RegisterDto, LoginDto } from './auth.dto';
|
||||
import { authService } from './auth.service';
|
||||
import { getErrorMessage } from '../../utils/error-utils';
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { Router } from 'express';
|
||||
|
||||
import { authenticate } from '../../middlewares/auth.middleware';
|
||||
import { socialAuthController } from '../social/social.controller';
|
||||
|
||||
import { authController } from './auth.controller';
|
||||
import { changePasswordController } from './change-password.controller';
|
||||
import { socialAuthController } from '../social/social.controller';
|
||||
|
||||
/**
|
||||
* EN: Create and configure auth routes
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Request, Response } from 'express';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { getErrorMessage } from '../../utils/error-utils';
|
||||
|
||||
import { ChangePasswordDto } from './auth.dto';
|
||||
import { changePasswordService } from './change-password.service';
|
||||
import { getErrorMessage } from '../../utils/error-utils';
|
||||
|
||||
/**
|
||||
* EN: Change Password Controller
|
||||
|
||||
@@ -2,9 +2,9 @@ import { ApiResponse } from '@goodgo/types';
|
||||
import { Request, Response } from 'express';
|
||||
|
||||
import { asyncHandler } from '../../middlewares/error.middleware';
|
||||
import { getErrorMessage } from '../../utils/error-utils';
|
||||
|
||||
import { FeatureService } from './feature.service';
|
||||
import { getErrorMessage } from '../../utils/error-utils';
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,8 +2,8 @@ import { logger } from '@goodgo/logger';
|
||||
|
||||
import { prisma } from '../../config/database.config';
|
||||
import { ConflictError } from '../../errors/http-error';
|
||||
import { BaseRepository, IRepository } from '../common/repository';
|
||||
import { hasCode } from '../../utils/error-utils';
|
||||
import { BaseRepository, IRepository } from '../common/repository';
|
||||
|
||||
// EN: Feature entity type from Prisma
|
||||
// VI: Feature entity type từ Prisma
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Request, Response } from 'express';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { NotFoundError, BadRequestError } from '../../../errors/http-error';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
import { GenerateComplianceReportDto, ReportFiltersDto } from '../governance.dto';
|
||||
|
||||
import { complianceService } from './compliance.service';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
|
||||
/**
|
||||
* EN: Compliance Controller
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { Router } from 'express';
|
||||
|
||||
import { authenticate } from '../../middlewares/auth.middleware';
|
||||
import { requirePermission } from '../../middlewares/rbac.middleware';
|
||||
|
||||
import { complianceController } from './compliance';
|
||||
import { policyGovernanceController } from './policy';
|
||||
import { riskController } from './risk';
|
||||
import { reportingController } from './reporting';
|
||||
import { riskController } from './risk';
|
||||
|
||||
/**
|
||||
* EN: Create and configure Governance routes
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Request, Response } from 'express';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { NotFoundError } from '../../../errors/http-error';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
import { CreatePolicyTemplateDto, TestPolicyDto } from '../governance.dto';
|
||||
|
||||
import { policyGovernanceService } from './policy-governance.service';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
|
||||
/**
|
||||
* EN: Policy Governance Controller
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Request, Response } from 'express';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
import { AccessSummaryFiltersDto, UserActivityFiltersDto, SecurityEventsFiltersDto } from '../governance.dto';
|
||||
|
||||
import { reportingService } from './reporting.service';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
|
||||
/**
|
||||
* EN: Reporting Controller
|
||||
|
||||
@@ -3,10 +3,10 @@ import { z } from 'zod';
|
||||
|
||||
import { getPrismaClient } from '../../../config/database.config';
|
||||
import { NotFoundError } from '../../../errors/http-error';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
import { CalculateRiskScoreDto, RiskFiltersDto } from '../governance.dto';
|
||||
|
||||
import { riskService } from './risk.service';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
|
||||
/**
|
||||
* EN: Risk Management Controller
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Request, Response } from 'express';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { NotFoundError, ConflictError } from '../../../errors/http-error';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
import { CreateGroupDto, UpdateGroupDto, AddGroupMemberDto } from '../identity.dto';
|
||||
|
||||
import { groupService } from './group.service';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
|
||||
/**
|
||||
* EN: Group Controller
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { Router } from 'express';
|
||||
|
||||
import { authenticate } from '../../middlewares/auth.middleware';
|
||||
import { requirePermission } from '../../middlewares/rbac.middleware';
|
||||
import { userManagementController } from './user';
|
||||
import { profileController } from './profile';
|
||||
import { verificationController } from './verification';
|
||||
import { organizationController } from './organization';
|
||||
|
||||
import { groupController } from './group';
|
||||
import { organizationController } from './organization';
|
||||
import { profileController } from './profile';
|
||||
import { userManagementController } from './user';
|
||||
import { verificationController } from './verification';
|
||||
|
||||
/**
|
||||
* EN: Create and configure Identity routes
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Request, Response } from 'express';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { NotFoundError, ConflictError } from '../../../errors/http-error';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
import { CreateOrganizationDto, UpdateOrganizationDto } from '../identity.dto';
|
||||
|
||||
import { organizationService } from './organization.service';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
|
||||
/**
|
||||
* EN: Organization Controller
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Request, Response } from 'express';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { NotFoundError } from '../../../errors/http-error';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
import { UpdateUserProfileDto } from '../identity.dto';
|
||||
|
||||
import { profileService } from './profile.service';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
|
||||
/**
|
||||
* EN: Profile Management Controller
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Request, Response } from 'express';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { NotFoundError } from '../../../errors/http-error';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
import { UpdateUserDto, UserFiltersDto, BulkImportUsersDto } from '../identity.dto';
|
||||
|
||||
import { userManagementService } from './user.service';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
|
||||
/**
|
||||
* EN: User Management Controller
|
||||
|
||||
@@ -7,8 +7,8 @@ import { auditService } from '../../../core/events/audit.service';
|
||||
import { NotFoundError, ConflictError } from '../../../errors/http-error';
|
||||
import { UserProfileRepository } from '../../../repositories/user-profile.repository';
|
||||
import { UserRepository } from '../../../repositories/user.repository';
|
||||
import { UpdateUserDto, UserFiltersDto, BulkImportUsersDto } from '../identity.dto';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
import { UpdateUserDto, UserFiltersDto, BulkImportUsersDto } from '../identity.dto';
|
||||
|
||||
/**
|
||||
* EN: User Management Service for user lifecycle operations
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Request, Response } from 'express';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { BadRequestError, NotFoundError } from '../../../errors/http-error';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
import { VerifyEmailDto, VerifyPhoneDto } from '../identity.dto';
|
||||
|
||||
import { verificationService } from './verification.service';
|
||||
import { getErrorMessage } from '../../../utils/error-utils';
|
||||
|
||||
/**
|
||||
* EN: Identity Verification Controller
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Request, Response } from 'express';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { mfaService } from './mfa.service';
|
||||
import { getErrorMessage } from '../../utils/error-utils';
|
||||
|
||||
import { mfaService } from './mfa.service';
|
||||
|
||||
const VerifyTOTPDto = z.object({
|
||||
token: z.string().length(6),
|
||||
});
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Router } from 'express';
|
||||
|
||||
import { authenticate } from '../../middlewares/auth.middleware';
|
||||
|
||||
import { mfaController } from './mfa.controller';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { logger } from '@goodgo/logger';
|
||||
import { Request, Response } from 'express';
|
||||
|
||||
import { oidcProviderService } from './oidc-provider.service';
|
||||
import { getErrorMessage } from '../../utils/error-utils';
|
||||
|
||||
import { oidcProviderService } from './oidc-provider.service';
|
||||
|
||||
/**
|
||||
* EN: OIDC Controller
|
||||
* VI: Controller OIDC
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Router } from 'express';
|
||||
|
||||
import { authenticate } from '../../middlewares/auth.middleware';
|
||||
|
||||
import { oidcController } from './oidc.controller';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Request, Response } from 'express';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { rbacService } from './rbac.service';
|
||||
import { getErrorMessage } from '../../utils/error-utils';
|
||||
|
||||
import { rbacService } from './rbac.service';
|
||||
|
||||
const AssignRoleDto = z.object({
|
||||
userId: z.string(),
|
||||
roleId: z.string(),
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { Router } from 'express';
|
||||
|
||||
import { authenticate } from '../../middlewares/auth.middleware';
|
||||
import { requirePermission } from '../../middlewares/rbac.middleware';
|
||||
|
||||
import { rbacController } from './rbac.controller';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Router } from 'express';
|
||||
|
||||
import { authenticate } from '../../middlewares/auth.middleware';
|
||||
|
||||
import { sessionsController } from './sessions.controller';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Request, Response } from 'express';
|
||||
|
||||
import { sessionService } from './session.service';
|
||||
import { getErrorMessage } from '../../utils/error-utils';
|
||||
|
||||
import { sessionService } from './session.service';
|
||||
|
||||
/**
|
||||
* EN: Sessions Controller
|
||||
* VI: Controller sessions
|
||||
|
||||
@@ -2,13 +2,13 @@ import { logger } from '@goodgo/logger';
|
||||
import { Request, Response } from 'express';
|
||||
|
||||
import { auditService } from '../../core/events/audit.service';
|
||||
import { getErrorMessage } from '../../utils/error-utils';
|
||||
import { rbacService } from '../rbac/rbac.service';
|
||||
import { sessionService } from '../session/session.service';
|
||||
import { cookieService } from '../token/cookie.service';
|
||||
import { jwtService } from '../token/jwt.service';
|
||||
|
||||
import { socialAuthService } from './social.service';
|
||||
import { getErrorMessage } from '../../utils/error-utils';
|
||||
|
||||
/**
|
||||
* EN: Social Auth Controller
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { Router } from 'express';
|
||||
import { createAuthRouter } from '../modules/auth/auth.routes';
|
||||
import { createIdentityRouter } from '../modules/identity/identity.routes';
|
||||
|
||||
import { createAccessRouter } from '../modules/access/access.routes';
|
||||
import { createAuthRouter } from '../modules/auth/auth.routes';
|
||||
import { createGovernanceRouter } from '../modules/governance/governance.routes';
|
||||
import { createSessionRouter } from '../modules/session/session.routes';
|
||||
import { createIdentityRouter } from '../modules/identity/identity.routes';
|
||||
import { createMfaRouter } from '../modules/mfa/mfa.routes';
|
||||
import { createOidcRouter } from '../modules/oidc/oidc.routes';
|
||||
import { createRbacRouter } from '../modules/rbac/rbac.routes';
|
||||
import { createMfaRouter } from '../modules/mfa/mfa.routes';
|
||||
import { createSessionRouter } from '../modules/session/session.routes';
|
||||
|
||||
/**
|
||||
* EN: Create and configure main application router
|
||||
|
||||
Reference in New Issue
Block a user