Skip to content

Instantly share code, notes, and snippets.

@jspw
Last active December 26, 2023 12:11
Show Gist options
  • Save jspw/6c0bdedd5abee70464e5e736ffa16290 to your computer and use it in GitHub Desktop.
Save jspw/6c0bdedd5abee70464e5e736ffa16290 to your computer and use it in GitHub Desktop.
Intra_CRM Backend Api Doc

A simplified table of contents for the API endpoints:

  1. Get Jobs API

  2. Get Sectors API

  3. Get Locations API

Get Jobs API

The Get Jobs API allows you to retrieve a list of jobs from the database while ensuring secure access through token-based authentication.

Endpoint

GET /jobs

Authentication

This API requires a bearer token for authentication. Include the token in the Authorization header of your request using the following format:

Authorization: Bearer YOUR_ACCESS_TOKEN

Query Parameters

Parameter Type Description
start number The index of the first job to return. Default is 0.
limit number The maximum number of jobs to return. Default is 60.
search string A keyword to search for in the job title. Optional.
type number The type of the job. Can be either 0 (master) or 1 (reed). Optional.

Response

The response is a JSON object with the following fields:

Field Type Description
total number The total number of jobs in the database that match the query parameters.
start number The index of the first job returned.
limit number The maximum number of jobs returned.
filtered number The number of jobs returned.
data array An array of job objects. Each job object has the following fields:
- id: The unique identifier of the job.
- title: The title of the job.
- type: The type of the job. 0 (master) or 1 (reed).
- createdAt: The date and time when the job was created.
- updatedAt: The date and time when the job was last updated.

Example

Request

GET /jobs?start=10&limit=20&search=engineer&type=0

Headers

Authorization: Bearer YOUR_ACCESS_TOKEN

Response

{
  "total": 35,
  "start": 10,
  "limit": 20,
  "filtered": 20,
  "data": [
    {
      "id": 11,
      "title": "Senior Software Engineer",
      "type": 0,
      "createdAt": "2023-12-01T10:15:23.000Z",
      "updatedAt": "2023-12-01T10:15:23.000Z"
    },
    {
      "id": 12,
      "title": "Mechanical Engineer",
      "type": 0,
      "createdAt": "2023-11-30T09:12:45.000Z",
      "updatedAt": "2023-11-30T09:12:45.000Z"
    },
    // ... more jobs
  ]
}

Authorization and Protection

To access this API, you must include a valid bearer token in the request header. Additionally, the API is protected by an authorization middleware (authorization) and a protector middleware (protector) to ensure that only authorized users can access the resource.

Please make sure to handle and securely store your access token. Unauthorized or improperly formatted tokens will result in a 401 Unauthorized response.

Feel free to use and adapt this documentation for your team's needs. If you have any further questions or adjustments, please let me know!

Get Sectors API

The Get Sectors API allows you to retrieve a list of sectors from the database. This endpoint requires token-based authentication to ensure secure access.

Endpoint

GET /sectors

Authentication

This API requires a bearer token for authentication. Include the token in the Authorization header of your request using the following format:

Authorization: Bearer YOUR_ACCESS_TOKEN

Response

The response is a JSON array containing sector objects with the following fields:

Field Type Description
id number The unique identifier of the sector.
name string The name of the sector.
createdAt string The date and time when the sector was created.
updatedAt string The date and time when the sector was last updated.

Example

Request

GET /sectors

Headers

Authorization: Bearer YOUR_ACCESS_TOKEN

Response

[
  {
    "id": 1,
    "name": "Technology",
    "createdAt": "2023-12-01T10:15:23.000Z",
    "updatedAt": "2023-12-01T10:15:23.000Z"
  },
  {
    "id": 2,
    "name": "Finance",
    "createdAt": "2023-11-30T09:12:45.000Z",
    "updatedAt": "2023-11-30T09:12:45.000Z"
  },
  // ... more sectors
]

Authorization and Protection

To access this API, you must include a valid bearer token in the request header. The API is protected by an authorization middleware (authorization) and a protector middleware (protector) to ensure that only authorized users can access the resource.

Please make sure to handle and securely store your access token. Unauthorized or improperly formatted tokens will result in a 401 Unauthorized response.

Feel free to use and adapt this documentation for your team's needs. If you have any further questions or adjustments, please let me know!

Get Locations API

The Get Locations API allows you to retrieve a list of locations from the database. This endpoint requires token-based authentication to ensure secure access.

Data Structure

The location data is represented by the following model:

const Location = sequelize.define<any>("location", {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true,
        allowNull: true
    },
    county: {
        type: DataTypes.STRING,
        allowNull: false
    },
    town: {
        type: DataTypes.STRING,
        allowNull: false
    },
    postcode: {
        type: DataTypes.STRING,
        allowNull: false
    },
    createdAt: {
        type: DataTypes.DATE,
        allowNull: true,
        defaultValue: Sequelize.NOW
    },
    updatedAt: {
        type: DataTypes.DATE,
        allowNull: true,
        defaultValue: Sequelize.NOW
    }
});

Endpoint

GET /locations

Authentication

This API requires a bearer token for authentication. Include the token in the Authorization header of your request using the following format:

Authorization: Bearer YOUR_ACCESS_TOKEN

Response

The response is a JSON array containing location objects with the following fields:

Field Type Description
id number The unique identifier of the location.
county string The county of the location.
town string The town of the location.
postcode string The postcode of the location.
createdAt string The date and time when the location was created.
updatedAt string The date and time when the location was last updated.

Example

Request

GET /locations

Headers

Authorization: Bearer YOUR_ACCESS_TOKEN

Response

[
  {
    "id": 1,
    "county": "London",
    "town": "Camden",
    "postcode": "NW1 6XE",
    "createdAt": "2023-12-01T10:15:23.000Z",
    "updatedAt": "2023-12-01T10:15:23.000Z"
  },
  {
    "id": 2,
    "county": "Manchester",
    "town": "Salford",
    "postcode": "M5 4WT",
    "createdAt": "2023-11-30T09:12:45.000Z",
    "updatedAt": "2023-11-30T09:12:45.000Z"
  },
  // ... more locations
]

Authorization and Protection

To access this API, you must include a valid bearer token in the request header. The API is protected by an authorization middleware (authorization) and a protector middleware (protector) to ensure that only authorized users can access the resource.

Please make sure to handle and securely store your access token. Unauthorized or improperly formatted tokens will result in a 401 Unauthorized response.

Feel free to use and adapt this documentation for your team's needs. If you have any further questions or adjustments, please let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment