Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public static async getCourses (app: any, req: any, res: any, apiData: any): Promise {
const auth = req.get('Authorization')
const apiKey = auth != null && auth.includes('APIKEY ') && auth.split('APIKEY ')[1]
const account = await Account.getAccountByAPIKey(apiKey)
if (apiData.prettify) {
app.set('json spaces', 2)
}
const courses = await this.filterCourses(account ? account._id : null, apiData)
if (apiData.format === 'ini') {
res.set('Content-type', 'text/plain')
res.send(`${encode({ General: { lvlcount: courses.length } })}\n${encode(JSON.parse(JSON.stringify(courses)), {
section: 'Level',
whitespace: false // TODO
})}`)
} else {
res.json(courses)
}
if (apiData.prettify) {
app.set('json spaces', 0)
}
}
}
if (!fs.existsSync(`${params.path}.backup`)) {
fs.copyFileSync(params.path, `${params.path}.backup`);
}
const hgrc = ini.parse(fs.readFileSync(params.path, 'utf-8'));
if (!('hooks' in hgrc)) {
hgrc.hooks = {};
}
hgrc.hooks['preupdate.bitrix.build.watcher'] = preUpdateHandler;
hgrc.hooks['update.bitrix.build.watcher'] = updateHandler;
const encodedHgrc = ini.encode(hgrc);
fs.writeFileSync(params.path, encodedHgrc);
if (!argv.silent && params.silent !== true) {
// eslint-disable-next-line
Logger.log(`${params.path} updated`.green.bold);
}
}
function formPypircFormatFromData(authInfo: auth.AuthInfo[]): string{
let ent : {} = {};
let header = util.format("[distutils]%sindex-servers=", os.EOL);
for(let entry of authInfo) {
console.log(tl.loc("Info_AddingAuthForRegistry", entry.packageSource.feedName));
if (entry.packageSource.feedName in ent){
throw new Error(tl.loc("Error_DuplicateEntryForExternalFeed",
entry.packageSource.feedName));
}
header += util.format("%s ", entry.packageSource.feedName);
ent[entry.packageSource.feedName] = new Repository(entry.packageSource.feedUri, entry.username, entry.password);
}
let encodedStr = ini.encode(ent);
header = header + os.EOL + encodedStr;
return header;
}
ipcMain.on('update_game_settings', (event, data) => {
var id = data.rom.toLowerCase().replace('-', ''),
settings = data.settings,
valid_games = game_storage.get('games').filter({title_id: data.rom}).value(),
instance = settings_storage.get('cemu_paths').find({name: data.emu}).value();
if (!valid_games || !instance) {
return;
}
for (var i=0;i
function write (file, conf) {
delete conf.auth
delete conf.creds
return writeFile(file, ini.encode(conf))
}
function writeLockfile(target, contents) {
return fs.writeFile(path.resolve(target, LOCKFILE_NAME), ini.encode(contents));
}
return new Promise((resolve, reject) => {
fs.writeFile(this.filePath, ini.encode(this.settings), err => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}