-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meta.js
46 lines (39 loc) · 1.25 KB
/
meta.js
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
export const baseUrl = new URL('',import.meta.url);
// will return url in the browser or filepath,
// in this file will return filepath
//console.debug('baseUrl:', baseUrl);
/** keyvalue
* @typedef {{string:string}} keyvalue
* representing argument list from Deno cli arguments
*
* i.e. port:80 mean key=port value=80
*
* key can be port or anything else
*/
/** args
* @type {keyvalue} args object
*/
const args = new Map();
//default constant
args.set('mode', 'local')
args.set('root', '../client')
args.set('httpPort', 8001)
args.set('httpsPort', 4000)
args.set('hostname', 'localhost')
args.set('protocol', 'https')
if (Deno.args.length) {
Deno.args.map((e) => {
const [k, v] = e.split(":");
args.set(k, v);
//args[k.toLowerCase()] = v;
});
}
const MODE = args.get('mode') ?? 'local';
const ROOT = args.get('root') ?? '../client';
const HTTPPORT = MODE === 'live' ? 80 : args.get('httpPort') ?? 8001;
const HTTPSPORT = MODE === 'live' ? 443 :args.get('httpsPort') ?? 4000;
const HOSTNAME = MODE === 'live' ? Deno.hostname(): args.get('hostname') ?? 'localhost';
const PROTOCOL = args.get('protocol');
// store sessionId
//sessionStorage.setItem("session", crypto.randomUUID());
export { ROOT, MODE, HTTPPORT, HTTPSPORT, HOSTNAME, PROTOCOL };