Compare commits
No commits in common. "3bc166bfb0cb7dcf2a01297c04ff5d3655fbd5d7" and "aa320e1b54a6256adace1f56db114e79f97a2f70" have entirely different histories.
3bc166bfb0
...
aa320e1b54
4 changed files with 7 additions and 18 deletions
|
@ -6,6 +6,8 @@ import { errors } from "../../../errors";
|
|||
|
||||
const router = express.Router();
|
||||
|
||||
router.use(express.json());
|
||||
|
||||
router.post(
|
||||
"/",
|
||||
authenticateRoute(),
|
||||
|
@ -79,6 +81,7 @@ router.delete(
|
|||
return res.status(400).json({ ...errors.INVALID_DATA, errors: validationErrors.array() });
|
||||
}
|
||||
|
||||
const { name } = req.body;
|
||||
const { id } = req.params;
|
||||
|
||||
const permissionCheckResult = await query("SELECT owner_id FROM channels WHERE id = $1", [id]);
|
||||
|
@ -122,14 +125,4 @@ 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;
|
|
@ -7,6 +7,8 @@ import { authenticateRoute, signToken } from "../../../auth";
|
|||
|
||||
const router = express.Router();
|
||||
|
||||
router.use(express.json());
|
||||
|
||||
router.post(
|
||||
"/register",
|
||||
body("username").isLength({ min: 3, max: 32 }).isAlphanumeric("en-US", { ignore: " _-" }),
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { Application, json } from "express";
|
||||
import { Application } from "express";
|
||||
import usersRouter from "./routes/api/v1/users";
|
||||
import channelsRouter from "./routes/api/v1/channels";
|
||||
|
||||
export default function(app: Application) {
|
||||
app.use(json());
|
||||
app.use("/api/v1/users", usersRouter);
|
||||
app.use("/api/v1/channels", channelsRouter);
|
||||
};
|
||||
|
|
|
@ -28,7 +28,7 @@ content-type: application/json
|
|||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidHlwZSI6MSwiaWF0IjoxNjQ5MTg3MDc5LCJleHAiOjE2NDkzNTk4Nzl9.tVzJWnBP7IFhA88XRwByKGXQ4cihWdJSoxUkrWHkIVU
|
||||
|
||||
{
|
||||
"name": "another channel"
|
||||
"name": "my channel"
|
||||
}
|
||||
|
||||
###
|
||||
|
@ -52,8 +52,3 @@ 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