Add prettier to api

This commit is contained in:
2020-11-11 21:26:11 -06:00
parent 0193935d2d
commit 7706f525cf
11 changed files with 90 additions and 87 deletions

View File

@@ -1,9 +1,7 @@
const express = require(`express`);
const app = express();
const passport = require(`passport`);
const {
users
} = require(`./controllers`);
const { users } = require(`./controllers`);
/**
* Configure Passport
@@ -37,10 +35,8 @@ app.use(express.json());
// Since Express doesn't support error handling of promises out of the box,
// this handler enables that
const asyncHandler = fn => (req, res, next) => {
return Promise
.resolve(fn(req, res, next))
.catch(next);
const asyncHandler = (fn) => (req, res, next) => {
return Promise.resolve(fn(req, res, next)).catch(next);
};
/**
@@ -63,7 +59,11 @@ app.get(`/test/`, (req, res) => {
* Routes - Protected
*/
app.post(`/user`, passport.authenticate(`jwt`, { session: false }), asyncHandler(users.get));
app.post(
`/user`,
passport.authenticate(`jwt`, { session: false }),
asyncHandler(users.get)
);
/**
* Routes - Catch-All
@@ -78,7 +78,9 @@ app.get(`/*`, (req, res) => {
*/
app.use(function (err, req, res) {
console.error(err);
res.status(500).json({ error: `Internal Serverless Error - "${err.message}"` });
res.status(500).json({
error: `Internal Serverless Error - "${err.message}"`,
});
});
module.exports = app;