A progressive Node.js framework for building efficient and scalable server-side applications.
Rest API to import and query investigation data with NestJs, MongoDB, TypeORM, and TypeScript.
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
Create .env file cp .env.example .env and replace existing env variables (mongodb connection params)
# Run development server and open http://localhost:3000
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# e2e tests
$ npm run test:e2e
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)
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
}