Gathering detailed insights and metrics for koa-send
Gathering detailed insights and metrics for koa-send
Gathering detailed insights and metrics for koa-send
Gathering detailed insights and metrics for koa-send
npm install koa-send
Typescript
Module System
Min. Node Version
Node Version
NPM Version
95.9
Supply Chain
100
Quality
82.3
Maintenance
100
Vulnerability
100
License
TypeScript (100%)
Total Downloads
149,189,248
Last Day
41,983
Last Week
537,247
Last Month
3,184,598
Last Year
37,575,559
427 Stars
131 Commits
85 Forks
8 Watching
5 Branches
39 Contributors
Latest Version
5.0.1
Package Id
koa-send@5.0.1
Size
5.30 kB
NPM Version
6.14.4
Node Version
12.18.0
Publised On
08 Jul 2020
Cumulative downloads
Total Downloads
Last day
-71.5%
41,983
Compared to previous day
Last week
-31.9%
537,247
Compared to previous week
Last month
-9.3%
3,184,598
Compared to previous month
Last year
7.4%
37,575,559
Compared to previous year
Static file serving middleware.
1$ npm install koa-send
maxage
Browser cache max-age in milliseconds. (defaults to 0
).immutable
Tell the browser the resource is immutable and can be cached indefinitely. (defaults to false
).hidden
Allow transfer of hidden files. (defaults to false
).root
Root directory to restrict file access.index
Name of the index file to serve automatically when visiting the root location. (defaults to none).gzip
Try to serve the gzipped version of a file automatically when gzip
is supported by a client and if the requested file with .gz
extension exists. (defaults to true
).brotli
Try to serve the brotli version of a file automatically when brotli
is supported by a client and if the requested file with .br
extension exists. (defaults to true
).format
If not false
(defaults to true
), format the path to serve static file servers and not require a trailing slash for directories, so that you can do both /directory
and /directory/
.setHeaders
Function to set custom headers on response.extensions
Try to match extensions from passed array to search for file when no extension is sufficed in URL. First found is served. (defaults to false
)Note that root
is required, defaults to ''
and will be resolved,
removing the leading /
to make the path relative and this
path must not contain "..", protecting developers from
concatenating user input. If you plan on serving files based on
user input supply a root
directory from which to serve from.
For example to serve files from ./public
:
1app.use(async (ctx) => { 2 await send(ctx, ctx.path, { root: __dirname + '/public' }); 3})
To serve developer specified files:
1app.use(async (ctx) => { 2 await send(ctx, 'path/to/my.js'); 3})
The function is called as fn(res, path, stats)
, where the arguments are:
res
: the response object.path
: the resolved file path that is being sent.stats
: the stats object of the file that is being sent.You should only use the setHeaders
option when you wish to edit the Cache-Control
or Last-Modified
headers, because doing it before is useless (it's overwritten by send
), and doing it after is too late because the headers are already sent.
If you want to edit any other header, simply set them before calling send
.
1const send = require('koa-send'); 2const Koa = require('koa'); 3const app = new Koa(); 4 5// $ GET /package.json 6// $ GET / 7 8app.use(async (ctx) => { 9 if ('/' == ctx.path) return ctx.body = 'Try GET /package.json'; 10 await send(ctx, ctx.path); 11}) 12 13app.listen(3000); 14console.log('listening on port 3000');
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
2 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 3
Reason
Found 10/29 approved changesets -- score normalized to 3
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More