Skip to content

hadeyici/investigation-api

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Description

Rest API to import and query investigation data with NestJs, MongoDB, TypeORM, and TypeScript.

Installation

Install nodejs and mongodb in your machine.

# 1. Clone the repository.
$ git clone https://github.com/hadeyici/investigation-api.git

# 2. Enter your newly-cloned folder.
$ cd investigation-api

# 3. Install dependencies.
$ npm install

Configuration

Create .env file cp .env.example .env and replace existing env variables (mongodb connection params)

Running the app

# Run development server and open http://localhost:3000
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# e2e tests
$ npm run test:e2e

API

Server will listen on port 3000, and it expose the following APIs:

  • POST - /investigations - Upload a new csv file | keys in csv file;

    • eventType - string ('fileCreated', 'fileAccessed', 'fileDownloaded', 'eventRecordCreated' or 'fileExecuted')
    • deviceName - string
    • tags - string[]
    • data - object[]
    • userName - string (optional)
  • GET - /investigations - Returns investigations | search params;

    • startDate - string
    • endDate - string
    • eventType - (optional)
    • deviceName - (optional)
    • tags - (optional)
    • data - (optional)
    • userName - (optional)

Request and Responses

POST /investigations upload csv file

  • Request

Example csv file: example.csv;

"userName"|"eventType"|"deviceName"|"tags"|"data"
"Helen"|"eventRecordCreated"|"mobile"|["ca","english"]|[{"job":{"name":"student","sallary":null},"favorite":"Twitter"}]
"Kane"|"fileCreated"|"mobile"|["faketon","ma"]|[{"job":{"name":"worker","sallary":"2 thousand"},"favorite":"Facebook"}]
"Parker"|"fileDownloaded"|"mobile"|["france","fr"]|[{"favorite":"Instagram"}]
"Clara"|"fileExecuted"|"pc"|["english","faketon"]|[{"favorite":"Instagram","married":true}]
"Adan"|"fileDownloaded"|"pc"|["group","ca"]|[{"job":{"name":"engineer","sallary":null},"married":false}]
"Mila"|"fileAccessed"|"pc"|["city","fr"]|[{"job":{"name":"teacher","sallary":"4 thousand"},"favorite":"Facebook"}]
"Leon"|"eventRecordCreated"|"pc"|["vancouver","faketon"]|[{"job":{"name":"farmer","sallary":null},"favorite":"Instagram","married":true}]
  • Response
{
statusCode: HTTP Status Code,
"msg": Success / Error Message,
}

GET /investigations returns investigations

  • Request
`GET /investigations?startDate=2021-11-25&endDate=2021-11-27&eventType=eventRecordCreated&deviceName=pc&userName=Leon&tags=["vancouver","faketon"]&data=mer`
  • Response
{
  "data": [
    {
      "id": "61a1032755e63a7150ac905c",
      "userName": "Leon",
      "eventType": "eventRecordCreated",
      "deviceName": "pc",
      "tags": [
        "vancouver",
        "faketon"
      ],
      "data": [
        {
          "job": {
            "name": "farmer",
            "sallary": null
          },
          "favorite": "Instagram",
          "married": true
        }
      ],
      "date": "2021-11-26T15:54:15.209Z"
    }
  ],
  "total": 1,
  "hasNext": false
}

or

{
  "data": [],
  "total": 0,
  "hasNext": false
}

About

Rest API to import and query investigation data.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published