Skip to content

Commit 0ea5b67

Browse files
committed
Sync commands
Signed-off-by: Reece Dunham <[email protected]>
1 parent 0c09b8d commit 0ea5b67

File tree

5 files changed

+34
-7
lines changed

5 files changed

+34
-7
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "static-server-rdil",
3-
"version": "1.7.0",
3+
"version": "1.8.0",
44
"description": "Static web server",
55
"homepage": "https://github.com/rdilweb/static-server",
66
"bin": {
7-
"static-server": "./src/index.js"
7+
"static-server-rdil": "./src/index.js"
88
},
99
"keywords": [
1010
"server",

source/headers.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
* Get response headers.
33
*
44
* @param {boolean} enhancedSecurity Should enhanced security be applied?
5-
* @param {string} mimetype The mime-type of the requested file.
6-
* @default
5+
* @param {string} mimetype The mime-type of the requested file.
76
*/
87
export default (enhancedSecurity, mimetype) => {
98
return !enhancedSecurity

source/index.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,23 @@ import handle from "./serverHandling"
1010

1111
/**
1212
* The arguments passed via command line.
13+
*
14+
* @constant
15+
* @readonly
1316
*/
1417
const argv = process.argv
1518

1619
/**
1720
* The port that the server will run on.
21+
*
22+
* @default 3000
1823
*/
1924
let port = 3000
2025

2126
/**
2227
* The root directory the server will serve.
28+
*
29+
* @default process.cwd
2330
*/
2431
let root = process.cwd()
2532

@@ -30,11 +37,15 @@ let logRequests = true
3037

3138
/**
3239
* If errors should be ignored.
40+
*
41+
* @default false
3342
*/
3443
let ignoreErrors = false
3544

3645
/**
3746
* If emojis should be logged to the console.
47+
*
48+
* @default true
3849
*/
3950
let emojis = true
4051

@@ -53,8 +64,10 @@ let renderMarkdown = true
5364
*/
5465
const emote = emojis ? emojify(":star:") : "!"
5566

67+
/**
68+
* Manual argument parsing.
69+
*/
5670
argv.forEach(arg => {
57-
// basic argument parsing
5871
if (arg == "--help") {
5972
help()
6073
} else if (arg == "--port") {

source/serverHandling.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import getHeaders from "./headers"
77
import markdown from "./markdownRendering"
88

99
/**
10-
* Handle file request.
10+
* Handle general request.
1111
*
1212
* @param {string} filePath The path requested.
1313
* @param {http.ServerResponse} response The response object.
@@ -59,12 +59,19 @@ export default function handle(
5959
if (!ignoreErrors) {
6060
console.log(chalk`
6161
{bgGray Internal Server Error: ${e}}
62-
`)
62+
`
63+
)
6364
}
6465
}
6566
}
6667

6768
/**
69+
* Handle Markdown request.
70+
* This will be called by the handle function,
71+
* with all needed context.
72+
*
73+
* @see handle
74+
*
6875
* @param {http.ServerResponse} response
6976
* @param {boolean} enhancedSecurity
7077
* @param {string} filePath
@@ -78,6 +85,12 @@ let handleMarkdown = (response, enhancedSecurity, filePath) => {
7885
}
7986

8087
/**
88+
* Handle a request for a real, existing file.
89+
* This will be called by the handle function,
90+
* with all the needed context.
91+
*
92+
* @see handle
93+
*
8194
* @param {http.ServerResponse} response
8295
* @param {string} fileExtension
8396
* @param {boolean} enhancedSecurity

source/utilities.js

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Please see {green https://docs.rdil.rocks/libraries/static-server-rdil/} for doc
1717
*
1818
* @param {Array<Any>} array The array.
1919
* @param {Any} currentItem The item before the targeted item.
20+
*
21+
* @returns The next item in the array
2022
*/
2123
export let getNextItemInArray = (array, currentItem) => {
2224
return array[array.indexOf(currentItem) + 1]

0 commit comments

Comments
 (0)