1.0.0 • Published 3 years ago

exclusion-list v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Exclusion list

Installation:

npm i exclusion-list

Setup:

In the root directory of your project you need to create two empty files, exclusionList.json and exclusionListConnection.json. After that you can import the library into your code and it will work properly:

import ExclusionService from "exclusion-list";

Methods:

createDatabaseConnection: Save the database credentials in the exclusionListConnection file.

const { host, port, username, password, database } = req.body;
try {
  await ExclusionService.createDatabaseConnection(
    host,
    port,
    username,
    password,
    database
  );
  return res.json({
    status: 1,
  });
} catch (error) {
  return res.json({
    status: 0,
    error: error.message,
  });
}

getDatabaseConfig: Return the database credentials that were stored in the exclusionListConnection file.

try {
  const databaseConfig = await ExclusionService.getDatabaseConfig();
  return res.json({
    status: 1,
    databaseConfig,
  });
} catch (error) {
  return res.json({
    status: 0,
    error: error.message,
  });
}

getList: Return the data stored in the exclusionList file.

const exclusionList = await ExclusionService.getList("exclusionList.json");
return res.json({
  status: 1,
  exclusionList,
});

addTable: Update the exclusionList file with a new table.

const { tableName } = req.body;

try {
  const exclusionList = await ExclusionService.addTable(
    "exclusionList.json",
    tableName
  );
  return res.json({
    status: 1,
    exclusionList,
  });
} catch (error) {
  return res.json({
    status: 0,
    error: error.message,
  });
}

deleteTable: Deletes a table that is registered in the exclusionList file.

const { tableName } = req.body;

try {
  const exclusionList = await ExclusionService.deleteTable(
    "exclusionList.json",
    tableName
  );

  return res.json({
    status: 1,
    exclusionList,
  });
} catch (error) {
  return res.json({
    status: 0,
    error: error.message,
  });
}

updateList: Update the data stored in the exclusionList file with a new identifier for a table.

const { newIdentifier, tableName } = req.body;

try {
  const exclusionList = await ExclusionService.updateList(
    "exclusionList.json",
    newIdentifier,
    tableName
  );
  return res.json({
    status: 1,
    exclusionList,
  });
} catch (error) {
  return res.json({
    status: 0,
    error: error.message,
  });
}

deleteID: Delete a identifier that is stored in the exclusionList file.

const { identifier, tableName } = req.body;

try {
  const exclusionList = await ExclusionService.deleteID(
    "exclusionList.json",
    identifier,
    tableName
  );

  return res.json({
    status: 1,
    exclusionList,
  });
} catch (error) {
  return res.json({
    status: 0,
    error: error.message,
  });
}