move json middleware use call into server object

This commit is contained in:
hippoz 2022-04-06 21:27:52 +03:00
parent 144a46fa3c
commit 2956bf10fc
Signed by: hippoz
GPG key ID: 7C52899193467641
3 changed files with 2 additions and 5 deletions

View file

@ -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(),

View file

@ -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: " _-" }),

View file

@ -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);
}; };