@gluestack-v2/glue-plugin-service-gateway
Version:
Gluestack V2 service Gateway Plugin
70 lines (69 loc) • 3.62 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "path", "@gluestack-v2/framework-cli/build/helpers/file/write-file", "./dbclient-service-template", "./write-service"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
// import fs from 'fs';
// const sdkIndexTemplate = require("./templates/sdkIndexTemplate")();
const write_file_1 = __importDefault(require("@gluestack-v2/framework-cli/build/helpers/file/write-file"));
const dbclient_service_template_1 = __importDefault(require("./dbclient-service-template"));
const write_service_1 = require("./write-service");
// function filePathExtension(filePath: string) {
// return filePath.split(".").pop() ?? "";
// }
// function getCamelCaseName(name: string) {
// // clean up the name
// if (name.split('/')[0] === '') {
// let nameArr = name.split('/');
// nameArr.splice(0, 1);
// name = nameArr.join('/');
// }
// return name
// .split('/')
// .map(
// (word, ind) =>
// (ind !== 0 ? word[0]?.toUpperCase() : word[0]?.toLowerCase()) +
// word.slice(1)
// )
// .join('');
// }
// Usage: Pass the directory path as an argument to the function
const writeDbClientService = (generatedServiceGatewayPath, instanceName) => __awaiter(void 0, void 0, void 0, function* () {
const moleculerDbClientServiceTemplate = (0, dbclient_service_template_1.default)(instanceName);
// const moleculerFunctionsPath = path.join(installationPath, "functions");
const moleculerDbClientServiceTemplatePath = path_1.default.join(generatedServiceGatewayPath, 'services', `${instanceName}.service.js`);
// console.log("> Writing cron service", moleculerDbClientServiceTemplatePath);
// Create functions service with all the actions and imports
(0, write_file_1.default)(moleculerDbClientServiceTemplatePath, moleculerDbClientServiceTemplate);
// Create SDK index file with all the functions
// createFileWithPath(
// sdkSrcIndex,
// sdkIndexTemplate.replace(
// "// **---Functions will be added after this---**",
// sdkFunctions
// )
// );
// }
(0, write_service_1.updateApiGateway)(generatedServiceGatewayPath, instanceName);
});
exports.default = writeDbClientService;
});