Skip to content

Commit

Permalink
rename http/server -> http/static
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Oct 26, 2022
1 parent d688683 commit 6742325
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -3241,20 +3241,20 @@ request will be blocked.
If `port` is omitted or is 0, the operating system will assign an arbitrary
unused port, which it's output will be the standard output.

Also accessible via `require('node:http/server')`.
Also accessible via `require('node:http/static')`.

```bash
# Starts serving the cwd on a random port:
node -r node:http/server
node -r node:http/static
node -e 'http.createStaticServer()'

# To start serving on the port 8080 using /path/to/dir as the root:
node -r node:http/server /path/to/dir --port 8080
node -r node:http/static /path/to/dir --port 8080
node -e 'http.createStaticServer({directory: "/path/to/dir", port: 8080})'

# Same as above, but exposing your local file system to the whole
# IPv4 network:
node -r node:http/server /path/to/dir --port 8080 --host 0.0.0.0
node -r node:http/static /path/to/dir --port 8080 --host 0.0.0.0
node -e 'http.createStaticServer({directory: "/path/to/dir", port: 8080, host: "0.0.0.0"})'
```

Expand Down
2 changes: 1 addition & 1 deletion lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const {
Server,
ServerResponse
} = require('_http_server');
const createStaticServer = require('http/server');
const createStaticServer = require('http/static');
let maxHeaderSize;

/**
Expand Down
8 changes: 4 additions & 4 deletions lib/http/server.js → lib/http/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ const { emitExperimentalWarning, kEmptyObject } = require('internal/util');
const { getOptionValue } = require('internal/options');
const { validateFunction, validatePort } = require('internal/validators');

emitExperimentalWarning('http/server');

if (module.isPreloading) {
const requiredModules = getOptionValue('--require');
if (ArrayPrototypeIncludes(requiredModules, `node:${module.id}`) ||
Expand All @@ -41,8 +39,8 @@ if (module.isPreloading) {
},
} });
nextTick(createStaticServer, { directory: process.argv[1], port, host });
process.env.NODE_REPL_EXTERNAL_MODULE = 'node:http/server';
process.argv[1] = 'node:http/server';
process.env.NODE_REPL_EXTERNAL_MODULE = 'node:http/static';
process.argv[1] = 'node:http/static';
}
}

Expand All @@ -51,6 +49,8 @@ function filterDotFiles(url, fileURL) {
}

function createStaticServer(options = kEmptyObject) {
emitExperimentalWarning('http/static');

const {
directory = cwd(),
port,
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-createstaticserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { mustCall } = require('../common');
const fixtures = require('../common/fixtures');
const assert = require('node:assert');
const { MIMEType } = require('node:util');
const createStaticServer = require('node:http/server');
const createStaticServer = require('node:http/static');

[0, 1, 1n, '', '1', true, false, NaN, Symbol(), {}, []].forEach((filter) => {
assert.throws(() => createStaticServer({ filter }), { code: 'ERR_INVALID_ARG_TYPE' });
Expand Down

0 comments on commit 6742325

Please sign in to comment.