forked from nodeSolidServer/node-solid-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolid.js
More file actions
47 lines (41 loc) · 1.36 KB
/
solid.js
File metadata and controls
47 lines (41 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env node
import { program } from 'commander'
import http from 'http'
import https from 'https'
import fs from 'fs'
import { createApp } from '../lib/server.js'
program
.name('solid')
.version('7.0.0')
program
.command('start')
.description('Start the Solid server')
.option('-p, --port <port>', 'Port to listen on', '8443')
.option('--root <path>', 'Root directory for storage', process.cwd())
.option('--server-uri <uri>', 'Server URI', 'https://localhost:8443')
.option('--ssl-key <path>', 'Path to SSL private key')
.option('--ssl-cert <path>', 'Path to SSL certificate')
.option('--no-auth', 'Disable authentication/ACL')
.action((opts) => {
const port = parseInt(opts.port, 10)
const app = createApp({
root: opts.root,
serverUri: opts.serverUri,
skipAuth: !opts.auth
})
let server
if (opts.sslKey && opts.sslCert) {
const key = fs.readFileSync(opts.sslKey)
const cert = fs.readFileSync(opts.sslCert)
server = https.createServer({ key, cert }, app)
} else {
server = http.createServer(app)
}
server.listen(port, () => {
console.log(`Solid server (v7.0.0) running on port ${port}`)
console.log(` Root: ${opts.root}`)
console.log(` URI: ${opts.serverUri}`)
console.log(` Auth: ${opts.auth ? 'enabled' : 'disabled'}`)
})
})
program.parse()