Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// to enable using sub routes in our controller we create
// a new router. This router is a ChildRouter and will delegate
// all error and 404 handler to it's parent. i.e. the global
// application
var controller = Router({ prefix: prefix })
// We instantiate our model here with the database configuration
// the model is local to this user feature
var model = UserModel(config.db)
// we set up configuration to pass to our views.
// we also set up an urlMap so that views are not hard coded
// to specific paths
var viewsConfig = { layout: config.layout, urlMap: {
"user": format.bind(null, prefix + "/{userId}"),
"userEdit": format.bind(null, prefix + "/{userId}/edit"),
"userPet": format.bind(null, prefix + "/{userId}/pet"),
"pet": format.bind(null, config.features.pet + "/{petId}")
} }
// optionally /. so its /user & /user/
controller.addRoute("/?", function (req, res, opts, cb) {
model.getAll(function (err, users) {
if (err) {
return cb(err)
}
sendHtml(req, res, usersPage(users, viewsConfig))
})
})
// to enable using sub routes in our controller we create
// a new router. This router is a ChildRouter and will delegate
// all error and 404 handler to it's parent. i.e. the global
// application
var controller = Router({ prefix: prefix })
// We instantiate our model here with the database configuration
// the model is local to this user feature
var model = UserModel(config.db)
// we set up configuration to pass to our views.
// we also set up an urlMap so that views are not hard coded
// to specific paths
var viewsConfig = { layout: config.layout, urlMap: {
"user": format.bind(null, prefix + "/{userId}"),
"userEdit": format.bind(null, prefix + "/{userId}/edit"),
"userPet": format.bind(null, prefix + "/{userId}/pet"),
"pet": format.bind(null, config.features.pet + "/{petId}")
} }
// optionally /. so its /user & /user/
controller.addRoute("/?", function (req, res, opts, cb) {
model.getAll(function (err, users) {
if (err) {
return cb(err)
}
sendHtml(req, res, usersPage(users, viewsConfig))
})
})
controller.addRoute("/:userId/edit", function (req, res, opts, cb) {
// a new router. This router is a ChildRouter and will delegate
// all error and 404 handler to it's parent. i.e. the global
// application
var controller = Router({ prefix: prefix })
// We instantiate our model here with the database configuration
// the model is local to this user feature
var model = UserModel(config.db)
// we set up configuration to pass to our views.
// we also set up an urlMap so that views are not hard coded
// to specific paths
var viewsConfig = { layout: config.layout, urlMap: {
"user": format.bind(null, prefix + "/{userId}"),
"userEdit": format.bind(null, prefix + "/{userId}/edit"),
"userPet": format.bind(null, prefix + "/{userId}/pet"),
"pet": format.bind(null, config.features.pet + "/{petId}")
} }
// optionally /. so its /user & /user/
controller.addRoute("/?", function (req, res, opts, cb) {
model.getAll(function (err, users) {
if (err) {
return cb(err)
}
sendHtml(req, res, usersPage(users, viewsConfig))
})
})
controller.addRoute("/:userId/edit", function (req, res, opts, cb) {
model.get(opts.userId, function (err, user) {
// all error and 404 handler to it's parent. i.e. the global
// application
var controller = Router({ prefix: prefix })
// We instantiate our model here with the database configuration
// the model is local to this user feature
var model = UserModel(config.db)
// we set up configuration to pass to our views.
// we also set up an urlMap so that views are not hard coded
// to specific paths
var viewsConfig = { layout: config.layout, urlMap: {
"user": format.bind(null, prefix + "/{userId}"),
"userEdit": format.bind(null, prefix + "/{userId}/edit"),
"userPet": format.bind(null, prefix + "/{userId}/pet"),
"pet": format.bind(null, config.features.pet + "/{petId}")
} }
// optionally /. so its /user & /user/
controller.addRoute("/?", function (req, res, opts, cb) {
model.getAll(function (err, users) {
if (err) {
return cb(err)
}
sendHtml(req, res, usersPage(users, viewsConfig))
})
})
controller.addRoute("/:userId/edit", function (req, res, opts, cb) {
model.get(opts.userId, function (err, user) {
if (err) {
obsinfo() {
if (this.obsProps.streamStatus != null) {
const { fps, kbitsPerSec } = this.obsProps.streamStatus;
this.say(
format(this.locale.obsinfo.success, {
currentScene: this.obsProps.currentScene,
fps: Math.round(fps),
bitrate: kbitsPerSec
})
);
} else {
this.say(this.locale.obsinfo.error);
}
}
async switch(sceneName) {
if (sceneName == null) return this.say(this.locale.switch.error);
const res = search(sceneName, this.obsProps.scenes, { keySelector: obj => obj.name });
const scene = res.length > 0 ? res[0].name : sceneName;
try {
await this.obs.setCurrentScene({
"scene-name": scene
});
this.say(
format(this.locale.switch.success, {
scene
})
);
} catch (e) {
log.error(e);
this.say(e.error);
}
}
protected getTemplate (): string {
return format(DebugProtectionFunctionIntervalTemplate(), {
debugProtectionFunctionName: this.debugProtectionFunctionName
});
}
}
config.twitchChat.alias.map((arr, index) => {
if (arr[0] == alias) {
config.twitchChat.alias.splice(index);
delete this.aliases[alias];
this.handleWriteToConfig();
this.say(
format(this.locale.alias.removed, {
alias: alias
})
);
exists = true;
}
});
log.success(`Started recording`);
} catch (error) {
this.say(
format(`[REC] ${this.locale.rec.error}`, {
option: this.locale.rec.started
})
);
}
} else {
try {
const res = await this.obs.StopRecording();
if (res.status === "ok") this.say(`[REC] ${this.locale.rec.stopped}`);
log.success(`Stopped recording`);
} catch (error) {
this.say(
format(` [REC] ${this.locale.rec.error}`, {
option: this.locale.rec.stopped
})
);
}
}
}
protected getTemplate (): string {
const domainsString: string = this.options.domainLock.join(';');
const [hiddenDomainsString, diff]: string[] = this.cryptUtils.hideString(
domainsString,
domainsString.length * 3
);
const globalVariableTemplate: string = this.options.target !== ObfuscationTarget.BrowserNoEval
? this.getGlobalVariableTemplate()
: GlobalVariableNoEvalTemplate();
return format(DomainLockNodeTemplate(), {
domainLockFunctionName: this.identifierNamesGenerator.generate(),
diff: diff,
domains: hiddenDomainsString,
globalVariableTemplate,
singleNodeCallControllerFunctionName: this.callsControllerFunctionName
});
}
}