Skip to content

Commit

Permalink
add TS configure and build step
Browse files Browse the repository at this point in the history
  • Loading branch information
sdenardi committed May 14, 2020
1 parent 18e8b4a commit a1bd44f
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.DS_Store
package-lock.json
lib/
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src/
tsconfig.json
.eslintrc
.gitignore
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "zoomapi",
"version": "1.0.0",
"private": true,
"version": "1.0.0-alpha",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"description": "NodeJS library for working with the Zoom API.",
"repository": {
"type": "git",
Expand All @@ -10,6 +11,9 @@
"author": "Sanders DeNardi <sedenardi@gmail.com> (http://www.sandersdenardi.com/)",
"homepage": "https://github.com/sedenardi/zoomapi",
"license": "MIT",
"scripts": {
"build": "tsc"
},
"dependencies": {
"jsonwebtoken": "^8.5.1"
},
Expand Down
60 changes: 30 additions & 30 deletions src/users.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
import request from './util/request';
import { ZoomOptions } from '.';

export type ListUsersParams = {
status?: 'active' | 'inactive' | 'pending';
page_size?: number;
page_number?: number;
role_id?: string;
};
export type ListUserResponse = {
page_count: number;
page_number: number;
page_size: number;
total_records: number;
users: {
id: string;
first_name: string;
last_name: string;
email: string;
type: 1 | 2 | 3;
status: string;
pmi: number;
timezone: string;
dept: string;
created_at: string;
last_login_time: string;
last_client_version: string;
group_ids: string[];
im_group_ids: string[];
verified: 0 | 1;
}[];
};

export default function(zoomApiOpts: ZoomOptions) {
const zoomRequest = request(zoomApiOpts);

type ListUsersParams = {
status?: 'active' | 'inactive' | 'pending';
page_size?: number;
page_number?: number;
role_id?: string;
};
type ListUserResponse = {
page_count: number;
page_number: number;
page_size: number;
total_records: number;
users: {
id: string;
first_name: string;
last_name: string;
email: string;
type: 1 | 2 | 3;
status: string;
pmi: number;
timezone: string;
dept: string;
created_at: string;
last_login_time: string;
last_client_version: string;
group_ids: string[];
im_group_ids: string[];
verified: 0 | 1;
}[];
};
const ListUsers = function(params?: ListUsersParams) {
return zoomRequest<ListUserResponse>({
method: 'GET',
Expand All @@ -41,7 +42,6 @@ export default function(zoomApiOpts: ZoomOptions) {
});
};


return {
ListUsers
};
Expand Down
11 changes: 7 additions & 4 deletions src/util/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ import { ZoomOptions } from '../';
const BASE_URL = 'api.zoom.us';
const API_VERSION = '/v2';

type QueryParams = {
[key: string]: string | number;
};
type ZoomRequestOpts = {
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
path: string;
params?: object;
params?: QueryParams;
body?: object;
};

const buildURL = function(url: string, params?: object) {
const buildURL = function(url: string, params?: QueryParams) {
if (!params) {
return url;
}
const sp = new URLSearchParams();
for (const k in params) {
if (params[k] !== undefined) {
sp.set(k, params[k]);
sp.set(k, params[k].toString());
}
}
return url + '?' + sp.toString();
Expand All @@ -43,7 +46,7 @@ export default function(zoomApiOpts: ZoomOptions) {
return reject(new Error(`HTTPS request failed, status code: ${res.statusCode}`));
}

const data = [];
const data: any[] = [];
res.on('data', (chunk) => {
data.push(chunk);
});
Expand Down
12 changes: 12 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"esModuleInterop": true,
"target": "ES2017",
"module": "commonjs",
"moduleResolution": "node",
"declaration": true,
"outDir": "./lib"
},
"include": ["src"],
"exclude": ["node_modules"]
}

0 comments on commit a1bd44f

Please sign in to comment.