mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-15 01:49:10 +00:00
[server/rpcrepl] add bot authorization to RPC repl, also log rpcs.
This commit is contained in:
parent
aeac74ae98
commit
a5f2b328d3
2 changed files with 10 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue