weatherqwq 1.0.0

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.
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # WeatherQWQ Node.js SDK
2
+
3
+ Free and unlimited weather data API client.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install weatherqwq
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { WeatherClient } from 'weatherqwq'
15
+
16
+ const client = new WeatherClient({ apiKey: 'qwq-...' })
17
+
18
+ // Current weather
19
+ const current = await client.currentWeather({ lat: 40.71, lon: -74.01 })
20
+
21
+ // 7-day forecast
22
+ const forecast = await client.forecast({ lat: 40.71, lon: -74.01, days: 7 })
23
+
24
+ // Historical data
25
+ const historical = await client.historical({
26
+ lat: 40.71, lon: -74.01,
27
+ startDate: '2024-01-01',
28
+ endDate: '2024-01-07'
29
+ })
30
+
31
+ // Air quality
32
+ const aq = await client.airQuality({ lat: 40.71, lon: -74.01 })
33
+
34
+ // Weather alerts
35
+ const alerts = await client.alerts({ lat: 40.71, lon: -74.01 })
36
+ ```
37
+
38
+ ## License
39
+
40
+ MIT
@@ -0,0 +1,27 @@
1
+ export interface WeatherOptions {
2
+ apiKey: string;
3
+ baseUrl?: string;
4
+ }
5
+ export interface LatLon {
6
+ lat: number;
7
+ lon: number;
8
+ }
9
+ export interface ForecastOptions extends LatLon {
10
+ days?: number;
11
+ }
12
+ export interface HistoricalOptions extends LatLon {
13
+ startDate: string;
14
+ endDate: string;
15
+ }
16
+ export declare class WeatherClient {
17
+ private apiKey;
18
+ private baseUrl;
19
+ constructor(options: WeatherOptions);
20
+ private get;
21
+ currentWeather(options: LatLon): Promise<any>;
22
+ forecast(options: ForecastOptions): Promise<any>;
23
+ historical(options: HistoricalOptions): Promise<any>;
24
+ airQuality(options: LatLon): Promise<any>;
25
+ alerts(options: LatLon): Promise<any>;
26
+ }
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,eAAgB,SAAQ,MAAM;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,iBAAkB,SAAQ,MAAM;IAC/C,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAQ;gBAEX,OAAO,EAAE,cAAc;YAKrB,GAAG;IAqBX,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAI7C,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC;IAQhD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC;IASpD,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAIzC,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;CAG5C"}
package/dist/index.js ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WeatherClient = void 0;
4
+ class WeatherClient {
5
+ apiKey;
6
+ baseUrl;
7
+ constructor(options) {
8
+ this.apiKey = options.apiKey;
9
+ this.baseUrl = (options.baseUrl ?? 'https://weatherqwq-api.onrender.com').replace(/\/+$/, '');
10
+ }
11
+ async get(path, params) {
12
+ const url = new URL(`${this.baseUrl}${path}`);
13
+ if (params) {
14
+ for (const [key, value] of Object.entries(params)) {
15
+ url.searchParams.set(key, String(value));
16
+ }
17
+ }
18
+ const resp = await fetch(url.toString(), {
19
+ headers: {
20
+ Authorization: `Bearer ${this.apiKey}`,
21
+ 'Content-Type': 'application/json',
22
+ },
23
+ });
24
+ if (!resp.ok) {
25
+ const err = await resp.json().catch(() => ({ error: resp.statusText }));
26
+ throw new Error(err.error);
27
+ }
28
+ const json = await resp.json();
29
+ return json.data;
30
+ }
31
+ async currentWeather(options) {
32
+ return this.get('/v1/weather/current', { lat: options.lat, lon: options.lon });
33
+ }
34
+ async forecast(options) {
35
+ return this.get('/v1/weather/forecast', {
36
+ lat: options.lat,
37
+ lon: options.lon,
38
+ days: options.days ?? 7,
39
+ });
40
+ }
41
+ async historical(options) {
42
+ return this.get('/v1/weather/historical', {
43
+ lat: options.lat,
44
+ lon: options.lon,
45
+ start_date: options.startDate,
46
+ end_date: options.endDate,
47
+ });
48
+ }
49
+ async airQuality(options) {
50
+ return this.get('/v1/weather/air-quality', { lat: options.lat, lon: options.lon });
51
+ }
52
+ async alerts(options) {
53
+ return this.get('/v1/weather/alerts', { lat: options.lat, lon: options.lon });
54
+ }
55
+ }
56
+ exports.WeatherClient = WeatherClient;
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAmBA,MAAa,aAAa;IAChB,MAAM,CAAQ;IACd,OAAO,CAAQ;IAEvB,YAAY,OAAuB;QACjC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,qCAAqC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAC/F,CAAC;IAEO,KAAK,CAAC,GAAG,CAAC,IAAY,EAAE,MAAmC;QACjE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GA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EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;SACxB,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAA0B;QACzC,OAAO,IAAI,CAAC,GAAG,CAAC,wBAAwB,EAAE;YACxC,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,UAAU,EAAE,OAAO,CAAC,SAAS;YAC7B,QAAQ,EAAE,OAAO,CAAC,OAAO;SAC1B,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAe;QAC9B,OAAO,IAAI,CAAC,GAAG,CAAC,yBAAyB,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;IACpF,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAe;QAC1B,OAAO,IAAI,CAAC,GAAG,CAAC,oBAAoB,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;IAC/E,CAAC;CACF;AA1DD,sCA0DC"}
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "weatherqwq",
3
+ "version": "1.0.0",
4
+ "description": "Free and unlimited weather data API client",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": ["dist"],
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "prepublishOnly": "npm run build"
11
+ },
12
+ "keywords": ["weather", "api", "weatherqwq"],
13
+ "license": "MIT",
14
+ "devDependencies": {
15
+ "typescript": "^5.0.0"
16
+ }
17
+ }