NodeJS Library is Here 🚀

NodeJS Library is Here 🚀

Are you looking for an easy and powerful way to receive notifications from your own NodeJS projects? In this article, we'll show you how to get started using the library in your projects.

The NotifyLog library is a simple and flexible tool for sending notifications through the NotifyLog API. With just a few lines of code, you can receive notifications on your account and receive insights from your app.

So let's get started! In this article, we'll walk you through the steps for installing and using the NotifyLog library in your project.

Installation

To use the NotifyLog library in your Express API, you need to install it first. Run the following command to install the library:

npm install notifylog express

Usage

After installing the library, you can use it to send notifications in your Express API. To do so, follow these steps:

1. Import the NotifyLog class and create an instance with your API key:

import express from "express";
import { NotifyLog } from "notifylog";

const app = express();
const notifyLog = new NotifyLog("YOUR_API_KEY");

OBS: You can get your API key on NotifyLog -> Settings -> API.

2. Define a route that sends a notification using the publish method of the NotifyLog class:

app.post("/users", (req, res) => {
  const user = req.body;
  // Save the user to the database
  // ...

  // Send a notification
  notifyLog.publish({
    name: "New user",
    description: `${user.name} just signed up`,
    channel: "users",
    icon: "👤",
    notify: true,
  });

  res.send("User created successfully");
});

3. Now start your server:

app.listen(3333, () => {
  console.log('Listening on port 3333');
})

4. Start your project and make the request on route /users with correct params and receive notifications.

And more useful features

You can also customize the notification by adding optional parameters to the publish method. For example, you can add tags to the notification using the tags parameter:

notifyLog.publish({
  name: "New user",
  description: `${user.name} just signed up`,
  channel: "users",
  icon: "👤",
  notify: true,
  tags: {
    "user-id": user.id,
    "user-name": user.name,
  },
});

You can also include a message written in Markdown using the message parameter:

notifyLog.publish({
  name: "New user",
  description: `${user.name} just signed up`,
  channel: "users",
  icon: "👤",
  notify: true,
  tags: {
    "user-id": user.id,
    "user-name": user.name,
  },
  message: `[See more on Admin](http://myapp.com/welcome)`,
});

In conclusion, the NotifyLog library is a powerful and easy-to-use tool for sending notifications through the NotifyLog API. With its simple API and customizable options, it's a great choice for any project that needs to send notifications.

If you're interested in trying out the NotifyLog library, we're currently offering a free beta test. Simply sign up at https://notifylog.com/ and you'll be able to test out the library and give us your feedback.

Thank you for reading this article. We hope you found it helpful and that you'll give the NotifyLog library a try in your own projects. Happy coding!