mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add live-server type declarations (#45621)
* Add live-server type declarations * Add shutdown function to live-server types Co-authored-by: mrjoshc <hello@joshcummingsdesign.com>
This commit is contained in:
parent
4abecf3200
commit
5142132dc0
40
types/live-server/index.d.ts
vendored
Normal file
40
types/live-server/index.d.ts
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
// Type definitions for live-server 1.2
|
||||
// Project: https://github.com/tapio/live-server#readme
|
||||
// Definitions by: Josh Cummings <https://github.com/joshcummingsdesign>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* The live-server start params.
|
||||
*/
|
||||
export interface LiveServerParams {
|
||||
/** Set the server port. Defaults to 8080. */
|
||||
port?: number;
|
||||
/** Set the address to bind to. Defaults to 0.0.0.0 or process.env.IP. */
|
||||
host?: string;
|
||||
/** Set root directory that's being served. Defaults to cwd. */
|
||||
root?: string;
|
||||
/** When false, it won't load your browser by default. */
|
||||
open?: boolean;
|
||||
/** Comma-separated string for paths to ignore. */
|
||||
ignore?: string;
|
||||
/** When set, serve this file (server root relative) for every 404 (useful for single-page applications). */
|
||||
file?: string;
|
||||
/** Waits for all changes, before reloading. Defaults to 0 sec. */
|
||||
wait?: number;
|
||||
/** Mount a directory to a route. */
|
||||
mount?: string[][];
|
||||
/** 0 = errors only, 1 = some, 2 = lots */
|
||||
logLevel?: 0 | 1 | 2;
|
||||
/** Takes an array of Connect-compatible middleware that are injected into the server middleware stack. */
|
||||
middleware?: Array<(req: any, res: any, next: any) => void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start live-server.
|
||||
*/
|
||||
export function start(params: LiveServerParams): void;
|
||||
|
||||
/**
|
||||
* Shutdown live-server.
|
||||
*/
|
||||
export function shutdown(): void;
|
||||
20
types/live-server/live-server-tests.ts
Normal file
20
types/live-server/live-server-tests.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import liveServer = require('live-server');
|
||||
|
||||
liveServer.start({
|
||||
port: 8181,
|
||||
host: '0.0.0.0',
|
||||
root: '/public',
|
||||
open: false,
|
||||
ignore: 'scss,my/templates',
|
||||
file: 'index.html',
|
||||
wait: 1000,
|
||||
mount: [['/components', './node_modules']],
|
||||
logLevel: 2,
|
||||
middleware: [
|
||||
(req: any, res: any, next: any) => {
|
||||
next();
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
liveServer.shutdown();
|
||||
23
types/live-server/tsconfig.json
Normal file
23
types/live-server/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"live-server-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/live-server/tslint.json
Normal file
1
types/live-server/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user