Skip to content

Commit 13fe3fa

Browse files
committed
Initial commit
0 parents  commit 13fe3fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+40842
-0
lines changed

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Nutrient DWS Processor API Configuration for Testing
2+
NUTRIENT_API_KEY=your_api_key_here
3+
NUTRIENT_BASE_URL=https://api.nutrient.io
4+
5+
# Development Settings
6+
DEBUG=true
7+
NODE_ENV=development
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: 'bug: [brief description]'
5+
labels: bug
6+
assignees: ''
7+
---
8+
9+
**Describe the bug**
10+
A clear and concise description of what the bug is.
11+
12+
**To Reproduce**
13+
Steps to reproduce the behavior:
14+
1. Initialize client with '...'
15+
2. Call method '....'
16+
3. See error
17+
18+
**Expected behavior**
19+
A clear and concise description of what you expected to happen.
20+
21+
**Code Example**
22+
```typescript
23+
// Provide a minimal code example that reproduces the issue
24+
const client = new NutrientClient({
25+
apiKey: 'your-api-key'
26+
});
27+
28+
// Code that causes the bug
29+
```
30+
31+
**Error Details**
32+
```
33+
Paste the full error message and stack trace here
34+
```
35+
36+
**Environment:**
37+
- Library version: [e.g. 1.0.0]
38+
- Node.js version: [e.g. 18.0.0]
39+
- OS: [e.g. macOS 12.0]
40+
41+
**Additional context**
42+
Add any other context about the problem here.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: 'feat: [brief description]'
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
**Is your feature request related to a problem? Please describe.**
10+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11+
12+
**Describe the solution you'd like**
13+
A clear and concise description of what you want to happen.
14+
15+
**Describe alternatives you've considered**
16+
A clear and concise description of any alternative solutions or features you've considered.
17+
18+
**API Design Proposal**
19+
```typescript
20+
// If applicable, provide a proposed API design
21+
interface NewFeature {
22+
// Proposed interfaces, methods, etc.
23+
}
24+
25+
// Usage example
26+
const result = await client.newMethod({
27+
// Example usage
28+
});
29+
```
30+
31+
**Use Cases**
32+
Describe specific use cases where this feature would be beneficial:
33+
1. Use case 1
34+
2. Use case 2
35+
3. Use case 3
36+
37+
**Additional context**
38+
Add any other context, screenshots, or examples about the feature request here.
39+
40+
**Implementation Notes**
41+
<!-- For maintainers -->
42+
- [ ] Breaking change
43+
- [ ] Requires API changes
44+
- [ ] Affects documentation
45+
- [ ] Requires new dependencies

.github/SETUP_SECRETS.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Setting Up GitHub Secrets for Integration Tests
2+
3+
## ⚠️ IMPORTANT SECURITY NOTICE
4+
5+
**NEVER commit API keys or secrets directly to your repository!** Always use GitHub Secrets for sensitive information.
6+
7+
## Required Secrets
8+
9+
To run the Integration tests in GitHub Actions, you need to configure the following secrets:
10+
11+
### 1. NUTRIENT_API_KEY (Required)
12+
Your Nutrient DWS Processor API key for running integration tests.
13+
14+
### 2. NPM_TOKEN (Optional)
15+
Required only if you want to automatically publish to NPM.
16+
17+
### 3. SNYK_TOKEN (Optional)
18+
Required only if you want to run Snyk security scans.
19+
20+
## How to Add Secrets
21+
22+
1. Go to your repository on GitHub
23+
2. Click on **Settings** (you need admin access)
24+
3. In the left sidebar, click **Secrets and variables****Actions**
25+
4. Click **New repository secret**
26+
5. Add each secret:
27+
- Name: `NUTRIENT_API_KEY`
28+
- Value: Your API key (without quotes)
29+
- Click **Add secret**
30+
31+
## Security Best Practices
32+
33+
### 1. Rotate API Keys Regularly
34+
- Create a schedule to rotate your API keys every 90 days
35+
- Update the GitHub secret when you rotate keys
36+
37+
### 2. Use Scoped API Keys
38+
- If possible, use API keys with limited scope for testing
39+
- Never use production API keys for testing
40+
41+
### 3. Monitor Usage
42+
- Regularly check your API key usage
43+
- Set up alerts for unusual activity
44+
45+
### 4. Restrict Secret Access
46+
- GitHub secrets are only available to workflows running on your repository
47+
- They are not exposed to pull requests from forks
48+
- Integration tests only run on:
49+
- Pushes to main branch
50+
- Pull requests from the same repository
51+
52+
### 5. Environment-Specific Keys
53+
Consider using different API keys for different environments:
54+
55+
```yaml
56+
# In your workflow
57+
env:
58+
NUTRIENT_API_KEY: ${{ github.ref == 'refs/heads/main' && secrets.NUTRIENT_API_KEY_PROD || secrets.NUTRIENT_API_KEY_DEV }}
59+
```
60+
61+
## Workflow Security Features
62+
63+
Our GitHub Actions workflows include several security features:
64+
65+
1. **Secret Scanning**: Automatically checks for hardcoded secrets
66+
2. **Dependency Scanning**: Checks for vulnerable dependencies
67+
3. **Code Scanning**: Uses CodeQL to find security vulnerabilities
68+
4. **Limited Integration Execution**: Integration tests only run on trusted sources
69+
70+
## Local Development
71+
72+
For local development, use environment variables:
73+
74+
```bash
75+
# Create a .env file (already in .gitignore)
76+
echo "NUTRIENT_API_KEY=your_api_key_here" > .env
77+
78+
# Run integration tests locally
79+
source .env
80+
npm run test:integration
81+
```
82+
83+
## Troubleshooting
84+
85+
### Integration Tests Not Running
86+
- Check that the secret is properly set in GitHub
87+
- Verify the secret name matches exactly: `NUTRIENT_API_KEY`
88+
- Check the workflow logs for authentication errors
89+
90+
### Authentication Errors
91+
- Ensure the API key is valid and active
92+
- Check that the API key has the necessary permissions
93+
- Verify the API key format (no extra spaces or quotes)
94+
95+
## Emergency Response
96+
97+
If an API key is accidentally exposed:
98+
99+
1. **Immediately revoke the exposed key** in your Nutrient dashboard
100+
2. **Generate a new API key**
101+
3. **Update the GitHub secret** with the new key
102+
4. **Check logs** for any unauthorized usage
103+
5. **Run security scan** to ensure no other secrets are exposed
104+
105+
## Questions?
106+
107+
If you have questions about security or need help setting up secrets, please open an issue (without including any sensitive information).

.github/pull_request_template.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
## Summary
2+
Brief description of what this PR does and why it's needed.
3+
4+
## Type of Change
5+
- [ ] Bug fix (non-breaking change which fixes an issue)
6+
- [ ] New feature (non-breaking change which adds functionality)
7+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
8+
- [ ] Documentation update
9+
- [ ] Refactoring (no functional changes)
10+
- [ ] Performance improvement
11+
- [ ] Test addition/update
12+
13+
## Changes Made
14+
<!-- List the specific changes made in this PR -->
15+
-
16+
-
17+
-
18+
19+
## Related Issues
20+
<!-- Link to any related issues -->
21+
Closes #
22+
Fixes #
23+
Relates to #
24+
25+
## Testing
26+
<!-- Describe how you tested your changes -->
27+
- [ ] Unit tests added/updated
28+
- [ ] All existing tests pass
29+
- [ ] Manual testing performed
30+
- [ ] Integration tests added (if applicable)
31+
32+
### Test Coverage
33+
<!-- If adding new functionality, describe test coverage -->
34+
- [ ] New code has >90% test coverage
35+
- [ ] Edge cases are covered
36+
- [ ] Error scenarios are tested
37+
38+
## Pre-submission Checklist
39+
<!-- Ensure all items are checked before submitting -->
40+
- [ ] **All commits follow conventional format** (`type(scope): description`)
41+
- [ ] **Each commit is atomic** (one logical change per commit)
42+
- [ ] **All tests pass**: `npm test`
43+
- [ ] **Code is properly formatted**: `npm run format`
44+
- [ ] **No linting errors**: `npm run lint`
45+
- [ ] **TypeScript compiles**: `npm run typecheck`
46+
- [ ] **Build succeeds**: `npm run build`
47+
- [ ] **Branch is up to date** with main branch
48+
- [ ] **Self-reviewed** the changes before requesting review
49+
50+
## Documentation
51+
- [ ] JSDoc comments added for new public APIs
52+
- [ ] README updated (if needed)
53+
- [ ] Breaking changes documented
54+
- [ ] Migration guide provided (for breaking changes)
55+
56+
## Performance Impact
57+
<!-- If applicable, describe any performance implications -->
58+
- [ ] No performance impact
59+
- [ ] Performance improvement (describe)
60+
- [ ] Potential performance regression (describe and justify)
61+
62+
## Backwards Compatibility
63+
- [ ] Fully backwards compatible
64+
- [ ] Deprecates existing functionality (provide timeline)
65+
- [ ] Breaking change (increment major version)
66+
67+
## Screenshots/Examples
68+
<!-- If applicable, add screenshots or code examples -->
69+
70+
## Additional Notes
71+
<!-- Any additional information that reviewers should know -->
72+
73+
---
74+
75+
**Reviewer Note**: Please ensure this PR follows our [Contributing Guidelines](../CONTRIBUTING.md) and meets all code review criteria.

.github/workflows/ci.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
lint-and-type-check:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Use Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20.x'
20+
cache: 'npm'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Run linting
26+
run: npm run lint
27+
28+
- name: Run type checking
29+
run: npm run typecheck
30+
31+
unit-tests:
32+
runs-on: ubuntu-latest
33+
needs: lint-and-type-check
34+
35+
strategy:
36+
matrix:
37+
node-version: [18.x, 20.x]
38+
os: [ubuntu-latest, windows-latest, macos-latest]
39+
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Use Node.js ${{ matrix.node-version }}
44+
uses: actions/setup-node@v4
45+
with:
46+
node-version: ${{ matrix.node-version }}
47+
cache: 'npm'
48+
49+
- name: Install dependencies
50+
run: npm ci
51+
52+
- name: Run unit tests with coverage
53+
run: npm test -- --coverage --testPathPatterns='^((?!integration).)*$'
54+
55+
- name: Upload coverage to Codecov
56+
uses: codecov/codecov-action@v3
57+
if: matrix.os == 'ubuntu-latest' && matrix.node-version == '20.x'
58+
with:
59+
file: ./coverage/lcov.info
60+
flags: unittests
61+
name: codecov-umbrella
62+
63+
64+
build:
65+
runs-on: ubuntu-latest
66+
needs: [lint-and-type-check, unit-tests]
67+
68+
steps:
69+
- uses: actions/checkout@v4
70+
71+
- name: Use Node.js
72+
uses: actions/setup-node@v4
73+
with:
74+
node-version: '20.x'
75+
cache: 'npm'
76+
77+
- name: Install dependencies
78+
run: npm ci
79+
80+
- name: Build
81+
run: npm run build
82+
83+
- name: Verify build outputs
84+
run: |
85+
ls -la dist/
86+
test -f dist/index.js
87+
test -f dist/index.cjs
88+
test -f dist/index.d.ts

0 commit comments

Comments
 (0)