Installations
npm install express-robots-txt
Releases
Unable to fetch releases
Developer
modosc
Developer Guide
Module System
CommonJS, ESM
Min. Node Version
Typescript Support
No
Node Version
14.17.0
NPM Version
6.14.13
Statistics
15 Stars
97 Commits
5 Forks
3 Watching
4 Branches
7 Contributors
Updated on 14 Sept 2024
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
3,175,623
Last day
-4.7%
3,583
Compared to previous day
Last week
7.7%
21,607
Compared to previous week
Last month
-0.4%
89,497
Compared to previous month
Last year
51.3%
1,006,416
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
express-robots-txt
Express middleware for generating a robots.txt or responding with an existing file.
Usage
1// es6 usage requires a version of node which supports esm_conditional_exports, see 2// https://nodejs.org/api/esm.html#esm_conditional_exports 3import express from 'express' 4import robots from 'express-robots-txt' 5 6// commonjs 7const express = require('express') 8const robots = require('express-robots-txt') 9 10const app = express() 11const port = 3000 12 13app.use(robots({ 14 UserAgent: '*', 15 Disallow: '/', 16 CrawlDelay: '5', 17 Sitemap: 'https://nowhere.com/sitemap.xml', 18})) 19 20app.listen(port)
Using a file
1app.use(robots(__dirname + '/robots.txt'));
Using an object
Basic object
1app.use(robots({ 2 UserAgent: '*', 3 Disallow: '/' 4}))
Will produce:
User-agent: *
Disallow: /
Crawl Delay
You can optionally pass a CrawlDelay in just like passing in Disallow
1app.use(robots({ 2 UserAgent: '*', 3 Disallow: '/', 4 CrawlDelay: '5' 5}))
Will produce:
User-agent: *
Disallow: /
Crawl-delay: 5
Sitemap
You can optionally pass a Sitemap in just like passing in CrawlDelay:
1app.use(robots({ 2 UserAgent: '*', 3 Disallow: '/', 4 CrawlDelay: '5', 5 Sitemap: 'https://nowhere.com/sitemap.xml' 6}))
Will produce:
User-agent: *
Disallow: /
Crawl-delay: 5
Sitemap: https://nowhere.com/sitemap.xml
You can also pass in an array of Sitemaps:
1app.use(robots({ 2 UserAgent: '*', 3 Disallow: '/', 4 CrawlDelay: '5', 5 Sitemap: [ 6 'https://nowhere.com/sitemap.xml', 7 'https://nowhere.com/sitemap2.xml' 8 ] 9}))
Will produce:
User-agent: *
Disallow: /
Crawl-delay: 5
Sitemap: https://nowhere.com/sitemap.xml
Sitemap: https://nowhere.com/sitemap2.xml
Or an array of objects
1app.use(robots([ 2 { 3 UserAgent: 'Googlebot', 4 Disallow: '/no-google' 5 }, 6 { 7 UserAgent: 'Bingbot', 8 Disallow: '/no-bing' 9 } 10]));
Will produce:
User-agent: Googlebot
Disallow: /no-google
User-agent: Bingbot
Disallow: /no-bing
Or either property (UserAgent | Disallow) as an array
1app.use(robots([ 2 { 3 UserAgent: [ 'Googlebot', 'Slurp' ], 4 Disallow: [ '/no-google', '/no-yahoo' ] 5 }, 6 { 7 UserAgent: '*', 8 Disallow: [ '/no-bots', '/still-no-bots' ] 9 } 10]));
Will produce:
User-agent: Googlebot
User-agent: Slurp
Disallow: /no-google
Disallow: /no-yahoo
User-agent: *
Disallow: /no-bots
Disallow: /still-no-bots
Host
You can optionally pass a Host in just like passing in Disallow. Note that some crawlers may not support this drective.
1app.use(robots({ 2 UserAgent: '*', 3 Disallow: '/', 4 CrawlDelay: '5', 5 Host: 'foobar.com' 6}))
Will produce:
User-agent: *
Disallow: /
Crawl-delay: 5
Host: foobar.com
Thanks
Originally forked from weo-edu/express-robots.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
Found 0/8 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
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/nodejs.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/modosc/express-robots-txt/nodejs.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/modosc/express-robots-txt/nodejs.yml/main?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 24 are checked with a SAST tool
Reason
17 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
Score
2.4
/10
Last Scanned on 2024-11-18
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