@apiverve/minimumwage 1.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +166 -0
  3. package/index.d.ts +33 -0
  4. package/index.js +215 -0
  5. package/package.json +48 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 APIVerve, and EvlarSoft LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,166 @@
1
+ # Minimum Wage API
2
+
3
+ Minimum Wage provides current minimum wage rates for all US states plus the federal minimum. Includes tipped minimum wages, effective rates (higher of state or federal), and historical federal minimum wage data.
4
+
5
+ ![Build Status](https://img.shields.io/badge/build-passing-green)
6
+ ![Code Climate](https://img.shields.io/badge/maintainability-B-purple)
7
+ ![Prod Ready](https://img.shields.io/badge/production-ready-blue)
8
+ [![npm version](https://img.shields.io/npm/v/@apiverve/minimumwage.svg)](https://www.npmjs.com/package/@apiverve/minimumwage)
9
+
10
+ This is a Javascript Wrapper for the [Minimum Wage API](https://apiverve.com/marketplace/minimumwage?utm_source=npm&utm_medium=readme)
11
+
12
+ ---
13
+
14
+ ## Installation
15
+
16
+ Using npm:
17
+ ```shell
18
+ npm install @apiverve/minimumwage
19
+ ```
20
+
21
+ Using yarn:
22
+ ```shell
23
+ yarn add @apiverve/minimumwage
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Configuration
29
+
30
+ Before using the Minimum Wage API client, you have to setup your account and obtain your API Key.
31
+ You can get it by signing up at [https://apiverve.com](https://apiverve.com?utm_source=npm&utm_medium=readme)
32
+
33
+ ---
34
+
35
+ ## Quick Start
36
+
37
+ [Get started with the Quick Start Guide](https://docs.apiverve.com/quickstart?utm_source=npm&utm_medium=readme)
38
+
39
+ The Minimum Wage API documentation is found here: [https://docs.apiverve.com/ref/minimumwage](https://docs.apiverve.com/ref/minimumwage?utm_source=npm&utm_medium=readme).
40
+ You can find parameters, example responses, and status codes documented here.
41
+
42
+ ### Setup
43
+
44
+ ```javascript
45
+ const minimumwageAPI = require('@apiverve/minimumwage');
46
+ const api = new minimumwageAPI({
47
+ api_key: '[YOUR_API_KEY]'
48
+ });
49
+ ```
50
+
51
+ ---
52
+
53
+ ## Usage
54
+
55
+ ---
56
+
57
+ ### Perform Request
58
+
59
+ Using the API is simple. All you have to do is make a request. The API will return a response with the data you requested.
60
+
61
+ ```javascript
62
+ var query = {
63
+ state: "CA"
64
+ };
65
+
66
+ api.execute(query, function (error, data) {
67
+ if (error) {
68
+ return console.error(error);
69
+ } else {
70
+ console.log(data);
71
+ }
72
+ });
73
+ ```
74
+
75
+ ---
76
+
77
+ ### Using Promises
78
+
79
+ You can also use promises to make requests. The API returns a promise that you can use to handle the response.
80
+
81
+ ```javascript
82
+ var query = {
83
+ state: "CA"
84
+ };
85
+
86
+ api.execute(query)
87
+ .then(data => {
88
+ console.log(data);
89
+ })
90
+ .catch(error => {
91
+ console.error(error);
92
+ });
93
+ ```
94
+
95
+ ---
96
+
97
+ ### Using Async/Await
98
+
99
+ You can also use async/await to make requests. The API returns a promise that you can use to handle the response.
100
+
101
+ ```javascript
102
+ async function makeRequest() {
103
+ var query = {
104
+ state: "CA"
105
+ };
106
+
107
+ try {
108
+ const data = await api.execute(query);
109
+ console.log(data);
110
+ } catch (error) {
111
+ console.error(error);
112
+ }
113
+ }
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Example Response
119
+
120
+ ```json
121
+ {
122
+ "status": "ok",
123
+ "error": null,
124
+ "data": {
125
+ "state": "CA",
126
+ "stateName": "California",
127
+ "minimumWage": 16,
128
+ "stateRate": 16,
129
+ "federalRate": 7.25,
130
+ "tippedMinimum": 16,
131
+ "usesFederalRate": false,
132
+ "note": null
133
+ }
134
+ }
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Customer Support
140
+
141
+ Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact?utm_source=npm&utm_medium=readme).
142
+
143
+ ---
144
+
145
+ ## Updates
146
+
147
+ Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Twitter.
148
+
149
+ ---
150
+
151
+ ## Legal
152
+
153
+ All usage of the APIVerve website, API, and services is subject to the [APIVerve Terms of Service](https://apiverve.com/terms?utm_source=npm&utm_medium=readme), [Privacy Policy](https://apiverve.com/privacy?utm_source=npm&utm_medium=readme), and [Refund Policy](https://apiverve.com/refund?utm_source=npm&utm_medium=readme).
154
+
155
+ ---
156
+
157
+ ## License
158
+ Licensed under the The MIT License (MIT)
159
+
160
+ Copyright (©) 2026 APIVerve, and EvlarSoft LLC
161
+
162
+ 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:
163
+
164
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
165
+
166
+ 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.
package/index.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ declare module '@apiverve/minimumwage' {
2
+ export interface minimumwageOptions {
3
+ api_key: string;
4
+ secure?: boolean;
5
+ }
6
+
7
+ export interface minimumwageResponse {
8
+ status: string;
9
+ error: string | null;
10
+ data: MinimumWageData;
11
+ code?: number;
12
+ }
13
+
14
+
15
+ interface MinimumWageData {
16
+ state: string;
17
+ stateName: string;
18
+ minimumWage: number;
19
+ stateRate: number;
20
+ federalRate: number;
21
+ tippedMinimum: number;
22
+ usesFederalRate: boolean;
23
+ note: null;
24
+ }
25
+
26
+ export default class minimumwageWrapper {
27
+ constructor(options: minimumwageOptions);
28
+
29
+ execute(callback: (error: any, data: minimumwageResponse | null) => void): Promise<minimumwageResponse>;
30
+ execute(query: Record<string, any>, callback: (error: any, data: minimumwageResponse | null) => void): Promise<minimumwageResponse>;
31
+ execute(query?: Record<string, any>): Promise<minimumwageResponse>;
32
+ }
33
+ }
package/index.js ADDED
@@ -0,0 +1,215 @@
1
+ const axios = require('axios');
2
+
3
+ class minimumwageWrapper {
4
+
5
+ constructor(options) {
6
+ if (!options || typeof options !== 'object') {
7
+ throw new Error('Options object must be provided. See documentation: https://docs.apiverve.com/ref/minimumwage');
8
+ }
9
+
10
+ const { api_key, secure = true } = options;
11
+
12
+ if (!api_key || typeof api_key !== 'string') {
13
+ throw new Error('API key must be provided as a non-empty string. Get your API key at: https://apiverve.com');
14
+ }
15
+
16
+ // Validate API key format (GUID or alphanumeric with hyphens)
17
+ const apiKeyPattern = /^[a-zA-Z0-9-]+$/;
18
+ if (!apiKeyPattern.test(api_key)) {
19
+ throw new Error('Invalid API key format. API key must be alphanumeric and may contain hyphens. Get your API key at: https://apiverve.com');
20
+ }
21
+
22
+ // Check minimum length (GUIDs are typically 36 chars with hyphens, or 32 without)
23
+ const trimmedKey = api_key.replace(/-/g, '');
24
+ if (trimmedKey.length < 32) {
25
+ throw new Error('Invalid API key. API key appears to be too short. Get your API key at: https://apiverve.com');
26
+ }
27
+
28
+ if (typeof secure !== 'boolean') {
29
+ throw new Error('Secure parameter must be a boolean value.');
30
+ }
31
+
32
+ this.APIKey = api_key;
33
+ this.IsSecure = secure;
34
+
35
+ // secure is deprecated, all requests must be made over HTTPS
36
+ this.baseURL = 'https://api.apiverve.com/v1/minimumwage';
37
+
38
+ // Validation rules for parameters (generated from schema)
39
+ this.validationRules = {"state":{"type":"string","required":false,"minLength":2,"maxLength":2}};
40
+ }
41
+
42
+ /**
43
+ * Validate query parameters against schema rules
44
+ * @param {Object} query - The query parameters to validate
45
+ * @throws {Error} - If validation fails
46
+ */
47
+ validateParams(query) {
48
+ const errors = [];
49
+
50
+ for (const [paramName, rules] of Object.entries(this.validationRules)) {
51
+ const value = query[paramName];
52
+
53
+ // Check required
54
+ if (rules.required && (value === undefined || value === null || value === '')) {
55
+ errors.push(`Required parameter [${paramName}] is missing.`);
56
+ continue;
57
+ }
58
+
59
+ // Skip validation if value is not provided and not required
60
+ if (value === undefined || value === null) {
61
+ continue;
62
+ }
63
+
64
+ // Type validation
65
+ if (rules.type === 'integer' || rules.type === 'number') {
66
+ const numValue = Number(value);
67
+ if (isNaN(numValue)) {
68
+ errors.push(`Parameter [${paramName}] must be a valid ${rules.type}.`);
69
+ continue;
70
+ }
71
+
72
+ if (rules.type === 'integer' && !Number.isInteger(numValue)) {
73
+ errors.push(`Parameter [${paramName}] must be an integer.`);
74
+ continue;
75
+ }
76
+
77
+ // Min/max validation for numbers
78
+ if (rules.min !== undefined && numValue < rules.min) {
79
+ errors.push(`Parameter [${paramName}] must be at least ${rules.min}.`);
80
+ }
81
+ if (rules.max !== undefined && numValue > rules.max) {
82
+ errors.push(`Parameter [${paramName}] must be at most ${rules.max}.`);
83
+ }
84
+ } else if (rules.type === 'string') {
85
+ if (typeof value !== 'string') {
86
+ errors.push(`Parameter [${paramName}] must be a string.`);
87
+ continue;
88
+ }
89
+
90
+ // Length validation for strings
91
+ if (rules.minLength !== undefined && value.length < rules.minLength) {
92
+ errors.push(`Parameter [${paramName}] must be at least ${rules.minLength} characters.`);
93
+ }
94
+ if (rules.maxLength !== undefined && value.length > rules.maxLength) {
95
+ errors.push(`Parameter [${paramName}] must be at most ${rules.maxLength} characters.`);
96
+ }
97
+
98
+ // Format validation
99
+ if (rules.format) {
100
+ const formatPatterns = {
101
+ 'email': /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
102
+ 'url': /^https?:\/\/.+/i,
103
+ 'ip': /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/,
104
+ 'date': /^\d{4}-\d{2}-\d{2}$/,
105
+ 'hexColor': /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/
106
+ };
107
+
108
+ if (formatPatterns[rules.format] && !formatPatterns[rules.format].test(value)) {
109
+ errors.push(`Parameter [${paramName}] must be a valid ${rules.format}.`);
110
+ }
111
+ }
112
+ } else if (rules.type === 'boolean') {
113
+ if (typeof value !== 'boolean' && value !== 'true' && value !== 'false') {
114
+ errors.push(`Parameter [${paramName}] must be a boolean.`);
115
+ }
116
+ } else if (rules.type === 'array') {
117
+ if (!Array.isArray(value)) {
118
+ errors.push(`Parameter [${paramName}] must be an array.`);
119
+ }
120
+ }
121
+
122
+ // Enum validation
123
+ if (rules.enum && Array.isArray(rules.enum)) {
124
+ if (!rules.enum.includes(value)) {
125
+ errors.push(`Parameter [${paramName}] must be one of: ${rules.enum.join(', ')}.`);
126
+ }
127
+ }
128
+ }
129
+
130
+ if (errors.length > 0) {
131
+ throw new Error(`Validation failed: ${errors.join(' ')} See documentation: https://docs.apiverve.com/ref/minimumwage`);
132
+ }
133
+ }
134
+
135
+ async execute(query, callback) {
136
+ // Handle different argument patterns
137
+ if(arguments.length === 0) {
138
+ // execute() - no args
139
+ query = {};
140
+ callback = null;
141
+ } else if(arguments.length === 1) {
142
+ if (typeof query === 'function') {
143
+ // execute(callback)
144
+ callback = query;
145
+ query = {};
146
+ } else {
147
+ // execute(query)
148
+ callback = null;
149
+ }
150
+ } else {
151
+ // execute(query, callback)
152
+ if (!query || typeof query !== 'object') {
153
+ throw new Error('Query parameters must be provided as an object.');
154
+ }
155
+ }
156
+
157
+ // Validate parameters against schema rules
158
+ this.validateParams(query);
159
+
160
+ const method = 'GET';
161
+ const url = method === 'POST' ? this.baseURL : this.constructURL(query);
162
+
163
+ try {
164
+ const response = await axios({
165
+ method,
166
+ url,
167
+ headers: {
168
+ 'Content-Type': 'application/json',
169
+ 'x-api-key': this.APIKey,
170
+ 'auth-mode': 'npm-package'
171
+ },
172
+ data: method === 'POST' ? query : undefined
173
+ });
174
+
175
+ const data = response.data;
176
+ if (callback) callback(null, data);
177
+ return data;
178
+ } catch (error) {
179
+ let apiError;
180
+
181
+ if (error.response && error.response.data) {
182
+ apiError = error.response.data;
183
+ } else if (error.message) {
184
+ apiError = { error: error.message, status: 'error' };
185
+ } else {
186
+ apiError = { error: 'An unknown error occurred', status: 'error' };
187
+ }
188
+
189
+ if (callback) {
190
+ callback(apiError, null);
191
+ return; // Don't throw if callback is provided
192
+ }
193
+
194
+ throw apiError;
195
+ }
196
+ }
197
+
198
+ constructURL(query) {
199
+ let url = this.baseURL;
200
+
201
+ if(query && typeof query === 'object')
202
+ {
203
+ if (Object.keys(query).length > 0) {
204
+ const queryString = Object.keys(query)
205
+ .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`)
206
+ .join('&');
207
+ url += `?${queryString}`;
208
+ }
209
+ }
210
+ return url;
211
+ }
212
+
213
+ }
214
+
215
+ module.exports = minimumwageWrapper;
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@apiverve/minimumwage",
3
+ "version": "1.1.13",
4
+ "description": "Minimum Wage provides current minimum wage rates for all US states plus the federal minimum. Includes tipped minimum wages, effective rates (higher of state or federal), and historical federal minimum wage data.",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "sideEffects": false,
8
+ "engines": {
9
+ "node": ">=14.0.0"
10
+ },
11
+ "files": [
12
+ "index.js",
13
+ "index.d.ts",
14
+ "LICENSE"
15
+ ],
16
+ "scripts": {
17
+ "test": "mocha",
18
+ "example": "node examples/basic.js"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/apiverve/minimumwage-api.git",
23
+ "directory": "npm"
24
+ },
25
+ "keywords": [
26
+ ""
27
+ ],
28
+ "author": {
29
+ "name": "APIVerve",
30
+ "email": "hello@apiverve.com",
31
+ "url": "https://apiverve.com"
32
+ },
33
+ "license": "MIT",
34
+ "bugs": {
35
+ "url": "https://github.com/apiverve/minimumwage-api/issues"
36
+ },
37
+ "homepage": "https://apiverve.com/marketplace/minimumwage?utm_source=npm&utm_medium=homepage",
38
+ "devDependencies": {
39
+ "mocha": "^11.0.1",
40
+ "chai": "^5.1.2",
41
+ "dotenv": "^16.4.7"
42
+ },
43
+ "dependencies": {
44
+ "node-fetch": "^3.3.2",
45
+ "promise": "^8.3.0",
46
+ "axios": "1.13.2"
47
+ }
48
+ }