-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core-api): adapt to new container
- Loading branch information
Brian Faust
committed
Sep 2, 2019
1 parent
0c03165
commit 67b10dd
Showing
19 changed files
with
390 additions
and
640 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,72 @@ | ||
export const defaults = { | ||
enabled: !process.env.CORE_API_DISABLED, | ||
host: process.env.CORE_API_HOST || "0.0.0.0", | ||
port: process.env.CORE_API_PORT || 4003, | ||
cache: { | ||
enabled: true, | ||
/** | ||
* How many seconds the server will try to complete the request and cache the result. | ||
* | ||
* Defaults to 8 seconds, set it to false if you do not care about the timeout. | ||
* | ||
* Setting it to false can result in requests never being completed, which is usually | ||
* caused by low-spec servers that are unable to handle the heavy load that results | ||
* out of SQL queries on the blocks and transactions tables. | ||
* | ||
* If you experience issues with the cache timeout, which is indicated by a 503 status codes, | ||
* you should consider upgrading your hardware or tweak your PostgreSQL settings. | ||
*/ | ||
generateTimeout: process.env.CORE_API_CACHE_TIMEOUT || 8000, | ||
}, | ||
// @see https://hapijs.com/api#-serveroptionstls | ||
ssl: { | ||
enabled: process.env.CORE_API_SSL, | ||
host: process.env.CORE_API_SSL_HOST || "0.0.0.0", | ||
port: process.env.CORE_API_SSL_PORT || 8443, | ||
key: process.env.CORE_API_SSL_KEY, | ||
cert: process.env.CORE_API_SSL_CERT, | ||
}, | ||
// @see https://github.com/wraithgar/hapi-rate-limit | ||
rateLimit: { | ||
enabled: !process.env.CORE_API_RATE_LIMIT, | ||
pathLimit: false, | ||
userLimit: process.env.CORE_API_RATE_LIMIT_USER_LIMIT || 300, | ||
userCache: { | ||
expiresIn: process.env.CORE_API_RATE_LIMIT_USER_EXPIRES || 60000, | ||
server: { | ||
http: { | ||
enabled: !process.env.CORE_API_DISABLED, | ||
host: process.env.CORE_API_HOST || "0.0.0.0", | ||
port: process.env.CORE_API_PORT || 4003, | ||
}, | ||
// @see https://hapijs.com/api#-serveroptionstls | ||
https: { | ||
enabled: process.env.CORE_API_SSL, | ||
host: process.env.CORE_API_SSL_HOST || "0.0.0.0", | ||
port: process.env.CORE_API_SSL_PORT || 8443, | ||
tls: { | ||
key: process.env.CORE_API_SSL_KEY, | ||
cert: process.env.CORE_API_SSL_CERT, | ||
}, | ||
}, | ||
}, | ||
// @see https://github.com/fknop/hapi-pagination | ||
pagination: { | ||
limit: 100, | ||
include: [ | ||
"/api/blocks", | ||
"/api/blocks/{id}/transactions", | ||
"/api/blocks/search", | ||
"/api/delegates", | ||
"/api/delegates/{id}/blocks", | ||
"/api/delegates/{id}/voters", | ||
"/api/delegates/search", | ||
"/api/peers", | ||
"/api/transactions", | ||
"/api/transactions/search", | ||
"/api/transactions/unconfirmed", | ||
"/api/votes", | ||
"/api/wallets", | ||
"/api/wallets/top", | ||
"/api/wallets/{id}/transactions", | ||
"/api/wallets/{id}/transactions/received", | ||
"/api/wallets/{id}/transactions/sent", | ||
"/api/wallets/{id}/votes", | ||
"/api/wallets/search", | ||
], | ||
plugins: { | ||
cache: { | ||
enabled: true, | ||
/** | ||
* How many seconds the server will try to complete the request and cache the result. | ||
* | ||
* Defaults to 8 seconds, set it to false if you do not care about the timeout. | ||
* | ||
* Setting it to false can result in requests never being completed, which is usually | ||
* caused by low-spec servers that are unable to handle the heavy load that results | ||
* out of SQL queries on the blocks and transactions tables. | ||
* | ||
* If you experience issues with the cache timeout, which is indicated by a 503 status codes, | ||
* you should consider upgrading your hardware or tweak your PostgreSQL settings. | ||
*/ | ||
generateTimeout: process.env.CORE_API_CACHE_TIMEOUT || 8000, | ||
}, | ||
// @see https://github.com/wraithgar/hapi-rate-limit | ||
rateLimit: { | ||
enabled: !process.env.CORE_API_RATE_LIMIT, | ||
pathLimit: false, | ||
userLimit: process.env.CORE_API_RATE_LIMIT_USER_LIMIT || 300, | ||
userCache: { | ||
expiresIn: process.env.CORE_API_RATE_LIMIT_USER_EXPIRES || 60000, | ||
}, | ||
}, | ||
// @see https://github.com/fknop/hapi-pagination | ||
pagination: { | ||
limit: 100, | ||
include: [ | ||
"/api/blocks", | ||
"/api/blocks/{id}/transactions", | ||
"/api/blocks/search", | ||
"/api/delegates", | ||
"/api/delegates/{id}/blocks", | ||
"/api/delegates/{id}/voters", | ||
"/api/delegates/search", | ||
"/api/peers", | ||
"/api/transactions", | ||
"/api/transactions/search", | ||
"/api/transactions/unconfirmed", | ||
"/api/votes", | ||
"/api/wallets", | ||
"/api/wallets/top", | ||
"/api/wallets/{id}/transactions", | ||
"/api/wallets/{id}/transactions/received", | ||
"/api/wallets/{id}/transactions/sent", | ||
"/api/wallets/{id}/votes", | ||
"/api/wallets/search", | ||
], | ||
}, | ||
whitelist: ["*"], | ||
}, | ||
whitelist: ["*"], | ||
plugins: [], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.