API to an assets management system
Explore the docs »
To run this project, you will need to install Node.js.
Clone the repository:
git clone https://github.com/lgsfarias/tractian-challenge-back.git
Access the project folder:
cd tractian-challenge-back
Fill the .env following the .env.example file
cp .env.example .env
Install dependencies:
npm install
Run the project:
npm run dev
POST /login
- Route to authenticate a user
- headers: {}
- body: {
"email": "[email protected]",
"password": "lorem123"
}
POST /signup
- Route to create a new user
- headers: {}
- body: {
"name": "Lorem Ipsum"
"email": "[email protected]",
"password": "lorem123",
"confirmPassword": "lorem123",
"company": "Lorem"
}
GET /users/show-data
- Route to show user data
- headers: {
"Authorization": "Bearer <token>"
}
POST /companies/
- Route to create a new company
- headers: {
"Authorization": "Bearer <token>"
}
- body: {
"name": "Lorem Ipsum"
}
GET /companies/
- Route to get all companies
- headers: {
"Authorization": "Bearer <token>"
}
GET /companies/:id
- Route to get a company by id
- headers: {
"Authorization": "Bearer <token>"
}
PUT /companies/:id
- Route to update a company by id
- headers: {
"Authorization": "Bearer <token>"
}
- body: {
"name": "Lorem Ipsum"
}
DELETE /companies/:id
- Route to delete a company by id
- headers: {
"Authorization": "Bearer <token>"
}
POST /units/
- Route to create a new unit
- headers: {
"Authorization": "Bearer <token>"
}
- body: {
"name": "Lorem Ipsum",
"company": "60f1a1f1b9c1a00015e1b1a1"
}
GET /units/
- Route to get all units
- headers: {
"Authorization": "Bearer <token>"
}
GET /units/:id
- Route to get a unit by id
- headers: {
"Authorization": "Bearer <token>"
}
PUT /units/:id
- Route to update a unit by id
- headers: {
"Authorization": "Bearer <token>"
}
- body: {
"name": "Lorem Ipsum",
"company": "60f1a1f1b9c1a00015e1b1a1"
}
DELETE /units/:id
- Route to delete a unit by id
- headers: {
"Authorization": "Bearer <token>"
}
POST /assets/
- Route to create a new asset
- headers: {
"Authorization": "Bearer <token>"
}
- body: {
"image": "https://lorem.com",
"name": "Lorem Ipsum",
"model": "Lorem Ipsum",
"description": "Lorem Ipsum",
"status": "Running",
"healthLevel": 100,
"unit": "60f1a1f1b9c1a00015e1b1a1",
"owner": "60f1a1f1b9c1a00015e1b1a1"
}
GET /assets/by-company/:companyId
- Route to get all assets by company id
- headers: {
"Authorization": "Bearer <token>"
}
GET /assets/by-unit/:unitId
- Route to get all assets by unit id
- headers: {
"Authorization": "Bearer <token>"
}
GET /assets/:id
- Route to get a asset by id
- headers: {
"Authorization": "Bearer <token>"
}
PUT /assets/:id
- Route to update a asset by id
- headers: {
"Authorization": "Bearer <token>"
}
- body: {
"image": "https://lorem.com",
"name": "Lorem Ipsum",
"model": "Lorem Ipsum",
"description": "Lorem Ipsum",
"status": "Running",
"healthLevel": 100,
"unit": "60f1a1f1b9c1a00015e1b1a1",
"owner": "60f1a1f1b9c1a00015e1b1a1"
}
DELETE /assets/:id
- Route to delete a asset by id
- headers: {
"Authorization": "Bearer <token>"
}
POST /employees/
- Route to create a new employee
- headers: {
"Authorization": "Bearer <token>"
}
- body: {
"name": "Lorem Ipsum",
"unit": "60f1a1f1b9c1a00015e1b1a1",
}
GET /employees/by-company/:companyId
- Route to get all employees by company id
- headers: {
"Authorization": "Bearer <token>"
}
GET /employees/by-unit/:unitId
- Route to get all employees by unit id
- headers: {
"Authorization": "Bearer <token>"
}
GET /employees/:id
- Route to get a employee by id
- headers: {
"Authorization": "Bearer <token>"
}
PUT /employees/:id
- Route to update a employee by id
- headers: {
"Authorization": "Bearer <token>"
}
- body: {
"name": "Lorem Ipsum",
"unit": "60f1a1f1b9c1a00015e1b1a1",
}
DELETE /employees/:id
- Route to delete a employee by id
- headers: {
"Authorization": "Bearer <token>"
}