For AI agents: the complete documentation index is available at https://docs.dataplatform.ovh.net/llms.txt, the full documentation bundle is available at https://docs.dataplatform.ovh.net/llms-full.txt, and this page is available as Markdown at https://docs.dataplatform.ovh.net/sdk/api-custom-endpoints.md.
  • 🇬🇧 English
  • Create custom endpoints

    Warning

    Rework pending, no delivery date. The Front App SDK (ReactJS) and the Front API SDK (NodeJS) are both being replaced. This page documents the current release, remains accurate, and is maintained until the replacement ships. Code written against it keeps working.

    It is possible to create completely new endpoints in your API.


    Add new routes

    ./src/index.js

    
    const IAM = require('../forepaas/iam/IAM')
    
    /*
    We define an AuthInterceptor, that checks for user authentication, to be used in the new routes.
    Without adding it, the new routes will be publicly available.
    In the /qb/* endpoints the same mechanism is already done.
    */
    let AuthInterceptor = function (req, _res, next) {
        new IAM().checkSession(req, (err, session) => {
            if (err) {
                return next(err);
            } 
            req.authentication = {
                session
            }
            next();
        })
    }
    /*
    The SDK loads src/index.js, if present, and execute the exported function passing the "Express app".
    That gives an opportunity to add routes.
    */
    module.exports = (app) => {
        // this route checks for user authentication
        app.get('/hello/user', [AuthInterceptor], (req, res, next) => {
        res.ok({"hello": "user !"});
      });
      // this route will be public
      app.get('/hello/everyone', (req, res, next) => {
        res.ok({"hello": "world !"});
      });
    }

    Notes:

    • The SDK uses Express
    • If the ./src/index.js file exists, it is executed as a function passing the Express app
    • This allows you to declare new routes using Express methods
    • It is needed to handle Authentication in those implementations

    Upload files through APIs

    You can use the same mechanism and a library such as Multer.

    For instance, to process my-budget.csv:

    const IAM = require('../forepaas/iam/IAM')
    const upload = multer()
    
    module.exports = (app) => {
      app.get('/send/budget', [AuthInterceptor, upload.single('budget')], (req, res, next) => {
        console.log(req.file)
        res.ok()
      })
    }

    It is then possible to process the file from the Front API, store it in the Lakehouse Manager buckets and launch a Data Processing Engine workflow or action!

    Go further

    If you need training or technical assistance to implement our solutions, contact your sales representative or click on this link to get a quote and ask our Professional Services experts for a custom analysis of your project.

    Ask questions, give your feedback and interact directly with the team building the Data Platform on the dedicated Discord channel.

    If you need support with your OVHcloud services, create a request in our Help Centre.

    Join our community of users.