DPDK Architecture  ->  Bootstrap (v3.0.5)

REST API
>= v1.0.0

Custom Endpoints
>= v1.21.0

You can setup custom REST endpoints like this:

const bootstrap = new NextBootstrap(__dirname, process.cwd(), nextConfig);

// HTTP GET
bootstrap.get('/api/test', (req, res) => {
  res.json({
    message: 'OK'
  });
});

// HTTP POST
bootstrap.post('/api/test', (req, res) => {
  res.json({
    message: 'OK'
  });
});

// HTTP PUT
bootstrap.put('/api/test', (req, res) => {
  res.json({
    message: 'OK'
  });
});

// HTTP PATCH
bootstrap.patch('/api/test', (req, res) => {
  res.json({
    message: 'OK'
  });
});

// HTTP DELETE
bootstrap.delete('/api/test', (req, res) => {
  res.json({
    message: 'OK'
  });
});

bootstrap.init();

Structure
>= v1.0.0

All bootstrap API call's will respond with this basic structure:

{
  "status": 1000,
  "result": {}
}

Status Codes
>= v1.16.3

The status code in the example above is a Bootstrap standard code.
These can be used anywhere in your application like this:

const statusCode = require('@dpdk/bootstrap/dist/status');
console.log('status', statusCode(1000)); // Outputs { code: 1000, message: '' } in production. Outputs { code: 1000, message: 'Request completed' } in development

All status codes can be found below:

Success Codes
>= v1.16.3

| Status Code | Status Message | |:------------ |:------------------------- | | 1000 | Request completed | | 1010 | Account activated | | 1011 | Login successful | | 1012 | Password reset successful | | 1020 | Email has been send | | 1030 | Form has been submitted |

Error Codes
>= v1.16.3

| Status Code | Status Message | |:------------ |:------------------------- | | 5000 | Server error | | 5010 | Account not found | | 5011 | Account not activated | | 5012 | Login incorrect | | 5013 | Email/Username not found | | 5020 | Error sending email | | 5030 | Error submitting form | | 5031 | Error sending email | | 5032 | Invalid fields | | 5033 | File to large | | 5034 | Invalid file type | | 5035 | CSRF validation failed | | 9999 | Generic Error |

Links

JSON-API Documentation: https://jsonapi.org/

OpenAPI Documentation: https://github.com/OAI/OpenAPI-Specification

Last modifiedFriday, April 30, 2021, 12:00:21 PM UTC
Last authorColin van Eenige
Commit ID4c7a701