MCPcopy Index your code
hub / github.com/nodeSolidServer/node-solid-server / handler

Function handler

lib/handlers/put.mjs:6–27  ·  view source on GitHub ↗
(req, res, next)

Source from the content-addressed store, hash-verified

4import debug from '../debug.mjs'
5
6export default async function handler (req, res, next) {
7 debug.handlers('PUT -- ' + req.originalUrl)
8 // deprecated kept for compatibility
9 res.header('MS-Author-Via', 'SPARQL') // is this needed ?
10 const contentType = req.get('content-type')
11
12 // check whether a folder or resource with same name exists
13 try {
14 const ldp = req.app.locals.ldp
15 await ldp.checkItemName(req)
16 } catch (e) {
17 return next(e)
18 }
19 // check for valid rdf content for auxiliary resource and /profile/card
20 // TODO check that /profile/card is a minimal valid WebID card
21 if (isAuxiliary(req) || req.originalUrl === '/profile/card') {
22 if (contentType === 'text/turtle') {
23 return bodyParser.text({ type: () => true })(req, res, () => putValidRdf(req, res, next))
24 } else return next(new HTTPError(415, 'RDF file contains invalid syntax'))
25 }
26 return putStream(req, res, next)
27}
28
29// Verifies whether the user is allowed to perform Append PUT on the target
30async function checkPermission (request, resourceExists) {

Callers

nothing calls this directly

Calls 5

isAuxiliaryFunction · 0.85
putValidRdfFunction · 0.85
putStreamFunction · 0.85
checkItemNameMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected