66 * @author Claude Sonnet 4, cubap, thehabes
77 */
88
9- import { newID , isValidID , db } from '../database/index .js'
9+ import { newID , isValidID , db } from '../database/client .js'
1010import utils from '../utils.js'
11+ import config from '../config/index.js'
1112import { _contextid , ObjectID , createExpressError , getAgentClaim , parseDocumentID , idNegotiation } from './utils.js'
1213
1314/**
@@ -75,13 +76,13 @@ const bulkCreate = async function (req, res, next) {
7576 // id is also protected in this case, so it can't be set.
7677 if ( _contextid ( d [ "@context" ] ) ) delete d . id
7778 d . _id = id
78- d [ '@id' ] = `${ process . env . RERUM_ID_PREFIX } ${ id } `
79+ d [ '@id' ] = `${ config . RERUM_ID_PREFIX } ${ id } `
7980 bulkOps . push ( { insertOne : { "document" : d } } )
8081 }
8182 try {
8283 let dbResponse = await db . bulkWrite ( bulkOps , { 'ordered' :false } )
8384 res . set ( "Content-Type" , "application/json; charset=utf-8" )
84- res . set ( "Link" , dbResponse . result . insertedIds . map ( r => `${ process . env . RERUM_ID_PREFIX } ${ r . _id } ` ) ) // https://www.rfc-editor.org/rfc/rfc5988
85+ res . set ( "Link" , dbResponse . result . insertedIds . map ( r => `${ config . RERUM_ID_PREFIX } ${ r . _id } ` ) ) // https://www.rfc-editor.org/rfc/rfc5988
8586 res . status ( 201 )
8687 const estimatedResults = bulkOps . map ( f => {
8788 let doc = f . insertOne . document
@@ -148,7 +149,7 @@ const bulkUpdate = async function (req, res, next) {
148149 // Update the same thing twice? can vs should.
149150 // if(encountered.includes(idReceived)) continue
150151 encountered . push ( idReceived )
151- if ( ! idReceived . includes ( process . env . RERUM_ID_PREFIX ) ) continue
152+ if ( ! idReceived . includes ( config . RERUM_ID_PREFIX ) ) continue
152153 let id = parseDocumentID ( idReceived )
153154 let originalObject
154155 try {
@@ -168,7 +169,7 @@ const bulkUpdate = async function (req, res, next) {
168169 // id is also protected in this case, so it can't be set.
169170 if ( _contextid ( objectReceived [ "@context" ] ) ) delete objectReceived . id
170171 delete objectReceived [ "@context" ]
171- let newObject = Object . assign ( context , { "@id" : process . env . RERUM_ID_PREFIX + id } , objectReceived , rerumProp , { "_id" : id } )
172+ let newObject = Object . assign ( context , { "@id" : config . RERUM_ID_PREFIX + id } , objectReceived , rerumProp , { "_id" : id } )
172173 bulkOps . push ( { insertOne : { "document" : newObject } } )
173174 if ( originalObject . __rerum . history . next . indexOf ( newObject [ "@id" ] ) === - 1 ) {
174175 originalObject . __rerum . history . next . push ( newObject [ "@id" ] )
@@ -185,7 +186,7 @@ const bulkUpdate = async function (req, res, next) {
185186 try {
186187 let dbResponse = await db . bulkWrite ( bulkOps , { 'ordered' :false } )
187188 res . set ( "Content-Type" , "application/json; charset=utf-8" )
188- res . set ( "Link" , dbResponse . result . insertedIds . map ( r => `${ process . env . RERUM_ID_PREFIX } ${ r . _id } ` ) ) // https://www.rfc-editor.org/rfc/rfc5988
189+ res . set ( "Link" , dbResponse . result . insertedIds . map ( r => `${ config . RERUM_ID_PREFIX } ${ r . _id } ` ) ) // https://www.rfc-editor.org/rfc/rfc5988
189190 res . status ( 200 )
190191 const estimatedResults = bulkOps . filter ( f => f . insertOne ) . map ( f => {
191192 let doc = f . insertOne . document
0 commit comments