Storage
Build Server Endpoints
Retrieve Data Block by Type
The Retrieve Data Block endpoint is responsible for fetching the block data (Profile or Session) from your database. OwnID will send a request to this endpoint, specifying the block type it needs to retrieve.
code sample
app.get('/providers/storage/:blockType', (req, res) => {
const { blockType } = req.params;
// Simulate fetching block data from your database
const blockData = getBlockData(blockType);
if (blockData) {
res.status(200).json(blockData);
} else {
res.status(404).send('Data for the specified blockType not found.');
}
});
Set/Update Data Block by Type
code sample
app.post('/providers/storage/:blockType', (req, res) => {
const { blockType } = req.params;
const newData = req.body;
// Simulate updating block data in your database
const success = updateBlockData(blockType, newData);
if (success) {
res.status(200).send('Data updated successfully.');
} else {
res.status(404).send('Data for the specified blockType not found.');
}
});