add route to get all channels
This commit is contained in:
parent
2956bf10fc
commit
3bc166bfb0
2 changed files with 16 additions and 1 deletions
|
@ -122,4 +122,14 @@ router.get(
|
|||
}
|
||||
);
|
||||
|
||||
router.get(
|
||||
"/",
|
||||
authenticateRoute(),
|
||||
async (req, res) => {
|
||||
const result = await query("SELECT id, name, owner_id FROM channels");
|
||||
|
||||
return res.status(200).send(result.rows);
|
||||
}
|
||||
);
|
||||
|
||||
export default router;
|
|
@ -28,7 +28,7 @@ content-type: application/json
|
|||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidHlwZSI6MSwiaWF0IjoxNjQ5MTg3MDc5LCJleHAiOjE2NDkzNTk4Nzl9.tVzJWnBP7IFhA88XRwByKGXQ4cihWdJSoxUkrWHkIVU
|
||||
|
||||
{
|
||||
"name": "my channel"
|
||||
"name": "another channel"
|
||||
}
|
||||
|
||||
###
|
||||
|
@ -52,3 +52,8 @@ Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidHlwZSI6M
|
|||
|
||||
GET http://localhost:3000/api/v1/channels/1 HTTP/1.1
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidHlwZSI6MSwiaWF0IjoxNjQ5MTg3MDc5LCJleHAiOjE2NDkzNTk4Nzl9.tVzJWnBP7IFhA88XRwByKGXQ4cihWdJSoxUkrWHkIVU
|
||||
|
||||
###
|
||||
|
||||
GET http://localhost:3000/api/v1/channels HTTP/1.1
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidHlwZSI6MSwiaWF0IjoxNjQ5MTg3MDc5LCJleHAiOjE2NDkzNTk4Nzl9.tVzJWnBP7IFhA88XRwByKGXQ4cihWdJSoxUkrWHkIVU
|
||||
|
|
Loading…
Reference in a new issue