https://github.com/servicespack/tasks-api
Microservice for tasks management
https://github.com/servicespack/tasks-api
microservice nodejs tasks typescript
Last synced: about 1 year ago
JSON representation
Microservice for tasks management
- Host: GitHub
- URL: https://github.com/servicespack/tasks-api
- Owner: servicespack
- License: unlicense
- Created: 2022-09-17T13:08:21.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-27T23:18:43.000Z (about 1 year ago)
- Last Synced: 2025-01-28T00:26:48.211Z (about 1 year ago)
- Topics: microservice, nodejs, tasks, typescript
- Language: TypeScript
- Homepage:
- Size: 949 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tasks API
Microservice for tasks management
## Getting started
### Docker
```bash
docker container run \
-p 3000:3000 \
--name tasks-api \
servicespack/tasks-api
```
### Locally
```bash
git clone https://github.com/servicespack/tasks-api.git
cd tasks-api
npm ci
cp .env.variables .env
```
**For development:**
```bash
npm run start:dev
```
**For production:**
```bash
npm run build
npm start
```
## Authorization
Since the Tasks API is a microservice, it does not has the responsibility to manage users and create tokens. So, in a real world the token creation would be outside the Tasks API.
For tests and developmet purposes, you can use the [jwt.io](https://jwt.io) to generate a valid token using the `JWT_SECRET` value that you can find in the `.env` file to sign the payload. The payload should have at least the property `sub` representing the unique id of the user. For exemple:
```json
{
"sub": "110bab5c-0e5c-4d7c-932c-498be2dcfe7a"
}
```
## API
### Healthcheck
> **GET `/health`**
**Response 200:**
```json
{
"server": true,
"database": true
}
```
### Create task
> **POST `/tasks`**
**Headers:**
```json
{
"Authorization": "Bearer eyJhbGciOiJIUzI1..."
}
```
**Body:**
```json
{
"title": "Complete the challange",
"description": "Create a Tasks API with tests, documentation, typescript, etc.."
}
```
**Response 201:**
```json
{
"id": 1,
"title": "Complete the challange",
"description": "Create a Tasks API with tests, documentation, typescript, etc..",
"status": "TO_DO",
"ownerId": "163e8571-127f-4d25-9dd4-79b1f47e780a",
"createdAt": "2022-09-18T18:59:01.231Z",
"updatedAt": "2022-09-18T18:59:01.231Z"
}
```
### Get tasks
> **GET `/tasks`**
**Headers:**
```json
{
"Authorization": "Bearer eyJhbGciOiJIUzI1..."
}
```
**Response 200:**
```json
{
"data": [
{
"id": 1,
"title": "Complete the challange",
"description": "Create a Tasks API with tests, documentation, typescript, etc..",
"status": "TO_DO",
"ownerId": "163e8571-127f-4d25-9dd4-79b1f47e780a",
"createdAt": "2022-09-18T18:59:01.231Z",
"updatedAt": "2022-09-18T18:59:01.231Z"
}
],
"total": 1
}
```
### Update task
> **PATCH `/tasks/:taskId`**
**Headers:**
```json
{
"Authorization": "Bearer eyJhbGciOiJIUzI1..."
}
```
**Body:**
```json
{
"status": "IN_PROGRESS"
}
```
**Response 200:**
```json
{
"id": 1,
"title": "Complete the challange",
"description": "Create a Tasks API with tests, documentation, typescript, etc..",
"status": "IN_PROGRESS",
"ownerId": "163e8571-127f-4d25-9dd4-79b1f47e780a",
"createdAt": "2022-09-18T18:59:01.231Z",
"updatedAt": "2022-09-18T18:59:01.231Z"
}
```