Skip to content

Commit

Permalink
push
Browse files Browse the repository at this point in the history
  • Loading branch information
chryzcode committed Jan 13, 2024
1 parent 98d7c85 commit 16115d7
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 29 deletions.
18 changes: 9 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import express from "express";
import "express-async-errors";
import mongoose from "mongoose";

import { getAllComments, getAllReplyComments } from "./controllers/comment";
import { getAllPosts } from "./controllers/post";
import commentRouter from "./routes/comment";
import postRouter from "./routes/post";
import tagRouter from "./routes/tag";
import authRouter from "./routes/user";
import { getAllComments, getAllReplyComments } from "./controllers/comment.js";
import { getAllPosts } from "./controllers/post.js";
import commentRouter from "./routes/comment.js";
import postRouter from "./routes/post.js";
import tagRouter from "./routes/tag.js";
import authRouter from "./routes/user.js";

// error handler
import errorHandlerMiddleware from "./middleware/error-handler";
import notFoundMiddleware from "./middleware/not-found";
import errorHandlerMiddleware from "./middleware/error-handler.js";
import notFoundMiddleware from "./middleware/not-found.js";

import authenticateUser from "./middleware/authentication";
import authenticateUser from "./middleware/authentication.js";

const app = express();
const port = process.env.PORT || 3000;
Expand Down
4 changes: 2 additions & 2 deletions controllers/comment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StatusCodes } from "http-status-codes";
import { Comment, replyComment } from "../models/comment";
import Post from "../models/post";
import { Comment, replyComment } from "../models/comment.js";
import Post from "../models/post.js";

export const createComment = async (req, res) => {
const { postId } = req.params;
Expand Down
4 changes: 2 additions & 2 deletions controllers/post.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StatusCodes } from "http-status-codes";
import { BadRequestError, NotFoundError } from "../errors";
import Post from "../models/post";
import { BadRequestError, NotFoundError } from "../errors/index.js";
import Post from "../models/post.js";

export const createPost = async (req, res) => {
req.body.author = req.user.userId;
Expand Down
2 changes: 1 addition & 1 deletion controllers/tag.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StatusCodes } from "http-status-codes";
import Tag from "../models/tag";
import Tag from "../models/tag.js";

export const createTag = async (req, res) => {
const tag = await Tag.create({ ...req.body });
Expand Down
4 changes: 2 additions & 2 deletions controllers/user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StatusCodes } from "http-status-codes";
import { BadRequestError, UnauthenticatedError } from "../errors/index";
import User from "../models/user";
import { BadRequestError, UnauthenticatedError } from "../errors/index.js";
import User from "../models/user.js";

export const register = async (req, res) => {
const user = await User.create({ ...req.body });
Expand Down
2 changes: 1 addition & 1 deletion errors/bad-request.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StatusCodes } from "http-status-codes";
import CustomAPIError from "./custom-api";
import CustomAPIError from "./custom-api.js";

export default class BadRequestError extends CustomAPIError {
constructor(message) {
Expand Down
8 changes: 4 additions & 4 deletions errors/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BadRequestError from "./bad-request";
import CustomAPIError from "./custom-api";
import NotFoundError from "./not-found";
import UnauthenticatedError from "./unauthenticated";
import BadRequestError from "./bad-request.js";
import CustomAPIError from "./custom-api.js";
import NotFoundError from "./not-found.js";
import UnauthenticatedError from "./unauthenticated.js";

export { CustomAPIError, UnauthenticatedError, NotFoundError, BadRequestError };
2 changes: 1 addition & 1 deletion errors/not-found.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StatusCodes } from "http-status-codes";
import CustomAPIError from "./custom-api";
import CustomAPIError from "./custom-api.js";

export default class NotFoundError extends CustomAPIError {
constructor(message) {
Expand Down
2 changes: 1 addition & 1 deletion errors/unauthenticated.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StatusCodes } from "http-status-codes";
import CustomAPIError from "./custom-api";
import CustomAPIError from "./custom-api.js";

export default class UnauthenticatedError extends CustomAPIError {
constructor(message) {
Expand Down
4 changes: 2 additions & 2 deletions middleware/authentication.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import jwt from "jsonwebtoken";
import { UnauthenticatedError } from "../errors";
import User from "../models/user";
import { UnauthenticatedError } from "../errors/index.js";
import User from "../models/user.js";

export default async (req, res, next) => {
// check header
Expand Down
2 changes: 1 addition & 1 deletion routes/comment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import express from "express";
import { createComment, createReplyComment } from "../controllers/comment";
import { createComment, createReplyComment } from "../controllers/comment.js";

const router = express.Router();

Expand Down
2 changes: 1 addition & 1 deletion routes/post.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import express from "express";
import { createPost, getUserPosts } from "../controllers/post";
import { createPost, getUserPosts } from "../controllers/post.js";

const router = express.Router();
router.route("/").post(createPost);
Expand Down
2 changes: 1 addition & 1 deletion routes/tag.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import express from "express";
import { createTag, getAllTags } from "../controllers/tag";
import { createTag, getAllTags } from "../controllers/tag.js";

const router = express.Router();

Expand Down
2 changes: 1 addition & 1 deletion routes/user.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import express from "express";
import { getAllUsers, login, register } from "../controllers/user";
import { getAllUsers, login, register } from "../controllers/user.js";

const router = express.Router();

Expand Down

0 comments on commit 16115d7

Please sign in to comment.