@raymanselltickets/common 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { CustomError } from '
|
|
1
|
+
import { CustomError } from '../errors/custom-error.js';
|
|
2
2
|
export function errorHandler(err, req, res, next) {
|
|
3
3
|
if (err instanceof CustomError) {
|
|
4
4
|
return res.status(err.statusCode).send({ errors: err.serializeErrors() });
|
|
5
5
|
}
|
|
6
|
+
console.error(err);
|
|
6
7
|
res.status(400).send({
|
|
7
8
|
errors: [
|
|
8
9
|
{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NotAuthorizedError } from '
|
|
1
|
+
import { NotAuthorizedError } from '../errors/not-authorized-error.js';
|
|
2
2
|
export const requireAuth = (req, res, next) => {
|
|
3
3
|
if (!req.currentUser) {
|
|
4
4
|
throw new NotAuthorizedError();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { validationResult } from 'express-validator';
|
|
2
|
-
import { RequestValidationError } from '
|
|
2
|
+
import { RequestValidationError } from '../errors/request-validation-error.js';
|
|
3
3
|
export const validateRequest = (req, res, next) => {
|
|
4
4
|
const errors = validationResult(req);
|
|
5
5
|
if (!errors.isEmpty()) {
|