Skip to content

Commit

Permalink
Merge pull request #40 from beachio/users_code
Browse files Browse the repository at this point in the history
Added users code update after start
  • Loading branch information
lumandra authored Sep 14, 2023
2 parents aedb0d7 + 0ecd0a5 commit 63e00bd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,24 @@ const postStart = async () => {
}
};

const checkUsersCode = async() => {
try {
const SERVER_URL = process.env.SERVER_URL;
const parse_id = SERVER_URL.match(/https:\/\/(\d*).*/)[1]
var file = fs.statSync('./cloud/users_code.js');
const url = process.env.CUSTOM_CODE_URL || 'https://getforge.com/cloud66-webhook';
console.log(file.size);
console.log(url);
if (file.size == 0){
request.post({headers: {'content-type': 'application/json'},
url: url, body: `{"service": {"name": "parse-${parse_id }"}}`})
}
}
catch (e) {
console.log(e)
}
};

// Clearing logs
const clearLogInterval = 1000 * 60 * 60 * 24;
const logsDirectory = './logs';
Expand All @@ -247,6 +265,7 @@ setInterval(clearLogs, clearLogInterval);
const httpServer = http.createServer(app);
httpServer.listen(PORT, async () => {
await postStart();
await checkUsersCode();
console.log(`Chisel Parse server v${packageJSON.version} running on port ${PORT}.`);
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chisel-parse-server",
"version": "0.7.16",
"version": "0.7.17",
"description": "Parse Server setup for Chisel CMS",
"author": "Beach.io <beach.io>",
"license": "MIT",
Expand Down

0 comments on commit 63e00bd

Please sign in to comment.