Skip to content

Commit 5d91de7

Browse files
committed
Add types
1 parent aef1ea6 commit 5d91de7

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
"description": "Convert query parameters from API urls to MongoDB queries",
55
"main": "dist/cjs/index.js",
66
"files": [
7-
"dist/"
7+
"dist/",
8+
"./types.d.ts"
89
],
10+
"types": "./types.d.ts",
911
"scripts": {
1012
"build": "babel ./src/index.js --out-file ./dist/cjs/index.js",
1113
"coverage": "nyc npm test && nyc report --reporter=html",

types.d.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
declare module 'api-query-params' {
2+
export type AqpQuery = {
3+
filter: Record<string, any>;
4+
skip: number;
5+
limit: number;
6+
sort: Record<string, number>;
7+
projection: Record<string, number>;
8+
};
9+
10+
function aqp(
11+
query: string | Record<string, string>,
12+
opt?: {
13+
skipKey?: string;
14+
limitKey?: string;
15+
projectionKey?: string;
16+
sortKey?: string;
17+
filterKey?: string;
18+
populationKey?: string;
19+
20+
blacklist?: string[];
21+
whitelist?: string[];
22+
23+
castParams?: unknown;
24+
casters?: unknown;
25+
}
26+
): AqpQuery;
27+
28+
export default aqp;
29+
}

0 commit comments

Comments
 (0)