rpc request handlers

Signed-off-by: dzdidi <deniszalessky@gmail.com>
This commit is contained in:
dzdidi
2024-02-11 16:01:20 +00:00
parent 0a941fe5b8
commit 32f72eeb95
5 changed files with 238 additions and 123 deletions

35
src/rpc-handlers/bpr.js Normal file
View File

@@ -0,0 +1,35 @@
const ACL = require('../acl')
async getBPRHandler (publicKey, req) {
}
async addBPRHandler (publicKey, req) {
}
async delBPRHandler (publicKey, req) {
}
async parseBPRRequest(publicKey, req) {
if (!req) throw new Error('Request is empty')
const request = JSON.parse(req.toString())
const userId = await this.authenticate(publicKey, request)
const isOwner = ACL.getOwnder(repoName).includes(userId)
if (!isOwner) throw new Error('You are not allowed to access this repo')
const repoName = request.body.url?.split('/')?.pop()
// TODO: check if repo exists
return {
repoName,
userId,
// FIXME
acl: request.body.acl,
}
}
module.exports = {
getBPRHandler,
addBPRHandler,
delBPRHandler,
}