-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAPI.cpp
More file actions
66 lines (60 loc) · 2.12 KB
/
API.cpp
File metadata and controls
66 lines (60 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "API.h"
#include <fstream>
#include "Input/Input.h"
#include "Log/Log.h"
namespace project {
std::string API::getMongodb() {
return this->mongodb;
}
void API::setMongodb(const std::string& mongodb) {
this->mongodb = mongodb;
}
void API::createENV() {
try {
std::ofstream envFile(this->getPath() + "\\.env");
envFile << "PORT=" << this->getJsquick()["port"] << std::endl;
if (this->getJsquick()["mongo"]) {
envFile << "MONGODB=" << this->mongodb << std::endl;
}
envFile.close();
} catch (const std::exception& e) {
Log::logError(e.what());
}
}
API::API(const Input::api& input) {
this->setType(projectType::API);
this->setPath(Utility::getCurrentWorkingDirectory() + "\\" + input.name);
this->setSrcDir(Utility::getExecutableDir() + "\\api");
this->setFiles({
"\\index.js",
"\\routes\\example.js",
"\\jsquick\\handleRoutes.js",
"\\jsquick\\loadFiles.js",
"\\jsquick\\log.js"
});
this->setFolders({
"\\routes",
"\\jsquick"
});
nlohmann::json jsquick;
jsquick["name"] = input.name;
jsquick["type"] = projectType::API;
jsquick["routes"]["example"] = ".\\routes\\example.js";
jsquick["port"] = input.port;
jsquick["mongo"] = input.mongo;
this->setJsquick(jsquick);
this->setPackages("console-log-colors cors dotenv express glob mongoose table");
}
// void API::createFolders() {
// const std::string routesPath = this->getPath() + "\\routes";
// const std::string jsquickPath = this->getPath() + "\\jsquick";
//
// CreateDirectory(this->getPath().c_str(), nullptr);
// if(!Utility::isDirectoryEmpty(this->getPath())) {
// Log::logError("Directory is not empty");
// return;
// }
// CreateDirectory(routesPath.c_str(), nullptr);
// CreateDirectory(jsquickPath.c_str(), nullptr);
// }
} // namespace project