Skip to content

Commit

Permalink
Fix for StaticFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
piliugin-anton committed Jun 9, 2022
1 parent 42a6ab9 commit a089220
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
23 changes: 21 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,28 @@ uquik
```

### Static files
#### Global
```javascript
const { Server, StaticFiles } = require("uquik");
const path = require("path");

const uquik = new Server();

const static = StaticFiles({
root: path.join(__dirname, "www"), // root directory
indexFile: "index.html", // index file name
compress: true, // enable gzip compression?
compressionThreshold: 1024, // compression threshold
});

uquik.get("/*", static);
uquik.head("/*", static);

uquik
.listen(5000, "127.0.0.1")
.then((socket) => console.log("[Example] Server started"))
.catch((error) => console.log("[Example] Failed to start a server", error));
```

#### Route-specific


### Production
Expand Down
2 changes: 1 addition & 1 deletion src/StaticFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const resolveFile = (file, indexFile = '') => {
} else {
throw new CustomError('404 Not Found', 404)
}
})
}).catch((ex) => { throw new CustomError('404 Not Found', 404) })
}

const destroy = (dataTransfer) => {
Expand Down

0 comments on commit a089220

Please sign in to comment.