feat: init

This commit is contained in:
montaghanmy
2023-03-23 11:03:16 +01:00
commit 10fe6f78d1
11518 changed files with 509786 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
# Sample HTTP Requests
Files in this folder works with the [REST Client VSCode extension](https://github.com/Huachao/vscode-restclient).
+19
View File
@@ -0,0 +1,19 @@
@company_id = bcfe2f79-8e81-42a3-b551-3a32d49b2b4c
@workspace_id = 3328552c-5ccd-4172-b84a-d876d56aa71b
@user_id = 3328552c-5ccd-4172-b84a-d876d56aa71c
@baseURL = http://localhost:3000
@badgesURL = {{baseURL}}/internal/services/notifications/v1/badges
# @name login
GET {{baseURL}}/api/auth/login
@authToken = {{login.response.body.token}}
@currentUserId = {{login.response.body.user.id}}
### List badges with all websockets
GET {{badgesURL}}/?company_id={{company_id}}&websockets=true&limit=5
Content-Type: application/json
Authorization: Bearer {{authToken}}
@@ -0,0 +1,61 @@
@company_id = bcfe2f79-8e81-42a3-b551-3a32d49b2b4c
@workspace_id = 3328552c-5ccd-4172-b84a-d876d56aa71b
@user_id = 3328552c-5ccd-4172-b84a-d876d56aa71c
@baseURL = http://localhost:3000
@channelsURL = {{baseURL}}/internal/services/channels/v1/companies/{{company_id}}/workspaces/{{workspace_id}}
@directChannelsURL = {{baseURL}}/internal/services/channels/v1/companies/{{company_id}}/workspaces/direct
# @name login
GET {{baseURL}}/api/auth/login
@authToken = {{login.response.body.token}}
@currentUserId = {{login.response.body.user.id}}
### Create a channel
# @name createChannel
POST {{channelsURL}}/channels
Content-Type: application/json
Authorization: Bearer {{authToken}}
{
"resource": {
"name": "My channel",
"icon": "twake logo",
"description": "This channel allow twake's team to chat easily",
"channel_group": "twake",
"visibility": "public",
"is_default": true,
"archived": false
}
}
### Get a single channel
@getId = {{createChannel.response.body.resource.id}}
GET {{channelsURL}}/channels/{{getId}}
Authorization: Bearer {{authToken}}
### Add current user as member to a channel (join channel)
POST {{channelsURL}}/channels/{{getId}}/members
Content-Type: application/json
Authorization: Bearer {{authToken}}
{
"resource": {
"user_id": "{{currentUserId}}"
}
}
### Mark the channel as read/unread
POST {{channelsURL}}/channels/{{getId}}/read
Content-Type: application/json
Authorization: Bearer {{authToken}}
{
"value": true
}
+133
View File
@@ -0,0 +1,133 @@
@company_id = bcfe2f79-8e81-42a3-b551-3a32d49b2b4c
@workspace_id = 3328552c-5ccd-4172-b84a-d876d56aa71b
@user_id = 3328552c-5ccd-4172-b84a-d876d56aa71c
@baseURL = http://localhost:3000
@channelsURL = {{baseURL}}/internal/services/channels/v1/companies/{{company_id}}/workspaces/{{workspace_id}}
@directChannelsURL = {{baseURL}}/internal/services/channels/v1/companies/{{company_id}}/workspaces/direct
# @name login
GET {{baseURL}}/api/auth/login
@authToken = {{login.response.body.token}}
@currentUserId = {{login.response.body.user.id}}
### List workspace channels with all websockets
GET {{channelsURL}}/channels?websockets=true&limit=5
Content-Type: application/json
Authorization: Bearer {{authToken}}
### List user channels with all websockets
@authToken = {{login.response.body.token}}
GET {{channelsURL}}/channels?websockets=true&mine=true&limit=5
Content-Type: application/json
Authorization: Bearer {{authToken}}
### Create a channel
# @name createChannel
POST {{channelsURL}}/channels
Content-Type: application/json
Authorization: Bearer {{authToken}}
{
"resource": {
"name": "My channel",
"icon": "twake logo",
"description": "This channel allow twake's team to chat easily",
"channel_group": "twake",
"visibility": "public",
"is_default": true,
"archived": false
}
}
### Get a single channel
@getId = {{createChannel.response.body.resource.id}}
GET {{channelsURL}}/channels/{{getId}}
Authorization: Bearer {{authToken}}
### Update a channel
@updateId = {{createChannel.response.body.resource.id}}
POST {{channelsURL}}/channels/{{updateId}}
Content-Type: application/json
Authorization: Bearer {{authToken}}
{
"resource": {
"name": "My channel",
"description": "Hello world",
"is_default": false
}
}
### Delete a channel
@deleteId = {{createChannel.response.body.resource.id}}
DELETE {{channelsURL}}/channels/{{deleteId}}
Authorization: Bearer {{authToken}}
### Get all channel members
GET {{channelsURL}}/channels/{{getId}}/members?websockets=true
Content-Type: application/json
Authorization: Bearer {{authToken}}
### Add current user as member to a channel (join channel)
POST {{channelsURL}}/channels/{{getId}}/members
Content-Type: application/json
Authorization: Bearer {{authToken}}
{
"resource": {
"user_id": "{{currentUserId}}"
}
}
### Get a channel member
GET {{channelsURL}}/channels/{{getId}}/members/{{currentUserId}}
Content-Type: application/json
Authorization: Bearer {{authToken}}
### Update current channel member
POST {{channelsURL}}/channels/{{getId}}/members/{{currentUserId}}
Content-Type: application/json
Authorization: Bearer {{authToken}}
{
"resource": {
"favorite": true,
"notification_level": "none",
"hello": 1
}
}
### Current user quits the channel
DELETE {{channelsURL}}/channels/{{getId}}/members/{{currentUserId}}
Content-Type: application/json
Authorization: Bearer {{authToken}}
### Errors Tests
### Call without the JWT token should HTTP 401
GET {{channelsURL}}/channels
Content-Type: application/json
### Get a channel which may not exists
GET {{channelsURL}}/channels/0b0e1492-f596-46b9-a4fb-c12d71b2696e
Authorization: Bearer {{authToken}}
@@ -0,0 +1,163 @@
@company_id = bcfe2f79-8e81-42a3-b551-3a32d49b2b4c
@workspace_id = 3328552c-5ccd-4172-b84a-d876d56aa71b
@baseURL = http://localhost:3000
@channelsURL = {{baseURL}}/internal/services/channels/v1/companies/{{company_id}}/workspaces/{{workspace_id}}
@directChannelsURL = {{baseURL}}/internal/services/channels/v1/companies/{{company_id}}/workspaces/direct
### Login as user 1
# @name login
GET {{baseURL}}/api/auth/login
@authToken1 = {{login.response.body.token}}
@userId1 = {{login.response.body.user.id}}
### Login as user 2
# @name login2
GET {{baseURL}}/api/auth/login
@authToken2 = {{login2.response.body.token}}
@userId2 = {{login2.response.body.user.id}}
### Login as user 3
# @name login3
GET {{baseURL}}/api/auth/login
@authToken3 = {{login3.response.body.token}}
@userId3 = {{login3.response.body.user.id}}
### Create a direct channel
# @name createDirectChannel
POST {{directChannelsURL}}/channels
Content-Type: application/json
Authorization: Bearer {{authToken1}}
{
"options": {
"members": ["{{userId2}}"]
},
"resource": {
"icon": "hello",
"description": "A direct channel",
"channel_group": "twake",
"is_default": false,
"archived": false
}
}
### Direct channel details as user 1 should work
@directId = {{createDirectChannel.response.body.resource.id}}
GET {{directChannelsURL}}/channels/{{directId}}
Content-Type: application/json
Authorization: Bearer {{authToken1}}
### Direct channel details as user 2 (member) should work
GET {{directChannelsURL}}/channels/{{directId}}
Content-Type: application/json
Authorization: Bearer {{authToken2}}
### Direct channel details as user 3 (not member) should not work
GET {{directChannelsURL}}/channels/{{directId}}
Content-Type: application/json
Authorization: Bearer {{authToken3}}
### Direct channel members
GET {{directChannelsURL}}/channels/{{directId}}/members?websockets=true
Content-Type: application/json
Authorization: Bearer {{authToken1}}
### List direct channels for user in company
@authToken = {{login.response.body.token}}
GET {{directChannelsURL}}/channels?websockets=true&limit=5
Content-Type: application/json
Authorization: Bearer {{authToken1}}
### Update the direct channel description
POST {{directChannelsURL}}/channels/{{directId}}
Content-Type: application/json
Authorization: Bearer {{authToken1}}
{
"resource": {
"description": "A new direct channel description"
}
}
### Update the direct channel name will do nothing since the name is useless
POST {{directChannelsURL}}/channels/{{directId}}
Content-Type: application/json
Authorization: Bearer {{authToken1}}
{
"resource": {
"name": "A new direct channel name"
}
}
### Update the direct channel member settings for current user
POST {{directChannelsURL}}/channels/{{directId}}/members/{{userId1}}
Content-Type: application/json
Authorization: Bearer {{authToken1}}
{
"resource": {
"favorite": true,
"notification_level": "all"
}
}
### Update another user member settings should fail
POST {{directChannelsURL}}/channels/{{directId}}/members/{{userId2}}
Content-Type: application/json
Authorization: Bearer {{authToken1}}
{
"resource": {
"favorite": true,
"notification_level": "none"
}
}
### Get member settings as user1
GET {{directChannelsURL}}/channels/{{directId}}/members/{{userId1}}
Content-Type: application/json
Authorization: Bearer {{authToken1}}
### Get member settings as user2
GET {{directChannelsURL}}/channels/{{directId}}/members/{{userId2}}
Content-Type: application/json
Authorization: Bearer {{authToken2}}
### Get other member settings should fail
GET {{directChannelsURL}}/channels/{{directId}}/members/{{userId2}}
Content-Type: application/json
Authorization: Bearer {{authToken1}}
### Leave a direct channel of another user should fail
DELETE {{directChannelsURL}}/channels/{{directId}}/members/{{userId2}}
Content-Type: application/json
Authorization: Bearer {{authToken1}}
### Leave a direct channel should not fail
DELETE {{directChannelsURL}}/channels/{{directId}}/members/{{userId1}}
Content-Type: application/json
Authorization: Bearer {{authToken1}}
@@ -0,0 +1,108 @@
@company_id = bcfe2f79-8e81-42a3-b551-3a32d49b2b4c
@workspace_id = 3328552c-5ccd-4172-b84a-d876d56aa71b
@baseURL = http://localhost:3000
@channelsURL = {{baseURL}}/internal/services/channels/v1/companies/{{company_id}}/workspaces/{{workspace_id}}
@directChannelsURL = {{baseURL}}/internal/services/channels/v1/companies/{{company_id}}/workspaces/direct
### Login as user 1
# @name login
GET {{baseURL}}/api/auth/login
@authTokenUser1 = {{login.response.body.token}}
@currentUserId1 = {{login.response.body.user.id}}
### Login as user 2
# @name login2
GET {{baseURL}}/api/auth/login
@authTokenUser2 = {{login2.response.body.token}}
@currentUserId2 = {{login2.response.body.user.id}}
### User 1 creates a private channel
# @name createChannel
POST {{channelsURL}}/channels
Content-Type: application/json
Authorization: Bearer {{authTokenUser1}}
{
"resource": {
"name": "My private channel",
"icon": "twake logo",
"description": "This channel allow twake's team to chat easily",
"channel_group": "twake",
"visibility": "private",
"is_default": true,
"archived": false
}
}
### Get the private channel
@getId = {{createChannel.response.body.resource.id}}
GET {{channelsURL}}/channels/{{getId}}
Authorization: Bearer {{authTokenUser1}}
### Get all channel members
GET {{channelsURL}}/channels/{{getId}}/members?websockets=true
Content-Type: application/json
Authorization: Bearer {{authTokenUser1}}
### The user 2 tries to join the private channel, this should reject
POST {{channelsURL}}/channels/{{getId}}/members
Content-Type: application/json
Authorization: Bearer {{authTokenUser2}}
{
"resource": {
"user_id": "{{currentUserId2}}"
}
}
### The user 1 adds the user 2 as channel member, this should be OK
POST {{channelsURL}}/channels/{{getId}}/members
Content-Type: application/json
Authorization: Bearer {{authTokenUser1}}
{
"resource": {
"user_id": "{{currentUserId2}}"
}
}
### User 2 lists his channels
GET {{channelsURL}}/channels?websockets=true&mine=true&limit=5
Content-Type: application/json
Authorization: Bearer {{authTokenUser2}}
### Get all channel members as user 1
GET {{channelsURL}}/channels/{{getId}}/members?websockets=true
Content-Type: application/json
Authorization: Bearer {{authTokenUser1}}
### Get all channel members as user 2
GET {{channelsURL}}/channels/{{getId}}/members?websockets=true
Content-Type: application/json
Authorization: Bearer {{authTokenUser2}}
### User 1 leaves the channel he created
DELETE {{channelsURL}}/channels/{{getId}}/members/{{currentUserId1}}
Content-Type: application/json
Authorization: Bearer {{authTokenUser1}}
### User 2 leaves the channel: Error since he is the last member, he can not leave
DELETE {{channelsURL}}/channels/{{getId}}/members/{{currentUserId2}}
Content-Type: application/json
Authorization: Bearer {{authTokenUser2}}
@@ -0,0 +1,70 @@
@company_id = bcfe2f79-8e81-42a3-b551-3a32d49b2b4c
@workspace_id = 3328552c-5ccd-4172-b84a-d876d56aa71b
@user_id = 3328552c-5ccd-4172-b84a-d876d56aa71c
@baseURL = http://localhost:3000
@channelsURL = {{baseURL}}/internal/services/channels/v1/companies/{{company_id}}/workspaces/{{workspace_id}}
@directChannelsURL = {{baseURL}}/internal/services/channels/v1/companies/{{company_id}}/workspaces/direct
# @name login
GET {{baseURL}}/api/auth/login
@authToken = {{login.response.body.token}}
@currentUserId = {{login.response.body.user.id}}
### List workspace channels with all websockets
GET {{channelsURL}}/channels?websockets=true&limit=5
Content-Type: application/json
Authorization: Bearer {{authToken}}
### List user channels with all websockets
@authToken = {{login.response.body.token}}
GET {{channelsURL}}/channels?websockets=true&mine=true&limit=5
Content-Type: application/json
Authorization: Bearer {{authToken}}
### Create a private channel
# @name createChannel
POST {{channelsURL}}/channels
Content-Type: application/json
Authorization: Bearer {{authToken}}
{
"resource": {
"name": "My private channel",
"icon": "twake logo",
"description": "A private channel",
"channel_group": "twake",
"visibility": "private",
"is_default": true,
"archived": false
}
}
### Get the private channel
@getId = {{createChannel.response.body.resource.id}}
GET {{channelsURL}}/channels/{{getId}}
Authorization: Bearer {{authToken}}
### Get members of the private channel
GET {{channelsURL}}/channels/{{getId}}/members?websockets=true
Content-Type: application/json
Authorization: Bearer {{authToken}}
### Get current user as member
GET {{channelsURL}}/channels/{{getId}}/members/{{currentUserId}}
Content-Type: application/json
Authorization: Bearer {{authToken}}
### Current user quits the private channel will fail because he is the only one in it
DELETE {{channelsURL}}/channels/{{getId}}/members/{{currentUserId}}
Content-Type: application/json
Authorization: Bearer {{authToken}}
@@ -0,0 +1,108 @@
@company_id = bcfe2f79-8e81-42a3-b551-3a32d49b2b4c
@workspace_id = 3328552c-5ccd-4172-b84a-d876d56aa71b
@baseURL = http://localhost:3000
@channelsURL = {{baseURL}}/internal/services/channels/v1/companies/{{company_id}}/workspaces/{{workspace_id}}
@directChannelsURL = {{baseURL}}/internal/services/channels/v1/companies/{{company_id}}/workspaces/direct
### Login as user 1
# @name login
GET {{baseURL}}/api/auth/login
@authTokenUser1 = {{login.response.body.token}}
@currentUserId1 = {{login.response.body.user.id}}
### Login as user 2
# @name login2
GET {{baseURL}}/api/auth/login
@authTokenUser2 = {{login2.response.body.token}}
@currentUserId2 = {{login2.response.body.user.id}}
### User 1 creates a public channel
# @name createChannel
POST {{channelsURL}}/channels
Content-Type: application/json
Authorization: Bearer {{authTokenUser1}}
{
"resource": {
"name": "A public channel",
"icon": "twake logo",
"description": "This channel allow twake's team to chat easily",
"channel_group": "twake",
"visibility": "public",
"is_default": true,
"archived": false
}
}
### Get the public channel
@getId = {{createChannel.response.body.resource.id}}
GET {{channelsURL}}/channels/{{getId}}
Authorization: Bearer {{authTokenUser1}}
### Get all channel members
GET {{channelsURL}}/channels/{{getId}}/members?websockets=true
Content-Type: application/json
Authorization: Bearer {{authTokenUser1}}
### The user 2 joins the public channel, this should be OK
POST {{channelsURL}}/channels/{{getId}}/members
Content-Type: application/json
Authorization: Bearer {{authTokenUser2}}
{
"resource": {
"user_id": "{{currentUserId2}}"
}
}
### Get all channel members, there are now 2 members
GET {{channelsURL}}/channels/{{getId}}/members?websockets=true
Content-Type: application/json
Authorization: Bearer {{authTokenUser1}}
### User 1 lists his channels
GET {{channelsURL}}/channels?mine=true
Content-Type: application/json
Authorization: Bearer {{authTokenUser1}}
### User 2 lists his channels
GET {{channelsURL}}/channels?mine=true
Content-Type: application/json
Authorization: Bearer {{authTokenUser2}}
### User 2 leaves the channel
DELETE {{channelsURL}}/channels/{{getId}}/members/{{currentUserId2}}
Content-Type: application/json
Authorization: Bearer {{authTokenUser2}}
### Get all channel members, there are now 1 member, the initial one
GET {{channelsURL}}/channels/{{getId}}/members?websockets=true
Content-Type: application/json
Authorization: Bearer {{authTokenUser1}}
### List channels as user 2, current channel appears since it is public
GET {{channelsURL}}/channels
Content-Type: application/json
Authorization: Bearer {{authTokenUser2}}
### User 2 list his public channels, current channel does not appear since he left it
GET {{channelsURL}}/channels?mine=true
Content-Type: application/json
Authorization: Bearer {{authTokenUser2}}
+85
View File
@@ -0,0 +1,85 @@
@company_id = bcfe2f79-8e81-42a3-b551-3a32d49b2b4c
@workspace_id = 3328552c-5ccd-4172-b84a-d876d56aa71a
@baseURL = http://localhost:3000
@tabsURL = {{baseURL}}/internal/services/channels/v1/companies/{{company_id}}/workspaces/{{workspace_id}}/channels
@channelsURL = {{baseURL}}/internal/services/channels/v1/companies/{{company_id}}/workspaces/{{workspace_id}}
# @name login
GET {{baseURL}}/api/auth/login
@authToken = {{login.response.body.token}}
@currentUserId = {{login.response.body.user.id}}
### List channel's tab with all websockets
GET {{tabsURL}}/{{channelId}}/tabs?websockets=true&limit=5
Content-Type: application/json
Authorization: Bearer {{authToken}}
### Create a channel
# @name createChannel
POST {{channelsURL}}/channels
Content-Type: application/json
Authorization: Bearer {{authToken}}
{
"resource": {
"name": "My channel",
"icon": "twake logo",
"description": "This channel allow twake's team to chat easily",
"channel_group": "twake",
"visibility": "public",
"is_default": true,
"archived": false
}
}
### Create a tab
# @name createTab
@channelId = {{createChannel.response.body.resource.id}}
POST {{tabsURL}}/{{channelId}}/tabs
Content-Type: application/json
Authorization: Bearer {{authToken}}
{
"resource": {
// WARNING : special caracter in tab's name does not work
"name": "My tabs name",
"configuration": "JSON"
}
}
### Get a single tab
@getId = {{createTab.response.body.resource.id}}
GET {{tabsURL}}/{{channelId}}/tabs/{{getId}}
Authorization: Bearer {{authToken}}
### Update a tab
@updateId = {{createTab.response.body.resource.id}}
POST {{tabsURL}}/{{channelId}}/tabs/{{updateId}}
Content-Type: application/json
Authorization: Bearer {{authToken}}
{
"resource": {
"name": "My tab updated",
"configuration": "JSON"
}
}
### Delete a tab
@deleteId = {{createTab.response.body.resource.id}}
DELETE {{tabsURL}}/{{channelId}}/tabs/{{deleteId}}
Authorization: Bearer {{authToken}}
+18
View File
@@ -0,0 +1,18 @@
@company_id = bcfe2f79-8e81-42a3-b551-3a32d49b2b4c
@workspace_id = 3328552c-5ccd-4172-b84a-d876d56aa71b
@user_id = 508c8c1a-706f-11eb-b6be-0242ac120002
@baseURL = http://localhost:3000
@usersURL = {{baseURL}}/internal/services/users/v1
# @name login
GET {{baseURL}}/api/auth/login
@authToken = {{login.response.body.token}}
@currentUserId = {{login.response.body.user.id}}
### Get a single user
GET {{usersURL}}/users/{{user_id}}
Content-Type: application/json
Authorization: Bearer {{authToken}}
@@ -0,0 +1,58 @@
@baseURL = http://localhost:8000
@workspacesURL = {{baseURL}}/internal/services/workspaces/v1
@usersURL = {{baseURL}}/internal/services/users/v1
@company_id = 357d0f1c-9dc9-11eb-ae20-0242ac120002
@workspace_id = 361a5be0-f509-11eb-a69b-d9862196e0cd
@user_id = ca68bc2a-81a4-11eb-8cf1-0242ac1e0002
# @name login
POST {{baseURL}}/internal/services/console/v1/login
Content-Type: application/json
{
"email": "",
"password": ""
}
### AUTH - GET TOKEN
@authToken = {{login.response.body.access_token.value}}
### USERS - GET
GET {{usersURL}}/users/{{user_id}}
Content-Type: application/json
Authorization: Bearer {{authToken}}
### WORKSPACES - LIST
GET {{workspacesURL}}/companies/{{company_id}}/workspaces
Content-Type: application/json
Authorization: Bearer {{authToken}}
### WORKSPACES - CREATE
POST {{workspacesURL}}/companies/{{company_id}}/workspaces
Content-Type: application/json
Authorization: Bearer {{authToken}}
{
"resource": {
"name": "created workspace",
"logo": "",
"default": false,
"archived": false
}
}
### WORKSPACES - UPDATE
POST {{workspacesURL}}/companies/{{company_id}}/workspaces/{{workspace_id}}
Content-Type: application/json
Authorization: Bearer {{authToken}}
{
"resource": {
"name": "updated workspace",
"logo": "",
"default": false,
"archived": false
}
}