Gathering detailed insights and metrics for @shellscape/koa-send
Gathering detailed insights and metrics for @shellscape/koa-send
Gathering detailed insights and metrics for @shellscape/koa-send
Gathering detailed insights and metrics for @shellscape/koa-send
npm install @shellscape/koa-send
Typescript
Module System
Min. Node Version
Node Version
NPM Version
75.8
Supply Chain
99.5
Quality
73.1
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
6,671,067
Last Day
351
Last Week
2,736
Last Month
20,640
Last Year
304,128
113 Commits
1 Forks
2 Watching
4 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
4.1.3
Package Id
@shellscape/koa-send@4.1.3
Size
5.37 kB
NPM Version
5.6.0
Node Version
9.2.0
Publised On
04 Apr 2018
Cumulative downloads
Total Downloads
Last day
-41.2%
351
Compared to previous day
Last week
-17.4%
2,736
Compared to previous week
Last month
-48.3%
20,640
Compared to previous month
Last year
-28.3%
304,128
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 objectpath
: the resolved file path that is being sentstats
: 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');
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
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