Skip to content

Commit 2ada44f

Browse files
committed
fix: production readiness improvements
- Centralize 38 hardcoded API URLs through UrlConfig - Add try-with-resources for OkHttp Response (fix connection leak) - Add SLF4J logging across all classes (requests, errors, async failures) - Replace blocking CompletableFuture.supplyAsync with OkHttp enqueue() for true async - Fix BufferedReader resource leak in UrlConfig - Remove -DskipTests from publish workflow - Add .env/secrets.* patterns to .gitignore - Document SLF4J binding requirement in README - Fix USERS_PUBLIC_PROFILE endpoint placeholder in url_config.json
0 parents  commit 2ada44f

43 files changed

Lines changed: 5120 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
name: Bug Report
3+
about: Report a bug to help us improve LatteSplash
4+
title: '[BUG] '
5+
labels: bug
6+
assignees: ''
7+
---
8+
9+
## Describe the Bug
10+
11+
A clear and concise description of what the bug is.
12+
13+
## To Reproduce
14+
15+
Steps to reproduce the behavior:
16+
17+
1. Initialize LatteSplash with '...'
18+
2. Call method '...'
19+
3. See error
20+
21+
## Expected Behavior
22+
23+
A clear and concise description of what you expected to happen.
24+
25+
## Screenshots
26+
27+
If applicable, add screenshots to help explain your problem.
28+
29+
## Environment
30+
31+
- **Java Version**: [e.g., Java 11, 17, 21]
32+
- **OS**: [e.g., Windows 10, macOS 12, Ubuntu 20.04]
33+
- **LatteSplash Version**: [e.g., 1.0.0]
34+
- **Build Tool**: [e.g., Maven 3.9.6, Gradle 7.5]
35+
36+
## API Details
37+
38+
- **Endpoint**: [e.g., GET /photos/:id]
39+
- **HTTP Method**: [e.g., GET, POST, PUT, DELETE]
40+
- **Authentication**: [e.g., Bearer Token, Client-ID]
41+
42+
## Code Sample
43+
44+
```java
45+
// Paste your code here
46+
LatteSplashConfig config = new LatteSplashConfig.Builder()
47+
.bearerToken("<token>")
48+
.build();
49+
50+
LatteSplash unsplash = new LatteSplash(config);
51+
// Code that causes the issue
52+
```
53+
54+
## Error Output
55+
56+
```
57+
Paste the full stack trace or error message here
58+
```
59+
60+
## Additional Context
61+
62+
Add any other context about the problem here. For example:
63+
- Does this happen every time, or only sometimes?
64+
- Did this work before? When did it stop working?
65+
- Any workarounds you've found?
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
name: Feature Request
3+
about: Suggest an idea for LatteSplash
4+
title: '[FEATURE] '
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
## Is your feature request related to a problem?
10+
11+
A clear and concise description of what the problem is.
12+
Ex. I'm always frustrated when [...]
13+
14+
## Describe the Solution You'd Like
15+
16+
A clear and concise description of what you want to happen.
17+
18+
## Describe Alternatives You've Considered
19+
20+
A clear and concise description of any alternative solutions or features you've considered.
21+
22+
## Use Case
23+
24+
Describe the use case(s) where this feature would be valuable:
25+
- Who would use this feature?
26+
- How would they use it?
27+
- What problem does it solve?
28+
29+
## API Design (if applicable)
30+
31+
If this is an API-related feature, provide a code example of how you'd like to use it:
32+
33+
```java
34+
// Example of desired API
35+
unsplash.photos().newMethod(param1, param2);
36+
```
37+
38+
## Mockups / Examples
39+
40+
If applicable, add mockups, diagrams, or examples to help explain the feature.
41+
42+
## Additional Context
43+
44+
Add any other context or screenshots about the feature request here.
45+
46+
## Are you willing to contribute?
47+
48+
- [ ] Yes, I'd be happy to submit a pull request
49+
- [ ] I can help with testing
50+
- [ ] I can help with documentation
51+
- [ ] No, I'm just suggesting

.github/ISSUE_TEMPLATE/question.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: Question
3+
about: Ask a question about LatteSplash
4+
title: '[QUESTION] '
5+
labels: question
6+
assignees: ''
7+
---
8+
9+
## Your Question
10+
11+
A clear and concise description of your question.
12+
13+
## Context
14+
15+
Provide any relevant context:
16+
- What are you trying to accomplish?
17+
- What have you already tried?
18+
- What documentation have you consulted?
19+
20+
## Code Sample
21+
22+
If applicable, provide a code sample showing what you're trying to do:
23+
24+
```java
25+
// Your code here
26+
```
27+
28+
## Environment
29+
30+
- **Java Version**: [e.g., Java 11, 17, 21]
31+
- **LatteSplash Version**: [e.g., 1.0.0]
32+
33+
## Additional Information
34+
35+
Any other information that might be helpful for answering your question.

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
java-version: [11, 17, 21]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up JDK ${{ matrix.java-version }}
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: ${{ matrix.java-version }}
23+
distribution: temurin
24+
25+
- name: Build with Maven
26+
run: mvn -B compile
27+
28+
- name: Run tests
29+
run: mvn -B verify

.github/workflows/publish.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Publish to GitHub Packages
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up JDK 11
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: 11
21+
distribution: temurin
22+
server-id: github
23+
24+
- name: Build and deploy
25+
run: mvn -B deploy
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Build output
2+
target/
3+
4+
# IDE files
5+
.idea/
6+
*.iml
7+
.project
8+
.classpath
9+
.settings/
10+
.vscode/
11+
*.swp
12+
*.swo
13+
*~
14+
15+
# OS files
16+
.DS_Store
17+
Thumbs.db
18+
19+
# Maven
20+
dependency-reduced-pom.xml
21+
pom.xml.tag
22+
pom.xml.releaseBackup
23+
pom.xml.versionsBackup
24+
pom.xml.next
25+
release.properties
26+
27+
# Logs
28+
*.log
29+
30+
# Package files
31+
*.jar
32+
*.war
33+
*.ear
34+
35+
# Environment and secrets
36+
.env
37+
.env.*
38+
secrets.*
39+
credentials.*
40+
*.pem
41+
*.key

CHANGELOG.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Changelog
2+
3+
All notable changes to LatteSplash will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.0.0] - 2024-01-01
9+
10+
### Added
11+
12+
- Initial release of LatteSplash Java library
13+
- Complete port of wrapsplash npm module (v5.0.0)
14+
- Support for all 34 Unsplash API endpoints
15+
- Synchronous and asynchronous (`CompletableFuture`) API variants
16+
- Builder pattern configuration (`LatteSplashConfig.Builder`)
17+
- OkHttp-based HTTP client with retry support
18+
- JSON serialization/deserialization using Gson
19+
- SLF4J logging integration
20+
- Bearer token and Client-ID authentication
21+
- Input validation for all API methods
22+
- SHA-256 header hashing for security
23+
- Configurable timeout and retry settings
24+
- Automatic retry with configurable delay
25+
- Error normalization with `LatteSplashError` exception
26+
- 204 Content Deleted handling
27+
- 403 Rate Limit handling
28+
- Comprehensive JUnit 5 test suite (95 tests)
29+
- Full Javadoc documentation
30+
- Maven and Gradle dependency support
31+
- GitHub Actions CI/CD workflow
32+
- GitHub Packages publishing workflow
33+
34+
### Features
35+
36+
- **Users API**: Get user profiles, photos, likes, collections, statistics
37+
- **Photos API**: List, get, update, like, unlike photos; get statistics and download links
38+
- **Search API**: Search photos, collections, and users
39+
- **Collections API**: Full CRUD operations for collections
40+
- **Current User API**: Get and update current user profile
41+
- **Stats API**: Get platform statistics totals and monthly stats
42+
43+
### Authentication
44+
45+
- Bearer token authentication
46+
- Client-ID authentication
47+
- OAuth2 support with bearer token generation
48+
49+
### Configuration
50+
51+
- Builder pattern for immutable configuration
52+
- Configurable timeout (default: 10000ms)
53+
- Configurable retry count (default: 2)
54+
- Configurable retry delay (default: 100ms)
55+
56+
### Error Handling
57+
58+
- Checked exception model (`LatteSplashError`)
59+
- Automatic error normalization
60+
- Rate limit detection and handling
61+
- Content deletion (204) handling
62+
63+
### Testing
64+
65+
- Unit tests for all API classes
66+
- Integration tests with MockHttpClient
67+
- Validation tests for input parameters
68+
- Async operation tests
69+
- Error handling tests
70+
- SHA-256 hashing tests
71+
72+
### Documentation
73+
74+
- Comprehensive README with usage examples
75+
- Full Javadoc for all public APIs
76+
- API reference documentation
77+
- Contributing guidelines
78+
- Code of conduct
79+
- Security policy
80+
- Changelog
81+
82+
## [Unreleased]
83+
84+
### Planned
85+
86+
- Maven Central publishing
87+
- Additional logging adapters
88+
- Connection pooling optimization
89+
- Retry-after header support
90+
- Rate limit headers parsing
91+
92+
---
93+
94+
## Versioning
95+
96+
- **Major**: Breaking changes to public API
97+
- **Minor**: New features, backward compatible
98+
- **Patch**: Bug fixes, backward compatible
99+
100+
## Support
101+
102+
- Java 11+ required
103+
- GitHub Issues: https://github.com/SandeepVattapparambil/lattesplash-java/issues

0 commit comments

Comments
 (0)