File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -318,9 +318,28 @@ uquik
318318```
319319
320320### Static files
321- #### Global
321+ ``` javascript
322+ const { Server , StaticFiles } = require (" uquik" );
323+ const path = require (" path" );
324+
325+ const uquik = new Server ();
326+
327+ const static = StaticFiles ({
328+ root: path .join (__dirname , " www" ), // root directory
329+ indexFile: " index.html" , // index file name
330+ compress: true , // enable gzip compression?
331+ compressionThreshold: 1024 , // compression threshold
332+ });
333+
334+ uquik .get (" /*" , static );
335+ uquik .head (" /*" , static );
336+
337+ uquik
338+ .listen (5000 , " 127.0.0.1" )
339+ .then ((socket ) => console .log (" [Example] Server started" ))
340+ .catch ((error ) => console .log (" [Example] Failed to start a server" , error));
341+ ```
322342
323- #### Route-specific
324343
325344
326345### Production
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ const resolveFile = (file, indexFile = '') => {
1919 } else {
2020 throw new CustomError ( '404 Not Found' , 404 )
2121 }
22- } )
22+ } ) . catch ( ( ex ) => { throw new CustomError ( '404 Not Found' , 404 ) } )
2323}
2424
2525const destroy = ( dataTransfer ) => {
You can’t perform that action at this time.
0 commit comments