Skip to content

Commit

Permalink
Merge pull request #46 from beachio/user_code
Browse files Browse the repository at this point in the history
Fixed issue with write File data
  • Loading branch information
lumandra authored May 23, 2024
2 parents ab1e7aa + 6a388dc commit 5061f77
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ parseGraphQLServer.applyGraphQL(app);
app.post('/users_code', bodyParser.json(), (req, res, next) => {
if (req.headers['x-parse-application-id'] == APP_ID && req.headers['x-parse-rest-api-key'] == MASTER_KEY)
{
let usersCodeSuccess = false;
let usersCodeSuccess = true;
let customTemplatesSuccess = true;
fs.writeFileSync("./cloud/users_code.js", req.body.custom_code, (err) =>{
if (!err)
usersCodeSuccess = true;
});
try{
fs.writeFileSync("./cloud/users_code.js", req.body.custom_code)
} catch (e) {
usersCodeSuccess = false
}

const path = './siteTemplates/default_templates.json'
if (fs.existsSync(path)) {
let defaultData = JSON.parse(fs.readFileSync(path));
Expand All @@ -112,7 +114,7 @@ app.post('/users_code', bodyParser.json(), (req, res, next) => {
res.send({ status: 'SUCCESS' })
}
else
res.send({ status: 'Failed' })
res.status(403).send({ status: 'Failed' })
}
else
res.status(401).send({message: "Unauthorized"})
Expand Down

0 comments on commit 5061f77

Please sign in to comment.