[server/rpcrepl] add bot authorization to RPC repl, also log rpcs.

This commit is contained in:
41666 2019-04-14 13:01:52 -05:00
parent aeac74ae98
commit a5f2b328d3
No known key found for this signature in database
GPG key ID: BC51D07640DC10AF
2 changed files with 10 additions and 3 deletions

View file

@ -53,6 +53,10 @@ export class Logger {
}
}
rpc (call: string, ...data: any) {
console.log(chalk.redBright.bold`RPC` + chalk.redBright(` ${call}():`), data)
}
sql (logger: Logger, ...data: any) {
if (logger.debugOn && !logger.quietSql) {
console.log(chalk.bold('DEBUG SQL:\n '), data)

View file

@ -18,8 +18,11 @@ const reset = async (r) => {
r.context.RP = RP
r.context.ctx = { session: { userId: RP.ctx.discord.cfg.rootUsers.values().next().value } }
r.context.guest = { session: {} }
r.context.ctx = {
session: { userId: RP.ctx.discord.cfg.rootUsers.values().next().value },
request: { headers: { 'authorization': `Bot ${process.env.SHARED_SECRET}` } }
}
r.context.guest = { session: {}, request: { headers: { 'authorization': `guest` } } }
r.context.g_rpc = {}
r.context.rpc = {}
@ -37,7 +40,7 @@ const reset = async (r) => {
const motd = () => {
console.log(`~~ Roleypoly RPC REPL.
\`ctx\` a mocked koa context, defaulting to first root user.
\`ctx\` a mocked koa context, defaulting to first root user, also authorized as a bot.
\`rpc\` maps to all rpc functions, prefilled with ctx.
\`guest\` maps to a mock guest sessioned koa context.