mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-16 18:29:08 +00:00
RPC: temporarily disable argument guards, add cookie support for SSR
(now with full isomorphism... almost!)
This commit is contained in:
parent
f30ca78e40
commit
c32ee37ca5
5 changed files with 47 additions and 10 deletions
|
@ -32,7 +32,7 @@ export default class RPCServer {
|
|||
this.mapHash = fnv.hash(Object.keys(this.rpcMap)).str()
|
||||
|
||||
// call map for the client.
|
||||
this.rpcCalls = Object.keys(this.rpcMap).map(fn => ({ name: this.rpcMap[fn].name, args: this.rpcMap[fn].length - 1 }))
|
||||
this.rpcCalls = Object.keys(this.rpcMap).map(fn => ({ name: this.rpcMap[fn].name, args: 0 }))
|
||||
}
|
||||
|
||||
hookRoutes (router: betterRouter) {
|
||||
|
@ -68,9 +68,9 @@ export default class RPCServer {
|
|||
|
||||
// if call.length (which is the solid args list)
|
||||
// is longer than args, we have too little to call the function.
|
||||
if (args.length < call.length) {
|
||||
return this.rpcError(ctx, null, new RPCError(`RPC call ${fn}() with ${args.length} arguments does not exist.`, 400))
|
||||
}
|
||||
// if (args.length < call.length) {
|
||||
// return this.rpcError(ctx, null, new RPCError(`RPC call ${fn}() with ${args.length} arguments does not exist.`, 400))
|
||||
// }
|
||||
|
||||
try {
|
||||
const response = await call(ctx, ...args)
|
||||
|
|
11
rpc/user.js
Normal file
11
rpc/user.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
// @flow
|
||||
import { type AppContext } from '../Roleypoly'
|
||||
import { type Context } from 'koa'
|
||||
// import { type Guild } from 'discord.js'
|
||||
|
||||
export default ($: AppContext) => ({
|
||||
getCurrentUser (ctx: Context) {
|
||||
const { userId } = ctx.session
|
||||
return $.discord.getUserPartial(ctx.session.userId)
|
||||
}
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue