Cleanup and renaming

This commit is contained in:
Elliot DeNolf
2019-03-19 23:57:19 -04:00
parent e5b9601f76
commit bba94a4415
9 changed files with 28 additions and 22 deletions

View File

@@ -10,7 +10,7 @@ const responseBody = res => res.body;
const setJwt = () => {
const jwt = cookies.get('token');
return jwt ? { 'Authorization': `JWT ${jwt}` } : {}
}
};
const requests = {
get: (url, params) => {

View File

@@ -18,7 +18,6 @@ export default User => ({
user.authenticate(password, (authErr, model, passwordError) => {
if (authErr || passwordError) return res.status(401).json({ message: 'Auth Failed' });
console.log('Correct password. Generating token.');
let opts = {};
opts.expiresIn = process.env.tokenExpiration || 7200; // 20min default expiration
const secret = process.env.secret || 'SECRET_KEY';

View File

@@ -21,7 +21,7 @@ function upload(req, res, next, config) {
if (req.files.file.mimetype.split('/')[0] === 'image') {
resize(config, req.files.file);
}
res.send('File uploaded.');
res.status(200).send('File uploaded.');
})
}

View File

@@ -82,7 +82,6 @@ export default function internationalization(schema, options) {
return value;
})
.set(function (value) {
;
// multiple locales are set as an object
if (typeof value === 'object') {
let locales = this.schema.options.mongooseIntl.locales;

View File

@@ -4,7 +4,7 @@ const create = (req, res) => {
req.model.setDefaultLocale(req.locale); // TODO - move to middleware
req.model.create(req.body, (err, result) => {
if (err)
return res.send(httpStatus.INTERNAL_SERVER_ERROR, { error: err });
return res.status(httpStatus.INTERNAL_SERVER_ERROR).json({ error: err });
return res.status(httpStatus.CREATED)
.json({