diff --git a/.github/workflows/translation.yml b/.github/workflows/translation.yml index 5eef3263..0fbb4cb5 100644 --- a/.github/workflows/translation.yml +++ b/.github/workflows/translation.yml @@ -9,6 +9,7 @@ on: - 'es/**' - 'fr/**' - 'it/**' + - 'id/**' - 'ja/**' - 'ko/**' - 'pt-br/**' @@ -37,7 +38,7 @@ jobs: uses: actions/github-script@v5 with: script: | - const languages = ['en', 'es', 'fr', 'it', 'ja', 'ko', 'pt-br', 'ru', 'sk', 'th', 'tr', 'uk', 'uz', 'zh-cn', 'zh-tw']; + const languages = ['en', 'es', 'fr', 'it', 'id', 'ja', 'ko', 'pt-br', 'ru', 'sk', 'th', 'tr', 'uk', 'uz', 'zh-cn', 'zh-tw']; const prNumber = context.eventName === 'workflow_dispatch' ? context.payload.inputs.prNumber : context.issue.number; const { data: pullRequest } = await github.rest.pulls.get({ owner: context.repo.owner, diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b9cf2602..861b75f7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,6 +16,7 @@ The documentation is translated into these languages: - Spanish (`es`) - French (`fr`) - Italian (`it`) +- Indonesian (`id`) - Japanese (`ja`) - Korean (`ko`) - Brazilian Portuguese (`pt-br`) diff --git a/_includes/announcement/announcement-id.md b/_includes/announcement/announcement-id.md new file mode 100644 index 00000000..cc456dc2 --- /dev/null +++ b/_includes/announcement/announcement-id.md @@ -0,0 +1,8 @@ +
Dokumentasi Express 5.0 versi beta kini telah tersedia.
++ Dokumentasi API beta masih dalam proses. Untuk informasi tentang apa yang ada dalam rilis, lihat riwayat rilis Express. +
+
+
+
+
+
+
+{% include footer/_docsearch.html %}
diff --git a/_includes/header/header-id.html b/_includes/header/header-id.html
new file mode 100644
index 00000000..386e6041
--- /dev/null
+++ b/_includes/header/header-id.html
@@ -0,0 +1,161 @@
+| Type | Value |
|---|---|
| Boolean | +
+If `true`, the client's IP address is understood as the left-most entry in the `X-Forwarded-For` header.
+
+If `false`, the app is understood as directly facing the client and the client's IP address is derived from `req.socket.remoteAddress`. This is the default setting.
+
+
+When setting to `true`, it is important to ensure that the last reverse proxy trusted is removing/overwriting all of the following HTTP headers: `X-Forwarded-For`, `X-Forwarded-Host`, and `X-Forwarded-Proto`, otherwise it may be possible for the client to provide any value.
+
+ |
+
| IP addresses | ++An IP address, subnet, or an array of IP addresses and subnets to trust as being a reverse proxy. The following list shows the pre-configured subnet names: + +* loopback - `127.0.0.1/8`, `::1/128` +* linklocal - `169.254.0.0/16`, `fe80::/10` +* uniquelocal - `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `fc00::/7` + +You can set IP addresses in any of the following ways: + +```js +app.set('trust proxy', 'loopback') // specify a single subnet +app.set('trust proxy', 'loopback, 123.123.123.123') // specify a subnet and an address +app.set('trust proxy', 'loopback, linklocal, uniquelocal') // specify multiple subnets as CSV +app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal']) // specify multiple subnets as an array +``` + +When specified, the IP addresses or the subnets are excluded from the address determination process, and the untrusted IP address nearest to the application server is determined as the client's IP address. This works by checking if `req.socket.remoteAddress` is trusted. If so, then each address in `X-Forwarded-For` is checked from right to left until the first non-trusted address. + | +
| Number | +
+Use the address that is at most `n` number of hops away from the Express application. `req.socket.remoteAddress` is the first hop, and the rest are looked for in the `X-Forwarded-For` header from right to left. A value of `0` means that the first untrusted address would be `req.socket.remoteAddress`, i.e. there is no reverse proxy.
+
+
+When using this setting, it is important to ensure there are not multiple, different-length paths to the Express application such that the client can be less than the configured number of hops away, otherwise it may be possible for the client to provide any value.
+
+ |
+
| Function | ++Custom trust implementation. + +```js +app.set('trust proxy', (ip) => { + if (ip === '127.0.0.1' || ip === '123.123.123.123') return true // trusted IPs + else return false +}) +``` + | +
| Express 3 | Express 4 |
|---|---|
express.bodyParser |
+body-parser + +multer |
express.compress |
+compression |
express.cookieSession |
+cookie-session |
express.cookieParser |
+cookie-parser |
express.logger |
+morgan |
express.session |
+express-session |
express.favicon |
+serve-favicon |
express.responseTime |
+response-time |
express.errorHandler |
+errorhandler |
express.methodOverride |
+method-override |
express.timeout |
+connect-timeout |
express.vhost |
+vhost |
express.csrf |
+csurf |
express.directory |
+serve-index |
express.static |
+serve-static |
app.use accepts parametersapp.route() methodexpress.Router class| Object | +Description | +
|---|---|
| Node.js | +Express 4 requires Node.js 0.10.x or later and has dropped support for +Node.js 0.8.x. | +
| +`http.createServer()` + | ++The `http` module is no longer needed, unless you need to directly work with it (socket.io/SPDY/HTTPS). The app can be started by using the +`app.listen()` function. + | +
| +`app.configure()` + | ++The `app.configure()` function has been removed. Use the +`process.env.NODE_ENV` or +`app.get('env')` function to detect the environment and configure the app accordingly. + | +
| +`json spaces` + | ++The `json spaces` application property is disabled by default in Express 4. + | +
| +`req.accepted()` + | ++Use `req.accepts()`, `req.acceptsEncodings()`, +`req.acceptsCharsets()`, and `req.acceptsLanguages()`. + | +
| +`res.location()` + | ++No longer resolves relative URLs. + | +
| +`req.params` + | ++Was an array; now an object. + | +
| +`res.locals` + | ++Was a function; now an object. + | +
| +`res.headerSent` + | ++Changed to `res.headersSent`. + | +
| +`app.route` + | ++Now available as `app.mountpath`. + | +
| +`res.on('header')` + | ++Removed. + | +
| +`res.charset` + | ++Removed. + | +
| +`res.setHeader('Set-Cookie', val)` + | ++Functionality is now limited to setting the basic cookie value. Use +`res.cookie()` for added functionality. + | +
app.jspackage.jsonpackage.jsonapp.jsres.send(status), where _`status`_ is a number. Instead, use the `res.sendStatus(statusCode)` function, which sets the HTTP response header status code and sends the text version of the code: "Not Found", "Internal Server Error", and so on.
+If you need to send a number by using the `res.send()` function, quote the number to convert it to a string, so that Express does not interpret it as an attempt to use the unsupported old signature.
+
+\ characters with an additional backslash, for example \\d+.
+* character in regular expressions is not interpreted in the usual way. As a workaround, use {0,} instead of *. This will likely be fixed in Express 5.
+
+
+ |
+
+ HTTP method for which the middleware function applies.
+
+Path (route) for which the middleware function applies.
+
+The middleware function.
+
+Callback argument to the middleware function, called "next" by convention.
+
+HTTP response argument to the middleware function, called "res" by convention.
+
+HTTP request argument to the middleware function, called "req" by convention.
+ |
+const express = require('express')
+const app = express()
+const port = 3000
+
+app.get('/', (req, res) => {
+ res.send('Hello World!')
+})
+
+app.listen(port, () => {
+ console.log(`Example app listening on port ${port}`)
+})
+