MCPcopy Index your code
hub / github.com/nodeSolidServer/node-solid-server / createServer

Function createServer

lib/create-server.mjs:10–126  ·  view source on GitHub ↗
(argv, app)

Source from the content-addressed store, hash-verified

8import createApp from './create-app.mjs'
9
10function createServer (argv, app) {
11 argv = argv || {}
12 app = app || express()
13 const ldpApp = createApp(argv)
14 const ldp = ldpApp.locals.ldp || {}
15 let mount = argv.mount || '/'
16 // Removing ending '/'
17 if (mount.length > 1 &&
18 mount[mount.length - 1] === '/') {
19 mount = mount.slice(0, -1)
20 }
21 app.use(mount, ldpApp)
22 debug.settings('Base URL (--mount): ' + mount)
23 if (argv.idp) {
24 console.warn('The idp configuration option has been renamed to multiuser.')
25 argv.multiuser = argv.idp
26 delete argv.idp
27 }
28
29 if (argv.httpProxy) {
30 globalTunnel.initialize(argv.httpProxy)
31 }
32
33 let server
34 const needsTLS = argv.sslKey || argv.sslCert
35 if (!needsTLS) {
36 server = http.createServer(app)
37 } else {
38 debug.settings('SSL Private Key path: ' + argv.sslKey)
39 debug.settings('SSL Certificate path: ' + argv.sslCert)
40
41 if (!argv.sslCert && !argv.sslKey) {
42 throw new Error('Missing SSL cert and SSL key to enable WebIDs')
43 }
44
45 if (!argv.sslKey && argv.sslCert) {
46 throw new Error('Missing path for SSL key')
47 }
48
49 if (!argv.sslCert && argv.sslKey) {
50 throw new Error('Missing path for SSL cert')
51 }
52
53 let key
54 try {
55 key = fs.readFileSync(argv.sslKey)
56 } catch (e) {
57 throw new Error('Can\'t find SSL key in ' + argv.sslKey)
58 }
59
60 let cert
61 try {
62 cert = fs.readFileSync(argv.sslCert)
63 } catch (e) {
64 throw new Error('Can\'t find SSL cert in ' + argv.sslCert)
65 }
66
67 const credentials = Object.assign({

Callers

nothing calls this directly

Calls 3

createAppFunction · 0.85
getMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected