1.0.5 • Published 9 months ago

data-knight v1.0.5

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
9 months ago

API Shield

Setup

Before using the package, you need to make the following setup in the app.js file :

Shield setup

const ShieldV2 = require("data-knight/shieldV2");
ShieldV2.setRoutes(routes); // routes => Routes settings
ShieldV2.setProjectInfo(configAPI); // configAPI => Project info

Secrets setup

const secrets = require("data-knight/secrets");
secrets.setProjectInfo(configAPI); // configAPI => Project info

Generators setup

const generators = require("data-knight/generators");
generators.setProjectInfo(configAPI); // configAPI => Project info

Generators setup

const generators = require("data-knight/generators");
generators.setProjectInfo(configAPI); // configAPI => Project info

Generators setup

const dbConfig = require("data-knight/db/dbConfig");
dbConfig.setProjectInfo(configAPI); // configAPI => Project info

Generators setup

const axiosFunctions = require("data-knight/axiosFunctions");
axiosFunctions.setProjectInfo(configAPI); // configAPI => Project info
axiosFunctions.setBaseURLs(baseURL); // Project URLs

Usage

utilities

const utilities = require("data-knight/utilities");

Usage of the runProcess function

const express = require("express");
const app = express();
app.get("/<route-name>", async (req, res) => {
  await utilities.runProcess(req, res, functionName);
});

DB

const db = require("data-knight/db/db");
let modelName = await db.modelName.functionName(...parameters...);

logsConstants

const logsConstants = require("data-knight/logsConstants");
let action = logsConstants.actions.get // For "GET" action
let object = logsConstants.objects.modelName 

ems

let errorMessage = ems.prescriberNotFound // For prescribers' functions