move json middleware use call into server object
This commit is contained in:
parent
144a46fa3c
commit
2956bf10fc
3 changed files with 2 additions and 5 deletions
|
@ -6,8 +6,6 @@ import { errors } from "../../../errors";
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.use(express.json());
|
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"/",
|
"/",
|
||||||
authenticateRoute(),
|
authenticateRoute(),
|
||||||
|
|
|
@ -7,8 +7,6 @@ import { authenticateRoute, signToken } from "../../../auth";
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.use(express.json());
|
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"/register",
|
"/register",
|
||||||
body("username").isLength({ min: 3, max: 32 }).isAlphanumeric("en-US", { ignore: " _-" }),
|
body("username").isLength({ min: 3, max: 32 }).isAlphanumeric("en-US", { ignore: " _-" }),
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import { Application } from "express";
|
import { Application, json } from "express";
|
||||||
import usersRouter from "./routes/api/v1/users";
|
import usersRouter from "./routes/api/v1/users";
|
||||||
import channelsRouter from "./routes/api/v1/channels";
|
import channelsRouter from "./routes/api/v1/channels";
|
||||||
|
|
||||||
export default function(app: Application) {
|
export default function(app: Application) {
|
||||||
|
app.use(json());
|
||||||
app.use("/api/v1/users", usersRouter);
|
app.use("/api/v1/users", usersRouter);
|
||||||
app.use("/api/v1/channels", channelsRouter);
|
app.use("/api/v1/channels", channelsRouter);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue