Remove redeemId field from redeem response
- Remove redeemId from successful redemption response - Remove redeemId from error response - Update swagger documentation to remove redeemId field - Update README examples to remove redeemId field - Clean up API response format for better simplicity
This commit is contained in:
@@ -76,7 +76,6 @@ Redeem a Cashu token to a Lightning address. Lightning address is optional - if
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"success": true,
|
"success": true,
|
||||||
"redeemId": "8e99101e-d034-4d2e-9ccf-dfda24d26762",
|
|
||||||
"paid": true,
|
"paid": true,
|
||||||
"amount": 21000,
|
"amount": 21000,
|
||||||
"invoiceAmount": 20580,
|
"invoiceAmount": 20580,
|
||||||
@@ -94,7 +93,6 @@ Redeem a Cashu token to a Lightning address. Lightning address is optional - if
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"success": true,
|
"success": true,
|
||||||
"redeemId": "8e99101e-d034-4d2e-9ccf-dfda24d26762",
|
|
||||||
"paid": true,
|
"paid": true,
|
||||||
"amount": 21000,
|
"amount": 21000,
|
||||||
"invoiceAmount": 20580,
|
"invoiceAmount": 20580,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ NODE_ENV=development
|
|||||||
|
|
||||||
# Security Configuration
|
# Security Configuration
|
||||||
ALLOW_REDEEM_DOMAINS=*
|
ALLOW_REDEEM_DOMAINS=*
|
||||||
API_SECRET=your-secret-key-here
|
|
||||||
|
|
||||||
# Default Lightning Address (used when no address is provided in redeem requests)
|
# Default Lightning Address (used when no address is provided in redeem requests)
|
||||||
DEFAULT_LIGHTNING_ADDRESS=admin@your-domain.com
|
DEFAULT_LIGHTNING_ADDRESS=admin@your-domain.com
|
||||||
|
|||||||
31
package-lock.json
generated
31
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "cashu-redeem-api",
|
"name": "cashu-redeem-api",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "cashu-redeem-api",
|
"name": "cashu-redeem-api",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cashu/cashu-ts": "^1.1.0",
|
"@cashu/cashu-ts": "^1.1.0",
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
"express": "^4.19.2",
|
"express": "^4.19.2",
|
||||||
|
"express-rate-limit": "^8.0.0",
|
||||||
"swagger-jsdoc": "^6.2.8",
|
"swagger-jsdoc": "^6.2.8",
|
||||||
"swagger-ui-express": "^5.0.1",
|
"swagger-ui-express": "^5.0.1",
|
||||||
"uuid": "^10.0.0"
|
"uuid": "^10.0.0"
|
||||||
@@ -26,6 +27,10 @@
|
|||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0",
|
"node": ">=18.0.0",
|
||||||
"npm": ">=8.0.0"
|
"npm": ">=8.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/Michilis"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@apidevtools/json-schema-ref-parser": {
|
"node_modules/@apidevtools/json-schema-ref-parser": {
|
||||||
@@ -1464,6 +1469,23 @@
|
|||||||
"url": "https://opencollective.com/express"
|
"url": "https://opencollective.com/express"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/express-rate-limit": {
|
||||||
|
"version": "8.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.0.0.tgz",
|
||||||
|
"integrity": "sha512-FXEAp2ccTeN1ZSO+sPHRHWB0/CrTP5asFBjUaNeD9A0v3iPmgFbLu24vqPjiM9utszI58VGlMokjXQ0W9Dbmjw==",
|
||||||
|
"dependencies": {
|
||||||
|
"ip": "2.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 16"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/express-rate-limit"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"express": ">= 4.11"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/fast-deep-equal": {
|
"node_modules/fast-deep-equal": {
|
||||||
"version": "3.1.3",
|
"version": "3.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
||||||
@@ -1961,6 +1983,11 @@
|
|||||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
|
"node_modules/ip": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ=="
|
||||||
|
},
|
||||||
"node_modules/ipaddr.js": {
|
"node_modules/ipaddr.js": {
|
||||||
"version": "1.9.1",
|
"version": "1.9.1",
|
||||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
|
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
|
||||||
|
|||||||
@@ -305,9 +305,6 @@ app.post('/api/decode', asyncHandler(async (req, res) => {
|
|||||||
* error:
|
* error:
|
||||||
* type: string
|
* type: string
|
||||||
* example: "This token has already been spent and cannot be redeemed again"
|
* example: "This token has already been spent and cannot be redeemed again"
|
||||||
* redeemId:
|
|
||||||
* type: string
|
|
||||||
* format: uuid
|
|
||||||
* errorType:
|
* errorType:
|
||||||
* type: string
|
* type: string
|
||||||
* example: "token_already_spent"
|
* example: "token_already_spent"
|
||||||
@@ -324,9 +321,6 @@ app.post('/api/decode', asyncHandler(async (req, res) => {
|
|||||||
* error:
|
* error:
|
||||||
* type: string
|
* type: string
|
||||||
* example: "Token amount is insufficient to cover the minimum fee"
|
* example: "Token amount is insufficient to cover the minimum fee"
|
||||||
* redeemId:
|
|
||||||
* type: string
|
|
||||||
* format: uuid
|
|
||||||
* errorType:
|
* errorType:
|
||||||
* type: string
|
* type: string
|
||||||
* example: "insufficient_funds"
|
* example: "insufficient_funds"
|
||||||
@@ -355,7 +349,6 @@ app.post('/api/redeem', asyncHandler(async (req, res) => {
|
|||||||
if (result.success) {
|
if (result.success) {
|
||||||
const response = {
|
const response = {
|
||||||
success: true,
|
success: true,
|
||||||
redeemId: result.redeemId,
|
|
||||||
paid: result.paid,
|
paid: result.paid,
|
||||||
amount: result.amount,
|
amount: result.amount,
|
||||||
invoiceAmount: result.invoiceAmount,
|
invoiceAmount: result.invoiceAmount,
|
||||||
@@ -400,7 +393,6 @@ app.post('/api/redeem', asyncHandler(async (req, res) => {
|
|||||||
res.status(statusCode).json({
|
res.status(statusCode).json({
|
||||||
success: false,
|
success: false,
|
||||||
error: result.error,
|
error: result.error,
|
||||||
redeemId: result.redeemId,
|
|
||||||
errorType: statusCode === 409 ? 'token_already_spent' :
|
errorType: statusCode === 409 ? 'token_already_spent' :
|
||||||
statusCode === 422 ? 'insufficient_funds' : 'validation_error'
|
statusCode === 422 ? 'insufficient_funds' : 'validation_error'
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -138,12 +138,6 @@ const options = {
|
|||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
example: true
|
example: true
|
||||||
},
|
},
|
||||||
redeemId: {
|
|
||||||
type: 'string',
|
|
||||||
format: 'uuid',
|
|
||||||
description: 'Unique redemption ID for tracking',
|
|
||||||
example: '8e99101e-d034-4d2e-9ccf-dfda24d26762'
|
|
||||||
},
|
|
||||||
paid: {
|
paid: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description: 'Whether the payment was successful',
|
description: 'Whether the payment was successful',
|
||||||
|
|||||||
Reference in New Issue
Block a user