![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
sync-dev-server
Advanced tools
Starts a server before your tests and stops on completion. Inspired by jest-puppeteer's subpackage jest-dev-server. Setup and teardown operations are fully synchronous.
Starts a server before your tests and stops on completion
Inspired by jest-puppeteer's subpackage jest-dev-server
Setup and teardown operations are fully synchronous
npm install sync-dev-server
Try with Replit.
startServer(command, options);
stopServer(server, signal);
Full example, specifying all options:
// const { startServer, stopServer } = require('sync-dev-server');
import { startServer, stopServer } from 'sync-dev-server';
const options = {
// Note: all fields below are optional with set defaults
host: '127.0.0.1',
port: 49152,
timeout: 10000,
debug: true,
signal: 'SIGINT',
usedPortAction: 'ignore', // alternatives are 'kill' and 'error'
env: {
secretKey: "bruno's fight club"
},
}
const server = startServer('npm start', options);
// Send requests to the server or perform other operations
// ...
// ...
// ...
stopServer(server, 'SIGINT');
When using Jest, you can create and stop the server using Setup and Teardown, for example with beforeAll and afterAll. To start and stop the server for all test suites, look into setupFiles, setupFilesAfterEnv, globalSetup and globalTeardown.
Type: string
The command to start your server with. Below are a few examples:
npm start
npm run dev
yarn start
node src/app.js
ts-node src/server.ts
In src/types.ts, the options interface is defined as:
type UsedPortAction = 'error' | 'ignore' | 'kill';
interface Options {
host?: string;
port?: number;
timeout?: number;
debug?: boolean;
signal?: string | number;
usedPortAction?: UsedPortAction;
env?: Record<string, string>;
}
Type: string
, Default: undefined
Host to wait for activity before considering that the server is running.
If not specified, no address
will be passed into node-netstat. This means that all local addresses will be checked, including localhost
, 127.0.0.1
, 0.0.0.0
, etc.
Type: number
, Default: 5000
Port to wait for activity before considering that the server is running.
Type: number
, Default: 10000
The timeout for individual tasks (not total time), which are:
options.usedPortAction === 'kill'
Type: boolean
, Default: true
Logs the server output to stdout
if true, ignore stdout
otherwise.
Type: number | string
Default: 'SIGTERM'
(15
)
The inter-process communication signals that will be used to kill any existing server, if options.usedPortAction === 'kill'
.
Type: 'error' | 'ignore' | 'kill'
. Default: 'error'
A string that defines the action to take if the given port is already in use, whereby
error
: Throws a generic Error objectignore
: Assumes that the server is already started. startServer
will return null
.kill
: the process occupying this port is automatically killedType: Record<string, string>
. Default: {}
Any environment variables you want to pass into the spawned server. This will take precedence over existing variables in process.env
.
Type: ChildProcess
| null
The server child process returned from startServer
.
stopServer
will do nothing if null
is passed.
Type: number | string
. Default: 'SIGTERM'
(15
)
The inter-process communication signals that will be used to kill the server.
Copyright (c) 2023 Khiet Tam Nguyen
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the “Software”),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
There are currently no known limitations.
sync-dev-server has been tested on Linux, Windows and MacOS.
It leverages node-netstat, kill-sync, dns-lookup-sync and slync which are all cross-platform.
FAQs
Starts a server before your tests and stops on completion. Inspired by jest-puppeteer's subpackage jest-dev-server. Setup and teardown operations are fully synchronous.
The npm package sync-dev-server receives a total of 18 weekly downloads. As such, sync-dev-server popularity was classified as not popular.
We found that sync-dev-server demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.