CenterForDigitalHumanities / CenterForDigitalHumanities/rerum_server_nodejs

Object Minting Utility for db-controller

Open
#82 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
3
Forks
6
Avg merge
1h 25m
Merged PRs (30d)
3

Description

This is an optimization idea.

Each of the actions have a moment like
```javascript
const id = new ObjectID().toHexString()
let generatorAgent = req.user[process.env.RERUM_AGENT_CLAIM] ?? "http://dev.rerum.io/agent/CANNOTBESTOPPED"
let context = req.body["@context"]?{"@context":req.body["@context"]}:{}
let provided = JSON.parse(JSON.stringify(req.body))
let rerumProp = {"__rerum":utils.configureRerumOptions(generatorAgent, provided, false, false)["__rerum"]}
delete provided["_rerum"]
delete provided["_id"]
delete provided["@id"]
delete provided["@context"]
let newObject = Object.assign(context, {"@id":process.env.RERUM_ID_PREFIX + id}, provided, rerumProp, {"_id":id})
```
where this code is ALMOST a direct C&P, but not quite so it will take a little focus and thought. This can probably be a utility function, JSON in - JSON Out with some strategic flags to make sure to support the slight differences between actions

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.