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.
fastify-influxdb
Advanced tools
Readme
npm i fastify-influxdb -s
const fastify = require("fastify")();
// Should be first declaration
fastify.register(require("fastify-influxdb"), {
host: "localhost",
database: "NOAA_water_database",
schema: [
{
measurement: "average_temperature",
fields: {
"level description": "STRING",
water_level: "FLOAT"
},
tags: ["location"]
},
{
measurement: "h2o_pH",
fields: {
"level description": "STRING",
water_level: "FLOAT"
},
tags: ["location"]
},
{
measurement: "h2o_quality",
fields: {
"level description": "STRING",
water_level: "FLOAT"
},
tags: ["location"]
},
{
measurement: "h2o_temperature",
fields: {
"level description": "STRING",
water_level: "FLOAT"
},
tags: ["location"]
}
]
});
fastify.get("/", async (request, reply) => {
const { instance } = fastify.influxdb;
await instance.writePoints([
{
measurement: "h2o_temperature",
tags: { location: "athens" },
fields: { "level description": "Medium", water_level: 2.4324 }
}
]);
reply.send({
rows: await instance.query(`
select * from h2o_temperature
where location = ${fastify.influxdb.escape.stringLit(
"athens"
)}
order by time desc
limit 10
`)
});
});
This plugin adds an InfluxDB driver made available to all routes via the decorate
function. It should be used whenever an InfluxDB instance needs to communicate with a Fastify API instance.
Option | Description |
---|---|
host | Optional, the host to connect to. Defaults to localhost |
hosts | Optional, the multiple hosts to connect to. If specified, multi-cluster setup will be passed on to influx |
database | Optional, the database to connect to. If the database does not exist, the library will create it. |
schema | Optional, the schema of the database we are connecting to |
username | Optional, the username to use for authorization if any |
password | Optional, the password to use for authorization if any |
Any schemas declared should follow the following format:
{
measurement: "name_of_measurement",
fields: {
"level description": "STRING",
water_level: "FLOAT"
},
tags: ["location"]
}
The above schema should be created according to the InfluxDB Node.JS Library Schema Specification.
One should note that instead of Influx.FieldType.TYPE
and FieldType.TYPE
he/she should specify the TYPE
in string format instead. For example, the default schema presented in the above documentation link can be converted as follows:
// Before
{
measurement: 'perf',
tags: ['hostname'],
fields: {
memory_usage: FieldType.INTEGER,
cpu_usage: FieldType.FLOAT,
is_online: FieldType.BOOLEAN,
}
}
// After
{
measurement: 'perf',
tags: ['hostname'],
fields: {
memory_usage: 'INTEGER',
cpu_usage: 'FLOAT',
is_online: 'BOOLEAN',
}
}
The Influx
object of the influx
npm package is also provided by default in the decorator while the InfluxDB instance can be accessed via fastify.influxdb.instance
.
Licensed under GPLv3.
FAQs
A Fastify plugin for injecting an InfluxDB instance on the framework
The npm package fastify-influxdb receives a total of 3 weekly downloads. As such, fastify-influxdb popularity was classified as not popular.
We found that fastify-influxdb demonstrated a not healthy version release cadence and project activity because the last version was released 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.