1- require ( 'dotenv' ) . config ( )
21import * as express from 'express'
32
43import * as fs from 'fs'
@@ -64,11 +63,11 @@ export function init(serverPath?: string, nodeModulesPath?: string) {
6463 node_modules = nodeModulesPath || path . join ( dirname , 'node_modules' )
6564
6665 reloadPath = path . resolve (
67- path . join ( node_modules , 'reloadsh.js/reloader.browser.js' )
66+ path . join ( node_modules , 'reloadsh.js/reloader.browser.js' ) ,
6867 )
6968
7069 liascriptPath = path . resolve (
71- path . join ( node_modules , '@liascript/editor/dist' )
70+ path . join ( node_modules , '@liascript/editor/dist' ) ,
7271 )
7372}
7473
@@ -80,7 +79,7 @@ export function start(
8079 liveReload ?: boolean ,
8180 openInBrowser ?: boolean ,
8281 testOnline ?: boolean ,
83- gotoCallback ?: ( linenumber : number , filename : string ) => void
82+ gotoCallback ?: ( linenumber : number , filename : string ) => void ,
8483) {
8584 port = port || 3000
8685 hostname = hostname || 'localhost'
@@ -116,7 +115,7 @@ export function start(
116115 layoutsDir : path . resolve ( path . join ( dirname , 'views/layouts' ) ) ,
117116 defaultLayout : 'main' ,
118117 extname : 'hbs' ,
119- } )
118+ } ) ,
120119 )
121120 app . set ( 'views' , path . resolve ( path . join ( dirname , 'views' ) ) )
122121
@@ -170,7 +169,7 @@ export function start(
170169 name : string
171170 href : string
172171 isDirectory : boolean
173- }
172+ } ,
174173 ) => {
175174 if ( a . isDirectory && ! b . isDirectory ) {
176175 return - 1
@@ -184,18 +183,18 @@ export function start(
184183 }
185184 }
186185 return 0
187- }
186+ } ,
188187 ) ,
189188 } )
190189 } else if ( stats . isFile ( ) ) {
191190 if ( req . params [ 0 ] . toLocaleLowerCase ( ) . endsWith ( '.md' ) ) {
192191 if ( testOnline ) {
193192 res . redirect (
194- `https://LiaScript.github.io/course/?http://${ hostname } :${ port } /${ req . params [ 0 ] } `
193+ `https://LiaScript.github.io/course/?http://${ hostname } :${ port } /${ req . params [ 0 ] } ` ,
195194 )
196195 } else {
197196 res . redirect (
198- `/liascript/index.html?http://${ hostname } :${ port } /${ req . params [ 0 ] } `
197+ `/liascript/index.html?http://${ hostname } :${ port } /${ req . params [ 0 ] } ` ,
199198 )
200199 }
201200 } else {
@@ -210,7 +209,7 @@ export function start(
210209 '/liascript/' ,
211210 function ( req : express . Request , res : express . Response ) {
212211 res . redirect ( '/liascript/index.html' )
213- }
212+ } ,
214213 )
215214
216215 app . get (
@@ -232,10 +231,10 @@ export function start(
232231 `<script type='text/javascript' src='/reloader/reloader.js'></script>
233232 <script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${ responsiveVoice } '></script>
234233 ${ gotoScript }
235- </head>`
236- )
234+ </head>` ,
235+ ) ,
237236 )
238- }
237+ } ,
239238 )
240239 }
241240 // ------------------------------------
@@ -253,10 +252,10 @@ export function start(
253252 '</head>' ,
254253 `<script type='text/javascript' src='/reloader/reloader.js'></script>
255254 ${ gotoScript }
256- </head>`
257- )
255+ </head>` ,
256+ ) ,
258257 )
259- }
258+ } ,
260259 )
261260 }
262261 // ------------------------------------
@@ -274,10 +273,10 @@ export function start(
274273 '</head>' ,
275274 `<script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${ responsiveVoice } '></script>
276275 ${ gotoScript }
277- </head>`
278- )
276+ </head>` ,
277+ ) ,
279278 )
280- }
279+ } ,
281280 )
282281 }
283282 // ------------------------------------
@@ -291,10 +290,10 @@ export function start(
291290 return
292291 }
293292 res . send ( data . replace ( '</head>' , `${ gotoScript } </head>` ) )
294- }
293+ } ,
295294 )
296295 }
297- }
296+ } ,
298297 )
299298
300299 // load everything from the liascript folder
@@ -307,26 +306,26 @@ export function start(
307306 const projectPath = req . params [ 0 ]
308307 console . log (
309308 `File not found in liascriptPath, trying project.path: ${ projectPath } ` ,
310- project . path
309+ project . path ,
311310 )
312311 res . sendFile ( projectPath , { root : project . path } )
313312 }
314313 } )
315- }
314+ } ,
316315 )
317316 // ignore this one
318317 app . get ( '/sw.js' , function ( req : express . Request , res : express . Response ) { } )
319318 app . get (
320319 '/favicon.ico' ,
321- function ( req : express . Request , res : express . Response ) { }
320+ function ( req : express . Request , res : express . Response ) { } ,
322321 )
323322
324323 // pass the reloader, to be used for live updates
325324 app . get (
326325 '/reloader/reloader.js' ,
327326 function ( req : express . Request , res : express . Response ) {
328327 res . sendFile ( reloadPath )
329- }
328+ } ,
330329 )
331330
332331 // react to click-events
@@ -338,7 +337,7 @@ export function start(
338337 gotoCallback ( linenumber , filename )
339338 } catch ( e ) {
340339 console . warn (
341- "lineGoto event with wrong datatype, you have to provide {'linenumber': int, 'filename': string}"
340+ "lineGoto event with wrong datatype, you have to provide {'linenumber': int, 'filename': string}" ,
342341 )
343342 }
344343 }
@@ -374,15 +373,15 @@ export function start(
374373
375374 const server = require ( 'reloadsh.js' ) (
376375 app ,
377- liveReload ? [ path . join ( project . path , project . readme || '' ) ] : [ ]
376+ liveReload ? [ path . join ( project . path , project . readme || '' ) ] : [ ] ,
378377 )
379378
380379 if ( liveReload ) {
381380 console . log (
382381 `✨ watching for changes on: "${ path . join (
383382 project . path || '' ,
384- project . readme || ''
385- ) } "`
383+ project . readme || '' ,
384+ ) } "`,
386385 )
387386 }
388387
@@ -399,7 +398,7 @@ export function start(
399398 console . log ( '📡 starting server' )
400399 console . log ( ` - local: ${ localURL } ` )
401400 console . log (
402- ` - on your network: ${ localURL . replace ( hostname , ip . address ( ) ) } `
401+ ` - on your network: ${ localURL . replace ( hostname , ip . address ( ) ) } ` ,
403402 )
404403
405404 serverPointer = server
@@ -417,15 +416,15 @@ export function gotoLine(linenumber: number, filename: string) {
417416 `data: ${ JSON . stringify ( {
418417 linenumber : linenumber ,
419418 filename : filename ,
420- } ) } \n\n`
421- )
419+ } ) } \n\n`,
420+ ) ,
422421 )
423422}
424423
425424function eventsHandler (
426425 request : express . Request ,
427426 response : express . Response ,
428- next : any
427+ next : any ,
429428) {
430429 const headers = {
431430 'Content-Type' : 'text/event-stream' ,
0 commit comments