Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/code-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Code Cleanup Audit

on:
pull_request:
schedule:
- cron: "0 1 * * 0"

jobs:
audit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20

- run: npm ci

- run: npx depcheck

- run: npx ts-prune
25 changes: 25 additions & 0 deletions .github/workflows/deployment-verification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deployment Verification

on:
workflow_dispatch:

jobs:
verify:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20

- run: npm ci

- run: npm run verify:env

- run: npm run verify:backup

- run: npm run predeploy

- run: npm run postdeploy
11 changes: 11 additions & 0 deletions compliance/deprecation-registry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"deprecatedItems": [
{
"name": "LegacyPaymentService",
"reason": "Superseded by PaymentOrchestrator",
"deprecatedDate": "2026-06-01",
"removalVersion": "v3.0.0",
"owner": "Backend Team"
}
]
}
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
7 changes: 7 additions & 0 deletions docs/code-cleanup/deprecation-policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Deprecation Policy

1. Mark deprecated functionality with @Deprecated
2. Announce deprecation in release notes
3. Maintain functionality for at least one release cycle
4. Remove only after communicated deadline
5. Update deprecation registry
7 changes: 7 additions & 0 deletions docs/code-cleanup/removal-timeline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Removal Timeline

| Version | Action |
|----------|---------|
| v2.4.0 | Mark deprecated |
| v2.5.0 | Warning logs enabled |
| v3.0.0 | Removal |
90 changes: 90 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions scripts/analyze-dead-code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

echo "Running dead code analysis"

npx ts-prune > reports/unused-exports.txt

npx depcheck > reports/unused-dependencies.txt

echo "Analysis complete"
13 changes: 13 additions & 0 deletions scripts/find-unused-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

echo "Checking unused dependencies..."

npx depcheck

echo "Checking TypeScript exports..."

npx ts-prune

echo "Checking duplicate packages..."

npm ls
Empty file.
25 changes: 25 additions & 0 deletions scripts/post-deployment-health-check.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const endpoints = [
'/health',
'/health/live',
'/health/ready',
];

async function run() {
const baseUrl = process.env.APP_URL;

for (const endpoint of endpoints) {
const response = await fetch(
`${baseUrl}${endpoint}`,
);

if (!response.ok) {
throw new Error(
`Health check failed: ${endpoint}`,
);
}
}

console.log('All health checks passed');
}

run();
30 changes: 30 additions & 0 deletions src/common/decorators/deprecated.decorator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Logger } from '@nestjs/common';

const logger = new Logger('Deprecation');

export interface DeprecatedOptions {
reason: string;
removalVersion: string;
}

export function Deprecated(options: DeprecatedOptions) {
return (
target: any,
propertyKey?: string,
descriptor?: PropertyDescriptor,
) => {
const originalMethod = descriptor?.value;

if (originalMethod) {
descriptor.value = function (...args: any[]) {
logger.warn(
`[DEPRECATED] ${propertyKey} - ${options.reason}. Scheduled removal: ${options.removalVersion}`,
);

return originalMethod.apply(this, args);
};
}

Reflect.defineMetadata('deprecated', options, target);
};
}
16 changes: 16 additions & 0 deletions src/common/utils/deprecation-logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Logger } from '@nestjs/common';

export class DeprecationLogger {
private static readonly logger =
new Logger('DeprecationLogger');

static warn(
feature: string,
reason: string,
removalVersion: string,
) {
this.logger.warn(
`${feature} is deprecated. Reason: ${reason}. Removal: ${removalVersion}`,
);
}
}
10 changes: 10 additions & 0 deletions src/constants/deprecation.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const DEPRECATION_VERSIONS = {
NEXT_MINOR: 'v2.5.0',
NEXT_MAJOR: 'v3.0.0',
};

export const DEPRECATION_REASONS = {
LEGACY_API: 'Legacy API implementation',
OLD_BUSINESS_LOGIC: 'Superseded business logic',
EXPERIMENTAL_FEATURE: 'Experimental implementation',
};
Loading