exp-response-utils

1.0.1 • Public • Published

Express Responses Utils

This package provides utility functions for sending standardized JSON responses in an Express.js application.

Installation

    npm install --save exp-response-utils@1.0.1

Available Functions

sendSuccessData(res, data, message)
sendCreatedData(res, data, message)
sendSuccess(res, message)
sendCreated(res, message)
sendUnauthorized(res, message)
sendForbidden(res, message)
sendNotFound(res, message)
sendServerError(res, error, message)
sendConflict(res, message)
SendMethodNotAllowed(res, message)

Usage Example

    const express = require('express');
    const app = express();
    const responseUtils = require('exp-response-utils');

    app.get('/api/data', (req, res) => {
        const data = { key: 'value' };
        responseUtils.sendSuccessData(res, data, 'Data retrieved successfully');
    });

    // Other usage examples of response functions
    // ...

    app.listen(3000, () => {
        console.log('Server running on port 3000');
    });

License

This package is licensed under ISC. See the LICENSE file for more details.

Readme

Keywords

Package Sidebar

Install

npm i exp-response-utils

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

3.65 kB

Total Files

3

Last publish

Collaborators

  • swalest