Skip to content

gmahota/nodejs-sales-api

Repository files navigation

Sales API

Welcome to the documentation of the Sales API. This API provides endpoints to manage companies, customers, projects, products, orders, document types, document series, and sales documents.

Requirements

  • Node.js
  • npm (or yarn)
  • Postman (for testing requests)

Installation

  1. Clone the repository:
git clone https://github.com/your-username/your-repository.git
cd your-repository
  1. Install dependencies:
npm install
# or
yarn install
  1. Configure environment variables:

Create a .env file in the root of your project and add the following variables:

PORT=5000
  1. Start the server:
node src/server.js

The API will be available at http://localhost:5000.

Server File (server.ts)

The server.ts file contains the code to set up and start the Express server. Here is an overview of the file:

/* Add the TypeScript code here */

Authentication

This API uses Bearer token authentication. Include the access token in authorized requests. An example token is provided below:

{
  "token": "AAAAAAAAAA",
  "type": "string"
}

Routes

Companies

List Companies

  • Endpoint: GET /api/base/companies
  • Request:
    • Method: GET
    • Authentication: Bearer Token
  • Example:
    curl -X GET -H "Authorization: Bearer YOUR_TOKEN" http://localhost:5000/api/base/companies