kschema-fs-api-gen-post-actions 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +323 -0
- package/bin/cli.js +12 -0
- package/bin/core/getLatestVersion.js +13 -0
- package/bin/core/loadRunner.js +9 -0
- package/bin/v5/core/createFolder.js +34 -0
- package/bin/v5/core/parseInput.js +9 -0
- package/bin/v5/core/resolveCommand.js +11 -0
- package/bin/v5/core/showUsage.js +49 -0
- package/bin/v5/start.js +22 -0
- package/bin/v5/tasks/actions/WithMail/actions.json +26 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/common/readFile.js +8 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/common/writeFile.js +10 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/updateImports/index.js +47 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/updateUse/buildUseLine.js +5 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +9 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v5/tasks/actions/WithMail/steps/UpdateRoutesJs/updateUse/index.js +56 -0
- package/bin/v5/tasks/actions/WithMail/steps/announce.js +9 -0
- package/bin/v5/tasks/actions/WithMail/steps/createFolder.js +7 -0
- package/bin/v5/tasks/actions/WithMail/steps/createHttpFile.js +12 -0
- package/bin/v5/tasks/actions/WithMail/steps/decideTemplate.js +3 -0
- package/bin/v5/tasks/actions/WithMail/steps/locateDestination.js +7 -0
- package/bin/v5/tasks/actions/WithMail/steps/locateSource.js +18 -0
- package/bin/v5/tasks/actions/WithMail/steps/resolveFolderName.js +20 -0
- package/bin/v5/tasks/actions/WithMail/steps/updateAppJs.js +7 -0
- package/bin/v5/tasks/actions/WithMail/steps/updateEndPointsFile.js +30 -0
- package/bin/v5/tasks/actions/WithMail/steps/updateEndPointsJs.js +16 -0
- package/bin/v5/tasks/actions/WithMail/template/v1/controller.js +28 -0
- package/bin/v5/tasks/actions/WithMail/template/v1/errors.js +11 -0
- package/bin/v5/tasks/actions/WithMail/template/v1/middleware.js +19 -0
- package/bin/v5/tasks/actions/WithMail/template/v1/service.js +44 -0
- package/bin/v5/tasks/actions/WithMail/template/v2/Mail/sendMailCC.js +45 -0
- package/bin/v5/tasks/actions/WithMail/template/v2/Mail/welcome.html +213 -0
- package/bin/v5/tasks/actions/WithMail/template/v2/controller.js +24 -0
- package/bin/v5/tasks/actions/WithMail/template/v2/errors.js +11 -0
- package/bin/v5/tasks/actions/WithMail/template/v2/middleware.js +19 -0
- package/bin/v5/tasks/actions/WithMail/template/v2/rest.http +7 -0
- package/bin/v5/tasks/actions/WithMail/template/v2/service.js +18 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/Mail/sendMailCC.js +45 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/Mail/welcome.html +213 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/config/getSchema.js +20 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/controller.js +27 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/errors.js +11 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/getData.js +11 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/getSchema.js +11 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/buildMutate.js +32 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/buildQuery.js +32 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/file/read.js +7 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/file/write.js +5 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/pkHelper.js +19 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validate.js +27 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validateHelper.js +27 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validators/default.js +5 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validators/enum.js +7 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validators/length.js +11 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validators/minMax.js +11 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validators/pattern.js +8 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validators/required.js +5 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validators/type.js +15 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/helpers/validators/unique.js +8 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/insertBase.js +9 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/insertGenPk.js +31 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/middleware.js +19 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/rest.http +7 -0
- package/bin/v5/tasks/actions/WithMail/template/v3/service.js +16 -0
- package/bin/v5/tasks/actions/withMail.js +60 -0
- package/bin/v5/tasks/core/createFolder.js +34 -0
- package/bin/v5/tasks/core/parseInput.js +12 -0
- package/bin/v5/tasks/core/resolveCommand.js +24 -0
- package/bin/v5/tasks/core/showUsage.js +43 -0
- package/bin/v6/core/createFolder.js +34 -0
- package/bin/v6/core/parseInput.js +9 -0
- package/bin/v6/core/resolveCommand.js +11 -0
- package/bin/v6/core/showUsage.js +49 -0
- package/bin/v6/start.js +22 -0
- package/bin/v6/tasks/actions/InsertGenPk/actions.json +26 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/common/readFile.js +8 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/common/writeFile.js +10 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/updateImports/index.js +47 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/updateUse/buildUseLine.js +5 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +9 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/UpdateRoutesJs/updateUse/index.js +56 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/announce.js +9 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/createFolder.js +7 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/createHttpFile.js +12 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/decideTemplate.js +3 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/locateDestination.js +7 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/locateSource.js +18 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/resolveFolderName.js +20 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/updateAppJs.js +7 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/updateEndPointsFile.js +30 -0
- package/bin/v6/tasks/actions/InsertGenPk/steps/updateEndPointsJs.js +16 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/config/getSchema.js +20 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/controller.js +27 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/errors.js +11 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/getData.js +11 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/getSchema.js +11 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/buildMutate.js +32 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/buildQuery.js +32 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/file/read.js +7 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/file/write.js +5 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/pkHelper.js +19 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validate.js +27 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validateHelper.js +27 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validators/default.js +5 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validators/enum.js +7 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validators/length.js +11 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validators/minMax.js +11 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validators/pattern.js +8 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validators/required.js +5 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validators/type.js +15 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/helpers/validators/unique.js +8 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/insertBase.js +9 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/insertGenPk.js +31 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/middleware.js +19 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/rest.http +7 -0
- package/bin/v6/tasks/actions/InsertGenPk/template/v1/service.js +16 -0
- package/bin/v6/tasks/actions/WithMail/actions.json +26 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/common/readFile.js +8 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/common/writeFile.js +10 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/updateImports/index.js +47 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/updateUse/buildUseLine.js +5 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +9 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
- package/bin/v6/tasks/actions/WithMail/steps/UpdateRoutesJs/updateUse/index.js +56 -0
- package/bin/v6/tasks/actions/WithMail/steps/announce.js +9 -0
- package/bin/v6/tasks/actions/WithMail/steps/createFolder.js +7 -0
- package/bin/v6/tasks/actions/WithMail/steps/createHttpFile.js +12 -0
- package/bin/v6/tasks/actions/WithMail/steps/decideTemplate.js +3 -0
- package/bin/v6/tasks/actions/WithMail/steps/locateDestination.js +7 -0
- package/bin/v6/tasks/actions/WithMail/steps/locateSource.js +18 -0
- package/bin/v6/tasks/actions/WithMail/steps/resolveFolderName.js +20 -0
- package/bin/v6/tasks/actions/WithMail/steps/updateAppJs.js +7 -0
- package/bin/v6/tasks/actions/WithMail/steps/updateEndPointsFile.js +30 -0
- package/bin/v6/tasks/actions/WithMail/steps/updateEndPointsJs.js +16 -0
- package/bin/v6/tasks/actions/WithMail/template/v1/controller.js +28 -0
- package/bin/v6/tasks/actions/WithMail/template/v1/errors.js +11 -0
- package/bin/v6/tasks/actions/WithMail/template/v1/middleware.js +19 -0
- package/bin/v6/tasks/actions/WithMail/template/v1/service.js +44 -0
- package/bin/v6/tasks/actions/WithMail/template/v2/Mail/sendMailCC.js +45 -0
- package/bin/v6/tasks/actions/WithMail/template/v2/Mail/welcome.html +213 -0
- package/bin/v6/tasks/actions/WithMail/template/v2/controller.js +24 -0
- package/bin/v6/tasks/actions/WithMail/template/v2/errors.js +11 -0
- package/bin/v6/tasks/actions/WithMail/template/v2/middleware.js +19 -0
- package/bin/v6/tasks/actions/WithMail/template/v2/rest.http +7 -0
- package/bin/v6/tasks/actions/WithMail/template/v2/service.js +18 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/Mail/sendMailCC.js +45 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/Mail/welcome.html +213 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/config/getSchema.js +20 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/controller.js +27 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/errors.js +11 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/getData.js +11 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/getSchema.js +11 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/buildMutate.js +32 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/buildQuery.js +32 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/file/read.js +7 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/file/write.js +5 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/pkHelper.js +19 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validate.js +27 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validateHelper.js +27 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validators/default.js +5 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validators/enum.js +7 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validators/length.js +11 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validators/minMax.js +11 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validators/pattern.js +8 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validators/required.js +5 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validators/type.js +15 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/helpers/validators/unique.js +8 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/insertBase.js +9 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/insertGenPk.js +31 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/middleware.js +19 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/rest.http +7 -0
- package/bin/v6/tasks/actions/WithMail/template/v3/service.js +16 -0
- package/bin/v6/tasks/actions/insertGenPk.js +68 -0
- package/bin/v6/tasks/actions/withMail.js +60 -0
- package/bin/v6/tasks/core/createFolder.js +34 -0
- package/bin/v6/tasks/core/parseInput.js +12 -0
- package/bin/v6/tasks/core/resolveCommand.js +24 -0
- package/bin/v6/tasks/core/showUsage.js +43 -0
- package/index.js +34 -0
- package/package.json +37 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
const createHttpFile = ({ inTargetPath, toPath }) => {
|
|
5
|
+
const relative = inTargetPath.replace(toPath, "").replace(/\\/g, "/");
|
|
6
|
+
|
|
7
|
+
const content = `GET http://localhost:3000${relative}`;
|
|
8
|
+
|
|
9
|
+
fs.writeFileSync(path.join(inTargetPath, "rest.http"), content);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default createHttpFile;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
7
|
+
|
|
8
|
+
export const locateSource = () => {
|
|
9
|
+
const templatePath = path.join(__dirname, "..", "template");
|
|
10
|
+
|
|
11
|
+
const versions = fs.readdirSync(templatePath);
|
|
12
|
+
|
|
13
|
+
const maxVersion = Math.max(
|
|
14
|
+
...versions.map(v => Number(v.replace("v", "")))
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
return path.join(templatePath, `v${maxVersion}`);
|
|
18
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
export default function resolveFolderName({ name, inDefaultFolderName = "WithMail" }) {
|
|
4
|
+
const defaultFolderName = inDefaultFolderName;
|
|
5
|
+
|
|
6
|
+
// case 1: force new → timestamp
|
|
7
|
+
if (name === null) {
|
|
8
|
+
name = defaultFolderName;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// case 2: user provided → strict
|
|
12
|
+
if (fs.existsSync(name)) {
|
|
13
|
+
return {
|
|
14
|
+
KTF: false,
|
|
15
|
+
KReason: `Folder already exists : ${name}`
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return name;
|
|
20
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import updateImports from "./UpdateRoutesJs/updateImports/index.js";
|
|
2
|
+
import updateAppUse from "./UpdateRoutesJs/updateUse/index.js";
|
|
3
|
+
|
|
4
|
+
export default ({ appJsPath, endpoint }) => {
|
|
5
|
+
updateImports({ appJsPath, endpoint });
|
|
6
|
+
updateAppUse({ appJsPath, endpoint });
|
|
7
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
|
|
3
|
+
function updateEndPointsFile({ filePath, inTableName }) {
|
|
4
|
+
try {
|
|
5
|
+
let content = readFile(filePath);
|
|
6
|
+
|
|
7
|
+
content = content.replace("<TABLE_NAME>", inTableName);
|
|
8
|
+
|
|
9
|
+
writeFile(filePath, content);
|
|
10
|
+
} catch (e) {
|
|
11
|
+
handleError(e);
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// read
|
|
16
|
+
function readFile(filePath) {
|
|
17
|
+
return fs.readFileSync(filePath, "utf-8");
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// write
|
|
21
|
+
function writeFile(filePath, content) {
|
|
22
|
+
fs.writeFileSync(filePath, content);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// error handler
|
|
26
|
+
function handleError(e) {
|
|
27
|
+
console.error("ROUTE USE ERROR:", e.message);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { updateEndPointsFile };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import updateImports from "./UpdateRoutesJs/updateImports/index.js";
|
|
2
|
+
import updateAppUse from "./UpdateRoutesJs/updateUse/index.js";
|
|
3
|
+
|
|
4
|
+
const funcName = "getFunc";
|
|
5
|
+
|
|
6
|
+
export default ({ appJsPath, endpoint }) => {
|
|
7
|
+
updateImports({
|
|
8
|
+
appJsPath, endpoint,
|
|
9
|
+
inFuncName: funcName
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
updateAppUse({
|
|
13
|
+
appJsPath, endpoint,
|
|
14
|
+
inFuncName: funcName
|
|
15
|
+
});
|
|
16
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { startFunc as Service } from "./service.js";
|
|
2
|
+
import { ConflictError, StorageError } from "./errors.js";
|
|
3
|
+
|
|
4
|
+
const postFunc = async ({ req, res, inTablePath }) => {
|
|
5
|
+
try {
|
|
6
|
+
const inRequestBody = req.body;
|
|
7
|
+
|
|
8
|
+
const fromService = await Service({ inRequestBody, inTablePath });
|
|
9
|
+
|
|
10
|
+
if (!fromService) {
|
|
11
|
+
return res.status(400).send("Validation failed");
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
res.type("text/plain").send(fromService);
|
|
15
|
+
} catch (err) {
|
|
16
|
+
|
|
17
|
+
if (err instanceof ConflictError)
|
|
18
|
+
return res.status(409).send(err.message);
|
|
19
|
+
|
|
20
|
+
if (err instanceof StorageError)
|
|
21
|
+
return res.status(500).send("Failed to persist data");
|
|
22
|
+
|
|
23
|
+
console.error(err);
|
|
24
|
+
res.status(500).send("Unexpected error");
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default postFunc;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class AppError extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = this.constructor.name;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
class ConflictError extends AppError { }
|
|
9
|
+
class StorageError extends AppError { }
|
|
10
|
+
|
|
11
|
+
export { AppError, ConflictError, StorageError };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const StartFunc = (req, res, next) => {
|
|
2
|
+
const LocalBody = req.body;
|
|
3
|
+
|
|
4
|
+
if (!LocalBody || Object.keys(LocalBody).length === 0) {
|
|
5
|
+
return res.status(400).send("Request body should not be empty.");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (Array.isArray(LocalBody)) {
|
|
9
|
+
return res.status(400).send("Remove The Array From The Body.");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (typeof LocalBody === 'object' && Object.keys(LocalBody).length === 0) {
|
|
13
|
+
return res.status(400).send("Request body should not be an empty object.");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
next();
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { StartFunc };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import Ajv from "ajv";
|
|
3
|
+
|
|
4
|
+
import { JSONFilePreset } from 'lowdb/node'
|
|
5
|
+
|
|
6
|
+
const ajv = new Ajv() // options can be passed, e.g. {allErrors: true}
|
|
7
|
+
|
|
8
|
+
const schema = {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
LedgerName: { type: "string" }
|
|
12
|
+
},
|
|
13
|
+
required: ["LedgerName"],
|
|
14
|
+
additionalProperties: true
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const startFunc = async ({ inRequestBody, inTablePath }) => {
|
|
18
|
+
return await insertData({ inTablePath, inRequestBody });
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const insertData = async ({ inTablePath, inRequestBody }) => {
|
|
22
|
+
const db = await JSONFilePreset(inTablePath, []);
|
|
23
|
+
|
|
24
|
+
await db.read();
|
|
25
|
+
|
|
26
|
+
const validate = ajv.compile(schema);
|
|
27
|
+
const valid = validate(inRequestBody)
|
|
28
|
+
// if (!valid) return false;
|
|
29
|
+
if (!valid) {
|
|
30
|
+
console.log(validate.errors);
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const maxPk = db.data.reduce((a, b) => Math.max(a, b.pk || 0), 0);
|
|
35
|
+
const newPk = maxPk + 1;
|
|
36
|
+
|
|
37
|
+
db.data.push({ ...inRequestBody, pk: newPk });
|
|
38
|
+
|
|
39
|
+
await db.write();
|
|
40
|
+
|
|
41
|
+
return await newPk;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { startFunc };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import nodemailer from "nodemailer";
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
|
|
5
|
+
dotenv.config();
|
|
6
|
+
|
|
7
|
+
let startFunc = async () => {
|
|
8
|
+
|
|
9
|
+
if ("KS_MAIL_ID" in process.env === false) {
|
|
10
|
+
console.log("KS_MAIL_ID not found in .env file");
|
|
11
|
+
return await false;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
if ("KS_MAIL_PASSWORD" in process.env === false) {
|
|
15
|
+
console.log("KS_MAIL_PASSWORD not found in .env file");
|
|
16
|
+
return await false;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
if ("KS_TO_MAIL_ID" in process.env === false) {
|
|
20
|
+
console.log("KS_TO_MAIL_ID not found in .env file");
|
|
21
|
+
return await false;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const LocalFromSendMail = jFTransporterForGoogle.sendMail({
|
|
25
|
+
from: `"KeshavSoft" ${process.env.KS_MAIL_ID}`,
|
|
26
|
+
to: `${process.env.KS_TO_MAIL_ID}`,
|
|
27
|
+
subject: `Hello ✔`,
|
|
28
|
+
text: "16",
|
|
29
|
+
html: ""
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return await LocalFromSendMail;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
let jFTransporterForGoogle = nodemailer.createTransport({
|
|
36
|
+
host: "smtp.gmail.com",
|
|
37
|
+
port: 587,
|
|
38
|
+
secure: false,
|
|
39
|
+
auth: {
|
|
40
|
+
user: process.env.KS_MAIL_ID,
|
|
41
|
+
pass: process.env.KS_MAIL_PASSWORD
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export default startFunc;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
|
|
3
|
+
<html lang="en" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml">
|
|
4
|
+
|
|
5
|
+
<head>
|
|
6
|
+
<title></title>
|
|
7
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
|
8
|
+
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
|
9
|
+
<!--[if mso]><xml><o:OfficeDocumentSettings><o:PixelsPerInch>96</o:PixelsPerInch><o:AllowPNG/></o:OfficeDocumentSettings></xml><![endif]--><!--[if !mso]><!-->
|
|
10
|
+
<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet" type="text/css" />
|
|
11
|
+
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css" /><!--<![endif]-->
|
|
12
|
+
<style>
|
|
13
|
+
* {
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
body {
|
|
18
|
+
margin: 0;
|
|
19
|
+
padding: 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
a[x-apple-data-detectors] {
|
|
23
|
+
color: inherit !important;
|
|
24
|
+
text-decoration: inherit !important;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#MessageViewBody a {
|
|
28
|
+
color: inherit;
|
|
29
|
+
text-decoration: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
p {
|
|
33
|
+
line-height: inherit
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.desktop_hide,
|
|
37
|
+
.desktop_hide table {
|
|
38
|
+
mso-hide: all;
|
|
39
|
+
display: none;
|
|
40
|
+
max-height: 0px;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.image_block img+div {
|
|
45
|
+
display: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
sup,
|
|
49
|
+
sub {
|
|
50
|
+
line-height: 0;
|
|
51
|
+
font-size: 75%;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@media (max-width:620px) {
|
|
55
|
+
|
|
56
|
+
.desktop_hide table.icons-inner,
|
|
57
|
+
.social_block.desktop_hide .social-table {
|
|
58
|
+
display: inline-block !important;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.icons-inner {
|
|
62
|
+
text-align: center;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.icons-inner td {
|
|
66
|
+
margin: 0 auto;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.image_block div.fullWidth {
|
|
70
|
+
max-width: 100% !important;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.mobile_hide {
|
|
74
|
+
display: none;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.row-content {
|
|
78
|
+
width: 100% !important;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.stack .column {
|
|
82
|
+
width: 100%;
|
|
83
|
+
display: block;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.mobile_hide {
|
|
87
|
+
min-height: 0;
|
|
88
|
+
max-height: 0;
|
|
89
|
+
max-width: 0;
|
|
90
|
+
overflow: hidden;
|
|
91
|
+
font-size: 0px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.desktop_hide,
|
|
95
|
+
.desktop_hide table {
|
|
96
|
+
display: table !important;
|
|
97
|
+
max-height: none !important;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
</style>
|
|
101
|
+
<!--[if mso ]><style>sup, sub { font-size: 100% !important; } sup { mso-text-raise:10% } sub { mso-text-raise:-10% }</style> <![endif]-->
|
|
102
|
+
</head>
|
|
103
|
+
|
|
104
|
+
<body class="body"
|
|
105
|
+
style="background-color: #FFFFFF; margin: 0; padding: 0; -webkit-text-size-adjust: none; text-size-adjust: none;">
|
|
106
|
+
<table border="0" cellpadding="0" cellspacing="0" class="nl-container" role="presentation"
|
|
107
|
+
style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #FFFFFF;" width="100%">
|
|
108
|
+
<tbody>
|
|
109
|
+
<tr>
|
|
110
|
+
<td>
|
|
111
|
+
<table border="0" cellpadding="0" cellspacing="0" class="heading_block block-2" role="presentation"
|
|
112
|
+
style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;" width="100%">
|
|
113
|
+
<tr>
|
|
114
|
+
<td class="pad"
|
|
115
|
+
style="padding-bottom:10px;padding-left:15px;padding-right:15px;padding-top:15px;text-align:center;width:100%;">
|
|
116
|
+
<h1
|
|
117
|
+
style="margin: 0; color: #2f2e41; direction: ltr; font-family: Ubuntu, Tahoma, Verdana, Segoe, sans-serif; font-size: 36px; font-weight: normal; letter-spacing: 1px; line-height: 120%; text-align: center; margin-top: 0; margin-bottom: 0; mso-line-height-alt: 43.199999999999996px;">
|
|
118
|
+
<strong>KeshavSoft welcomes you</strong>
|
|
119
|
+
</h1>
|
|
120
|
+
</td>
|
|
121
|
+
</tr>
|
|
122
|
+
</table>
|
|
123
|
+
|
|
124
|
+
<table align="center" border="0" cellpadding="0" cellspacing="0" class="row row-2"
|
|
125
|
+
role="presentation"
|
|
126
|
+
style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff;" width="100%">
|
|
127
|
+
<tbody>
|
|
128
|
+
<tr>
|
|
129
|
+
<td>
|
|
130
|
+
<table align="center" border="0" cellpadding="0" cellspacing="0"
|
|
131
|
+
class="row-content stack" role="presentation"
|
|
132
|
+
style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #000000; width: 600px; margin: 0 auto;"
|
|
133
|
+
width="600">
|
|
134
|
+
<tbody>
|
|
135
|
+
<tr>
|
|
136
|
+
<td class="column column-1"
|
|
137
|
+
style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; padding-bottom: 35px; padding-top: 25px; vertical-align: top; border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px;"
|
|
138
|
+
width="100%">
|
|
139
|
+
<table border="0" cellpadding="0" cellspacing="0"
|
|
140
|
+
class="image_block block-1" role="presentation"
|
|
141
|
+
style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;"
|
|
142
|
+
width="100%">
|
|
143
|
+
<tr>
|
|
144
|
+
<td class="pad"
|
|
145
|
+
style="padding-bottom:20px;padding-top:20px;width:100%;padding-right:0px;padding-left:0px;">
|
|
146
|
+
<div align="center" class="alignment"
|
|
147
|
+
style="line-height:10px">
|
|
148
|
+
<div class="fullWidth" style="max-width: 546px;">
|
|
149
|
+
<img alt="A world with kidness" height="auto"
|
|
150
|
+
src="https://jyothitally.keshavsoft.biz/images/Group.png"
|
|
151
|
+
style="display: block; height: auto; border: 0; width: 100%;"
|
|
152
|
+
title="A world with kidness" width="546" />
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
</td>
|
|
156
|
+
</tr>
|
|
157
|
+
</table>
|
|
158
|
+
|
|
159
|
+
<table border="0" cellpadding="0" cellspacing="0"
|
|
160
|
+
class="paragraph_block block-3" role="presentation"
|
|
161
|
+
style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;"
|
|
162
|
+
width="100%">
|
|
163
|
+
<tr>
|
|
164
|
+
<td class="pad"
|
|
165
|
+
style="padding-bottom:25px;padding-left:15px;padding-right:15px;padding-top:15px;">
|
|
166
|
+
<div
|
|
167
|
+
style="color:#39374e;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:18px;line-height:180%;text-align:center;mso-line-height-alt:32.4px;">
|
|
168
|
+
<p style="margin: 0; word-break: break-word;"><span
|
|
169
|
+
style="word-break: break-word;">For starting
|
|
170
|
+
journey with
|
|
171
|
+
<strong>KeshavSoft</strong> click the link
|
|
172
|
+
below</span></p>
|
|
173
|
+
</div>
|
|
174
|
+
</td>
|
|
175
|
+
</tr>
|
|
176
|
+
</table>
|
|
177
|
+
<table border="0" cellpadding="0" cellspacing="0"
|
|
178
|
+
class="button_block block-4" role="presentation"
|
|
179
|
+
style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;"
|
|
180
|
+
width="100%">
|
|
181
|
+
<tr>
|
|
182
|
+
<td class="pad"
|
|
183
|
+
style="padding-bottom:15px;padding-left:10px;padding-right:10px;padding-top:15px;text-align:center;">
|
|
184
|
+
<div align="center" class="alignment">
|
|
185
|
+
<a href="{{inRedirectUrl}}"
|
|
186
|
+
style="background-color:#f84c89;border-bottom:0px solid #8a3b8f;border-left:0px solid #8a3b8f;border-radius:60px;border-right:0px solid #8a3b8f;border-top:0px solid #8a3b8f;color:#ffffff;display:inline-block;font-family:Ubuntu, Tahoma, Verdana, Segoe, sans-serif;font-size:16px;font-weight:undefined;mso-border-alt:none;padding-bottom:7px;padding-top:7px;text-align:center;text-decoration:none;width:auto;word-break:keep-all;"
|
|
187
|
+
target="_blank"><span
|
|
188
|
+
style="word-break: break-word; padding-left: 40px; padding-right: 40px; font-size: 16px; display: inline-block; letter-spacing: normal;"><span
|
|
189
|
+
style="word-break: break-word;"><span
|
|
190
|
+
data-mce-style=""
|
|
191
|
+
style="word-break: break-word; line-height: 32px;"><strong>Verify
|
|
192
|
+
your
|
|
193
|
+
account</strong></span></span></span></a><!--[if mso]></center></v:textbox></v:roundrect><![endif]-->
|
|
194
|
+
</div>
|
|
195
|
+
</td>
|
|
196
|
+
</tr>
|
|
197
|
+
</table>
|
|
198
|
+
</td>
|
|
199
|
+
</tr>
|
|
200
|
+
</tbody>
|
|
201
|
+
</table>
|
|
202
|
+
</td>
|
|
203
|
+
</tr>
|
|
204
|
+
</tbody>
|
|
205
|
+
</table>
|
|
206
|
+
|
|
207
|
+
</td>
|
|
208
|
+
</tr>
|
|
209
|
+
</tbody>
|
|
210
|
+
</table><!-- End -->
|
|
211
|
+
</body>
|
|
212
|
+
|
|
213
|
+
</html>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { startFunc as Service } from "./service.js";
|
|
2
|
+
import { ConflictError, StorageError } from "./errors.js";
|
|
3
|
+
|
|
4
|
+
const postFunc = async ({ req, res, inTableName }) => {
|
|
5
|
+
try {
|
|
6
|
+
const inRequestBody = req.body;
|
|
7
|
+
|
|
8
|
+
const fromService = await Service({ inRequestBody, inTableName });
|
|
9
|
+
|
|
10
|
+
res.type("application/json").send(fromService);
|
|
11
|
+
} catch (err) {
|
|
12
|
+
|
|
13
|
+
if (err instanceof ConflictError)
|
|
14
|
+
return res.status(409).send(err.message);
|
|
15
|
+
|
|
16
|
+
if (err instanceof StorageError)
|
|
17
|
+
return res.status(500).send("Failed to persist data");
|
|
18
|
+
|
|
19
|
+
console.error(err);
|
|
20
|
+
res.status(500).send("Unexpected error");
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { postFunc };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class AppError extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = this.constructor.name;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
class ConflictError extends AppError { }
|
|
9
|
+
class StorageError extends AppError { }
|
|
10
|
+
|
|
11
|
+
export { AppError, ConflictError, StorageError };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const StartFunc = (req, res, next) => {
|
|
2
|
+
const LocalBody = req.body;
|
|
3
|
+
|
|
4
|
+
if (!LocalBody || Object.keys(LocalBody).length === 0) {
|
|
5
|
+
return res.status(400).send("Request body should not be empty.");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (Array.isArray(LocalBody)) {
|
|
9
|
+
return res.status(400).send("Remove The Array From The Body.");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (typeof LocalBody === 'object' && Object.keys(LocalBody).length === 0) {
|
|
13
|
+
return res.status(400).send("Request body should not be an empty object.");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
next();
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { StartFunc };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { kschema } from "@keshavsoft/kschema";
|
|
2
|
+
import sendMail from "./Mail/sendMailCC.js";
|
|
3
|
+
|
|
4
|
+
const startFunc = async ({ inRequestBody, inTableName }) => {
|
|
5
|
+
const tableName = inTableName;
|
|
6
|
+
|
|
7
|
+
const insertedPk = await kschema.table(tableName).mutate.insertGenPk(inRequestBody);
|
|
8
|
+
|
|
9
|
+
const info = await sendMail();
|
|
10
|
+
|
|
11
|
+
return await {
|
|
12
|
+
insertedPk,
|
|
13
|
+
isMailSent: info.accepted.length > 0 &&
|
|
14
|
+
info.rejected.length === 0
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { startFunc };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import nodemailer from "nodemailer";
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
|
|
5
|
+
dotenv.config();
|
|
6
|
+
|
|
7
|
+
let startFunc = async () => {
|
|
8
|
+
|
|
9
|
+
if ("KS_MAIL_ID" in process.env === false) {
|
|
10
|
+
console.log("KS_MAIL_ID not found in .env file");
|
|
11
|
+
return await false;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
if ("KS_MAIL_PASSWORD" in process.env === false) {
|
|
15
|
+
console.log("KS_MAIL_PASSWORD not found in .env file");
|
|
16
|
+
return await false;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
if ("KS_TO_MAIL_ID" in process.env === false) {
|
|
20
|
+
console.log("KS_TO_MAIL_ID not found in .env file");
|
|
21
|
+
return await false;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const LocalFromSendMail = jFTransporterForGoogle.sendMail({
|
|
25
|
+
from: `"KeshavSoft" ${process.env.KS_MAIL_ID}`,
|
|
26
|
+
to: `${process.env.KS_TO_MAIL_ID}`,
|
|
27
|
+
subject: `Hello ✔`,
|
|
28
|
+
text: "16",
|
|
29
|
+
html: ""
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return await LocalFromSendMail;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
let jFTransporterForGoogle = nodemailer.createTransport({
|
|
36
|
+
host: "smtp.gmail.com",
|
|
37
|
+
port: 587,
|
|
38
|
+
secure: false,
|
|
39
|
+
auth: {
|
|
40
|
+
user: process.env.KS_MAIL_ID,
|
|
41
|
+
pass: process.env.KS_MAIL_PASSWORD
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export default startFunc;
|