diff --git a/src/routes/api/v1/channels.ts b/src/routes/api/v1/channels.ts index 0352c07..7ab2a5f 100644 --- a/src/routes/api/v1/channels.ts +++ b/src/routes/api/v1/channels.ts @@ -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; \ No newline at end of file diff --git a/test.rest b/test.rest index c10fe23..4911d6f 100644 --- a/test.rest +++ b/test.rest @@ -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