Skip to content

Commit

Permalink
added minimal typescript support
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielJDufour committed Jul 19, 2022
1 parent 9774d88 commit 2dbf635
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
18 changes: 13 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@
"version": "0.3.1",
"description": "Another Development Server. Supports Range Requests. Configure through Environmental Variables.",
"main": "srvd.js",
"types": "srvd.d.ts",
"bin": {
"srvd": "bin/srvd.js"
},
"files": [
"srvd.js",
"bin/srvd.js"
"bin/srvd.js",
"srvd.d.ts"
],
"scripts": {
"build": "mkdir -p bin && echo \"#!/usr/bin/env node\n\" > ./bin/srvd.js && cat srvd.js >> ./bin/srvd.js",
"format": "npx prettier --arrow-parens=avoid --print-width=120 --trailing-comma=none --write srvd.js *.js test/*.js",
"test": "node test/test.cb.js && node test/test.max.js && node test/test.env.js && node test/test.wait.js"
"f": "npm run format",
"format": "npx prettier --arrow-parens=avoid --print-width=120 --trailing-comma=none --write srvd.js *.js test/*.js test/*.ts",
"test": "npm run test:js && npm run test:ts",
"test:js": "node test/test.cb.js && node test/test.max.js && node test/test.env.js && node test/test.wait.js",
"test:ts": "npx ts-node ./test/test.types.ts"
},
"repository": {
"type": "git",
Expand All @@ -39,7 +44,10 @@
},
"homepage": "https://github.com/DanielJDufour/srvd#readme",
"dependencies": {
"finalhandler": "^1.1.2",
"serve-static": "^1.14.1"
"finalhandler": "^1.2.0",
"serve-static": "^1.15.0"
},
"devDependencies": {
"flug": "^2.3.1"
}
}
16 changes: 16 additions & 0 deletions srvd.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export function serve(options?: {
acceptRanges?: boolean,
debug?: boolean,
max?: number,
wait?: number,
root?: string,
port?: number
}): {
acceptRanges: boolean,
debug: boolean,
max: number,
server: any,
port: number,
root: string,
wait: number
}
15 changes: 15 additions & 0 deletions test/test.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import test from "flug";
import { serve } from "../srvd";

declare var process: any;

test("testing types", ({ eq }) => {
const { acceptRanges, debug, max, server, port, root, wait } = serve();
server.close();
eq(acceptRanges, true);
eq(debug, false);
eq(max, Infinity);
eq(port, 8080);
eq(root, process.cwd());
eq(wait, 60);
});

0 comments on commit 2dbf635

Please sign in to comment.