steering_docs/javascript-tech.md
# Dependencies
npm install # Install dependencies
npm ci # Clean install from package-lock.json
# Testing
npm test # Run all tests
npm run test:unit # Run unit tests
npm run test:integration # Run integration tests
# Code Quality
npm run lint # Lint code
npm run format # Format code with Prettier
# Execution
node src/hello-{service}.js # Run hello scenario
npm start # Run main application
{service}-action.js (e.g., s3-list-buckets.js)hello-{service}.js (e.g., hello-s3.js){service}-action.test.jshello-{service}.js or hello function in main moduleimport { S3Client, ListBucketsCommand } from "@aws-sdk/client-s3";
const client = new S3Client({ region: "us-east-1" });
async function listBuckets() {
try {
const command = new ListBucketsCommand({});
const response = await client.send(command);
console.log("Buckets:", response.Buckets);
return response.Buckets;
} catch (error) {
if (error.name === "NoSuchBucket") {
console.error("Bucket not found:", error.message);
} else if (error.name === "AccessDenied") {
console.error("Access denied:", error.message);
} else {
console.error("AWS SDK Error:", error.message);
}
throw error;
}
}
export { listBuckets };
src/
├── hello-{service}.js
├── {service}-actions.js
├── {service}-scenarios.js
└── tests/
├── {service}-actions.test.js
└── {service}-integration.test.js
{
"name": "{service}-examples",
"version": "1.0.0",
"type": "module",
"scripts": {
"test": "jest",
"test:unit": "jest --testPathPattern=unit",
"test:integration": "jest --testPathPattern=integration",
"lint": "biome check .",
"format": "prettier --write ."
},
"dependencies": {
"@aws-sdk/client-{service}": "^3.0.0",
"@aws-sdk/credential-providers": "^3.0.0"
},
"devDependencies": {
"jest": "^29.0.0",
"prettier": "^3.0.0",
"@biomejs/biome": "^1.0.0"
}
}
/** for function and class documentation@param@returns@example blocksimport { S3Client } from "@aws-sdk/client-s3";
import { fromEnv } from "@aws-sdk/credential-providers";
const client = new S3Client({
region: process.env.AWS_REGION || "us-east-1",
credentials: fromEnv(), // Optional: explicit credential provider
});
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
const client = new S3Client({ region: "us-east-1" });
async function uploadObject(bucketName, key, body) {
const command = new PutObjectCommand({
Bucket: bucketName,
Key: key,
Body: body,
});
return await client.send(command);
}
AWS_REGION environment variableBefore creating JavaScript code examples:
coding-standards-KB for "JavaScript-code-example-standards"JavaScript-premium-KB for "JavaScript implementation patterns"