Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
open-weather-image
Advanced tools
Readme
open-weather-image is a image creation (base64 or buffer (png format)) to show current weather data of a provided area
Forecast data is loaded from OpenWeather API
The theme changes if it's daytime or nighttime as shown below
Or alternatively you can include it with a forecast
Optionally if you don't like the default colours, you can customise the theme (Only with solid colours, all arguments are optional, gradients will be added in future version)
npm:
npm install open-weather-image
bun:
bun add open-weather-image
First you will need to register and account on OpenWeather to obtain an API key
Recommended to put your API key as an environment variable.
You can output with a buffer or base64 string.
Default: "buffer"
Base 64:
import { createWeatherImage } from 'open-weather-image';
const image = await createWeatherImageToday({
key: process.env.WEATHER_API_KEY,
cityName: 'Munich',
output: 'base64',
});
Buffer:
import { createWeatherImage } from 'open-weather-image';
const image = await createWeatherImageToday({
key: process.env.WEATHER_API_KEY,
cityName: 'Munich',
output: 'buffer',
});
import { createWeatherImage } from 'open-weather-image';
const image = await createWeatherImageToday({
key: process.env.WEATHER_API_KEY,
cityName: 'Munich',
units: 'metric',
});
Omitting the
units
property will use the preferred temperature unit of the target country.
import { createWeatherImage } from 'open-weather-image';
const image = await createWeatherImageToday({
key: process.env.WEATHER_API_KEY,
cityName: 'Springfield',
stateCode: 'OR',
countryCode: 'US',
units: 'imperial',
});
import { createWeatherImage } from 'open-weather-image';
const image = await createWeatherImage({
key: process.env.WEATHER_API_KEY,
cityName: 'Munich',
withForecast: true,
});
Currently only English and German is supported, and tested with, feel free to contribute with other langauges within the i18n.ts file.
Default: "en"
import { createWeatherImage } from "open-weather-image"
const image = await createWeatherImage({
key: process.env.WEATHER_API_KEY,
cityName: 'Munich',
withForecast: true,
locale: "de",
});
af - Afrikaans
al - Albanian
ar - Arabic
az - Azerbaijani
bg - Bulgarian
ca - Catalan
cz - Czech
da - Danish
de - German (Full Support)
el - Greek
en - English (Full Support)
eu - Basque
fa - Persian (Farsi)
fi - Finnish
fr - French
gl - Galician
he - Hebrew
hi - Hindi
hr - Croatian
hu - Hungarian
id - Indonesian
it - Italian
ja - Japanese
kr - Korean
la - Latvian
lt - Lithuanian
mk - Macedonian
no - Norwegian
nl - Dutch
pl - Polish
pt - Portuguese
pt_br - Português Brasil
ro - Romanian
ru - Russian
sv, se - Swedish
sk - Slovak
sl - Slovenian
sp, es - Spanish
sr - Serbian
th - Thai
tr - Turkish
ua, uk - Ukrainian
vi - Vietnamese
zh_cn - Chinese Simplified
zh_tw - Chinese Traditional
zu - Zulu
import { createWeatherImage } from 'open-weather-image';
const myTheme = {
dayThemeRight: '#373CC4',
forecastBgTheme: '#242424',
forecastBoxDivider: '#FFFFFF',
dayThemeText: '#FF00FF',
dayThemeSymbol: '#00FF00',
};
const image = await createWeatherImage({
key: process.env.WEATHER_API_KEY,
cityName: 'Munich',
withForecast: true,
theme: myTheme,
});
Importing the theme type in TypeScript
import type { Theme } from 'open-weather-image';
Default Theme
const defaultTheme = {
dayThemeLeft: '#FFD982',
dayThemeRight: '#5ECEF6',
dayThemeText: 'black', // #000000
dayThemeSymbol: 'black',
nightThemeLeft: '#25395C',
nightThemeRight: '#1C2A4F',
nightThemeText: 'white', // #FFFFFF
nightThemeSymbol: 'white',
forecastBgTheme: '#DDDDDD',
forecastBoxTheme: '#EEEEEE',
forecastText: 'black',
forecastSymbolColour: 'black',
forecastBoxDivider: 'black',
};
Before creating an issue, please ensure that it hasn't already been reported/suggested.
You are free to submit a PR to this repo, please fork first, please only communicate in English or German.
open-weather-image is available under the MIT license. See the LICENSE.md file for more info.
Copyright © 2022-2024 Kira Kitsune https://kirakitsune.com, All rights reserved.
FAQs
A npm package to create images (base64 png) from the open weather API
The npm package open-weather-image receives a total of 0 weekly downloads. As such, open-weather-image popularity was classified as not popular.
We found that open-weather-image demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.