Skip to content

Commit

Permalink
Merge pull request #1 from lblod/ben/lmb-392-delete-mandataris
Browse files Browse the repository at this point in the history
Ben/lmb 392 delete mandataris
  • Loading branch information
bfidlers authored May 7, 2024
2 parents cb37c68 + 95dac67 commit cfa167f
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 4,728 deletions.
4 changes: 4 additions & 0 deletions app.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { app } from 'mu';
import { ErrorRequestHandler } from 'express';
import { mandatarissenRouter } from './routes/mandatarissen';

app.get('/', async (_req, res) => {
res.send({ status: 'ok' });
});

app.use('/mandatarissen', mandatarissenRouter);

const errorHandler: ErrorRequestHandler = function (err, _req, res, _next) {
// custom error handler to have a default 500 error code instead of 400 as in the template
res.status(err.status || 500);
Expand Down
23 changes: 23 additions & 0 deletions data-access/delete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { query, sparqlEscapeDateTime, sparqlEscapeString } from 'mu';

export const deleteMandataris = async (id: string) => {
const q = `
PREFIX mu: <http://mu.semte.ch/vocabularies/core/>
PREFIX astreams: <http://www.w3.org/ns/activitystreams#>
DELETE {
?uri ?p ?o.
}
INSERT {
?uri a astreams:Tombstone ;
astreams:deleted ${sparqlEscapeDateTime(new Date())} ;
astreams:formerType ?type .
}
WHERE {
?uri mu:uuid ${sparqlEscapeString(id)} ;
a ?type ;
?p ?o .
}
`;
await query(q);
};
Loading

0 comments on commit cfa167f

Please sign in to comment.