Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@frangio/servbot
Advanced tools
Readme
A small dev server for local static site development. Essentially a wrapper around http.Server. Fork of servor.
import servbot from 'servbot';
const server = servbot({
root: './public/',
reload: true,
fallback: 'index.html'
});
server.listen(8080);
This is an opinionated fork with some intentional exclusions and smaller scope, and some ideas taken from nativew/serve.
npm install servbot --save-dev
See types in index.d.ts. servbot accepts a single argument, ServbotOptions
; and returns an instance of ServbotServer
. See below for the default options.
import servbot from 'servbot';
const server = servbot({
// root: string
// Directory to serve. Relative to process.cwd().
root: '.',
// reload: boolean
// Flag to enable manual reload.
reload: false,
// fallback: string
// Filename to fallback to for single-page applications. Relative to `root`.
// Leaving this empty assumes you are not serving a single-page application
fallback: '',
// ignores: RegExp[]
// *Only applicable when `fallback` is provided and `ignores` is not an empty array*
// A list of patterns to *not* route to your fallback
// Useful when you want to be able to route non-filetypes to your SPA ("/foo/routename.hi")
// But otherwise, want to "ignore" routes that should be static files ("/main.css", "/js/jquery.js")
ignores: [],
// credentials: object
// TLS Credentials. Providing these enables an HTTPS server
// See https://nodejs.org/api/https.html#httpscreateserveroptions-requestlistener
credentials: undefined
});
// Start server on port 8080
server.listen(8080);
// Close server from new connections
// https://nodejs.org/api/net.html#serverclosecallback
server.close((err) => {
if (err) process.exit();
});
Instead of including a filewatcher to automatically reload your app on file changes, servbot includes a manual reload feature. Most modern front-end development build tools already include a built-in watch feature (esbuild, rollup, webpack, parcel, etc.) that can be leveraged by servbot. For an example with rollup, see here.
Outside of build tools, you can also use something like cheap-watch or watchlist. See below for an example using watchlist:
import servbot from 'servbot';
import { watch } from 'watchlist';
const server = servbot({
root: './example/static/',
reload: true,
fallback: 'index.html'
});
server.listen(8080);
(async () => {
await watch(['./example/static/'], async () => {
console.log('change detected! reloading...');
server.reload();
});
})();
FAQs
A small dev server script for local static site development
The npm package @frangio/servbot receives a total of 556 weekly downloads. As such, @frangio/servbot popularity was classified as not popular.
We found that @frangio/servbot demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.