From 31ce8ae582152c544efbff8b8b879c1187ffad3c Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Sun, 26 Feb 2023 08:36:27 +0000 Subject: [PATCH] rename index.js to main.js remove unused imports in main.js, add function prototypes to db.js --- db.js | 20 ++++++++++++++++++++ index.js => main.js | 3 +-- package.json | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 db.js rename index.js => main.js (95%) diff --git a/db.js b/db.js new file mode 100644 index 0000000..ef55a42 --- /dev/null +++ b/db.js @@ -0,0 +1,20 @@ +/** + * called at app startup, can be used to initialize any variables needed for database access + */ +function init () {} + +/** + * user requests additional resources specified in k-v pairs + * @param {string} user user's proxmox username in the form username@authrealm + * @param {Object} resources k-v pairs with resource name as keys and resource ammount as values + */ +function requestResources (user, resources) {} + +/** + * user releases allocated resources specified in k-v pairs + * @param {string} user user's proxmox username in the form username@authrealm + * @param {Object} resources k-v pairs with resource name as keys and resource ammount as values + */ +function releaseResources (user, resources) {} + +module.exports = {init, requestResources, releaseResources}; \ No newline at end of file diff --git a/index.js b/main.js similarity index 95% rename from index.js rename to main.js index 67456de..33267e4 100644 --- a/index.js +++ b/main.js @@ -8,8 +8,7 @@ const axios = require('axios'); var api = require("./package.json"); const {pveAPI, pveAPIToken, listenPort} = require("./vars.js"); -const { token } = require("morgan"); -const { response } = require("express"); +const {init, requestResources, releaseResources} = require("./db.js"); const app = express(); app.use(helmet()); diff --git a/package.json b/package.json index f2fe1d7..ab71c45 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "proxmoxaas-api", "version": "0.0.1", "description": "REST API for ProxmoxAAS", - "main": "index.js", + "main": "main.js", "dependencies": { "axios": "^1.3.2", "body-parser": "^1.20.1",