Skip to content

Commit 888cbd5

Browse files
authored
Logger (#2)
* Initialize project structure with essential configuration files and documentation * initial files * Enhance logger module: add LoggerConfig interface and initializeLogger function * Refactor logger module: update exports and enhance Logger class with configuration options * Update Jest configuration and add comprehensive tests for Logger class * Add pull request template with instructions and checklist * Add issue templates for bug reports, stories, and tasks * Update package version to 0.1.0-alpha.4 and refine scripts in package.json * Add comprehensive logging guide and update README for improved documentation * Update README with comprehensive usage examples, documentation links, and structured logging details * Initialize Husky for pre-commit hooks and update package version to 0.1.0-alpha.5 * Add CI and Publish workflows for automated testing and deployment * Update package version to 0.1.0-alpha.6 and enhance Rollup configuration with new plugins * Add code quality workflow with ESLint, Prettier, testing, and security checks
1 parent 0f2482d commit 888cbd5

25 files changed

Lines changed: 8863 additions & 2 deletions

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is used to define coding styles and formatting rules for the project.
2+
# For more information, see https://editorconfig.org/
3+
root=true
4+
5+
[*]
6+
charset=utf-8
7+
end_of_line=lf
8+
indent_style=space
9+
indent_size=2
10+
insert_final_newline=true
11+
max_line_length=120
12+
trim_trailing_whitespace=true

.github/ISSUE_TEMPLATE/bug.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: bug
6+
assignees: ''
7+
---
8+
9+
## Describe the bug
10+
11+
_Provide a clear and concise description of what the bug is._
12+
13+
## Steps to reproduce
14+
15+
Steps to reproduce the behavior:
16+
17+
1. Go to '...'
18+
2. Click on '....'
19+
3. Scroll down to '....'
20+
4. See error
21+
22+
## Expected behavior
23+
24+
_Provide a clear and concise description of what you expected to happen._
25+
26+
## Screenshots
27+
28+
_If applicable, add screenshots to help explain your problem._
29+
30+
## Environment
31+
32+
**Desktop (please complete the following information):**
33+
34+
- OS: [e.g. iOS]
35+
- Browser [e.g. chrome, safari]
36+
- Version [e.g. 22]
37+
38+
**Smartphone (please complete the following information):**
39+
40+
- Device: [e.g. iPhone6]
41+
- OS: [e.g. iOS8.1]
42+
- Browser [e.g. stock browser, safari]
43+
- Version [e.g. 22]
44+
45+
## Additional context
46+
47+
_Add any other context about the problem here._

.github/ISSUE_TEMPLATE/story.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Story
3+
about: New feature or improvement request
4+
title: ''
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
## Describe the story
10+
11+
_Provide a clear description of the new feature or improvement to existing functionality._
12+
13+
## Acceptance criteria
14+
15+
_Provide clear acceptance criteria to validate the story is complete._
16+
17+
[Gherkin syntax](https://cucumber.io/docs/gherkin/reference) example:
18+
19+
> Given the 'PERSONA' has 'DONE SOMETHING'
20+
> When the 'PERSONA' does 'ONE THING'
21+
> Then the 'PERSONA' must do 'ANOTHER THING'
22+
23+
## Additional context
24+
25+
_Add any other context about the story here._

.github/ISSUE_TEMPLATE/task.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
name: Task
3+
about: A chore unrelated to features or problems
4+
title: ''
5+
labels: task
6+
assignees: ''
7+
---
8+
9+
## Describe the task
10+
11+
_Provide a clear description of the task._
12+
13+
## Additional context
14+
15+
_Add any other context about the task here._

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
:loudspeaker: **Instructions**
2+
3+
- Begin with a **DRAFT** pull request.
4+
- Follow _italicized instructions_ to add detail to assist the reviewers.
5+
- After completing all checklist items, change the pull request to **READY**.
6+
7+
---
8+
9+
### :wrench: Change Summary
10+
11+
_Describe the changes included in this pull request. Link to the associated [GitHub](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) or Jira issue(s)._
12+
13+
- see #1234
14+
- Added the [...]
15+
- Updated the [...]
16+
- Fixed the [...]
17+
18+
### :memo: Checklist
19+
20+
_Pull request authors must complete the following tasks before marking the PR as ready to review._
21+
22+
- [ ] Complete a self-review of changes
23+
- [ ] Unit tests have been created or updated
24+
- [ ] The code is free of [new] lint errors and warnings
25+
- [ ] Update project documentation as needed: README, /docs, JSDoc, etc.
26+
27+
### :test_tube: Steps to Test
28+
29+
_Describe the process to test the changes in this pull request._
30+
31+
1. Go to [...]
32+
2. Click on [...]
33+
3. Verify that [...]
34+
35+
### :link: Additional Information
36+
37+
_Optionally, provide additional details, screenshots, or URLs that may assist the reviewer._
38+
39+
- [...]

.github/copilot-instructions.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Lambda Utilities Project Instructions
2+
3+
This project contains a set of utilities and helper functions designed to streamline the development of AWS Lambda functions using TypeScript. The utilities cover common tasks such as input validation, response formatting, error handling, and logging. The project is packaged and published as an npm package for easy integration into other Lambda projects.
4+
5+
---
6+
7+
## Technology Stack
8+
9+
Each pattern project uses the following technology stack:
10+
11+
- **Language:** TypeScript
12+
- **Platform:** AWS Lambda
13+
- **Runtime:** Node.js 24.x
14+
- **AWS SDK:** v3 (modular packages)
15+
- **Testing:** Jest
16+
- **Linting/Formatting:** ESLint + Prettier
17+
- **Validation:** Zod
18+
- **Logging:** Pino + Pino-Lambda
19+
- **Package Manager:** npm
20+
- **Package Bundler:** rollup
21+
22+
---
23+
24+
## Pattern Project Structure
25+
26+
Each pattern project follows a consistent directory and file structure to promote maintainability and scalability. Below is an example structure:
27+
28+
```
29+
/docs # Project documentation
30+
README.md # Documentation table of contents
31+
32+
/src
33+
/logging
34+
logger.ts # Logger utility using Pino
35+
logger.test.ts # Unit tests for logger
36+
/clients
37+
dynamodb-client.ts # AWS SDK client for DynamoDB
38+
dynamodb-client.test.ts # Unit tests for DynamoDB client
39+
lambda-client.ts # AWS SDK client for Lambda
40+
lambda-client.test.ts # Unit tests for Lambda client
41+
/validation
42+
config.ts # Configuration validation with Zod
43+
config.test.ts # Unit tests for config
44+
validator.ts # Generic validator helpers
45+
validator.test.ts # Unit tests for validator
46+
/responses
47+
apigateway-response.ts # Standard API response helpers
48+
apigateway-response.test.ts # Unit tests for API response helpers
49+
.editorconfig # Editor config
50+
.gitignore # Git ignore rules
51+
.nvmrc # Node version manager config
52+
.prettierrc # Prettier config
53+
eslint.config.mjs # ESLint config
54+
jest.config.ts # App Jest config
55+
jest.setup.ts # App Jest setup
56+
package.json # App NPM package config
57+
README.md # Project README
58+
tsconfig.json # Project TypeScript config
59+
```
60+
61+
---
62+
63+
## Source Code Guidelines
64+
65+
Each pattern project follows best practices for source code organization, naming conventions, and coding standards. Below are the key guidelines:
66+
67+
- Use **TypeScript** for all source and infrastructure code.
68+
- Use arrow functions for defining functions.
69+
- Use path aliases for cleaner imports (e.g., `@utils`, `@models`).
70+
- Organize import statements: external packages first, then internal modules.
71+
- Use async/await for asynchronous operations.
72+
- Document functions and modules with JSDoc comments.
73+
74+
### Source Code Commands & Scripts
75+
76+
- Use `npm run build` to compile TypeScript.
77+
- Use `npm run test` to run tests.
78+
- Use `npm run test:coverage` to run tests with coverage report.
79+
- Use `npm run lint` to run ESLint.
80+
- Use `npm run lint:fix` to fix ESLint issues.
81+
- Use `npm run format` to run Prettier to format code.
82+
- Use `npm run format:check` to check code formatting with Prettier.
83+
84+
---
85+
86+
## Unit Testing Guidelines
87+
88+
Each pattern project includes comprehensive unit tests for both application and infrastructure code. Below are the key guidelines for writing unit tests:
89+
90+
- Use the **Jest** testing framework.
91+
- Place test files next to the source file, with `.test.ts` suffix.
92+
- Use `describe` and `it` blocks for organization.
93+
- Use `beforeEach` for setup and `afterEach` for cleanup.
94+
- Use `expect` assertions for results.
95+
- Mock dependencies to isolate the component under test.
96+
- Mock external calls (e.g., AWS SDK, databases).
97+
- Structure your tests using the Arrange-Act-Assert pattern:
98+
- **Arrange:** Set up the test environment, including any necessary mocks and test data.
99+
- **Act:** Execute the function or service being tested.
100+
- **Assert:** Verify that the results are as expected.
101+
- Add comments to separate these sections for clarity.

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Continuous Integration
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
ci:
15+
name: Build, Lint, and Test
16+
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 5
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v5
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v5
26+
with:
27+
node-version-file: '.nvmrc'
28+
cache: 'npm'
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Lint code
34+
run: npm run lint
35+
36+
- name: Check code formatting
37+
run: npm run format:check
38+
39+
- name: Build
40+
run: npm run build
41+
42+
- name: Run tests with coverage
43+
run: npm run test:coverage

0 commit comments

Comments
 (0)