[lint] linting
This commit is contained in:
@@ -2,8 +2,8 @@ const crypto = require('crypto')
|
||||
const moment = require('moment-timezone')
|
||||
const { Op } = require('sequelize')
|
||||
const lodash = require('lodash')
|
||||
const { event: Event, comment: Comment, tag: Tag, place: Place,
|
||||
user: User, notification: Notification, event_notification: EventNotification } = require('../models')
|
||||
const { event: Event, comment: Comment, tag: Tag, place: Place,
|
||||
user: User, notification: Notification } = require('../models')
|
||||
const Sequelize = require('sequelize')
|
||||
const exportController = require('./export')
|
||||
const debug = require('debug')('controller:event')
|
||||
@@ -142,7 +142,7 @@ const eventController = {
|
||||
async unconfirm (req, res) {
|
||||
const id = Number(req.params.event_id)
|
||||
const event = await Event.findByPk(id)
|
||||
if (!event) { return sendStatus(404) }
|
||||
if (!event) { return req.sendStatus(404) }
|
||||
|
||||
try {
|
||||
event.is_visible = false
|
||||
@@ -219,7 +219,7 @@ const eventController = {
|
||||
{ start_datetime: { [Op.between]: [start.unix(), end.unix()] } }
|
||||
]
|
||||
},
|
||||
attributes: { exclude: ['createdAt', 'updatedAt', 'placeId' ] },
|
||||
attributes: { exclude: [ 'createdAt', 'updatedAt', 'placeId' ] },
|
||||
order: [[Tag, 'weigth', 'DESC']],
|
||||
include: [
|
||||
{ model: Comment, required: false, attributes: ['id'] },
|
||||
|
||||
@@ -65,7 +65,7 @@ const exportController = {
|
||||
url: `${req.settings.baseurl}/event/${e.id}`,
|
||||
alarms: [{
|
||||
action: 'display',
|
||||
trigger: {hours: 1, before: true}
|
||||
trigger: { hours: 1, before: true }
|
||||
}]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -200,7 +200,7 @@ const userController = {
|
||||
},
|
||||
|
||||
async current (req, res) {
|
||||
if (!req.user) return res.status(400).send('Not logged')
|
||||
if (!req.user) { return res.status(400).send('Not logged') }
|
||||
const user = await User.findByPk(req.user.id, { include: { model: FedUsers, as: 'followers' } })
|
||||
res.json(user)
|
||||
},
|
||||
@@ -214,7 +214,7 @@ const userController = {
|
||||
|
||||
async update (req, res) {
|
||||
// user to modify
|
||||
user = await User.findByPk(req.body.id)
|
||||
const user = await User.findByPk(req.body.id)
|
||||
|
||||
if (!user) { return res.status(404).json({ success: false, message: 'User not found!' }) }
|
||||
|
||||
|
||||
@@ -21,16 +21,16 @@ api.use(cookieParser())
|
||||
api.use(bodyParser.urlencoded({ extended: false }))
|
||||
api.use(bodyParser.json())
|
||||
|
||||
const jwt = expressJwt({
|
||||
secret: config.secret,
|
||||
credentialsRequired: false,
|
||||
})
|
||||
// const jwt = expressJwt({
|
||||
// secret: config.secret,
|
||||
// credentialsRequired: false
|
||||
// })
|
||||
|
||||
// api.use(jwt)
|
||||
|
||||
// AUTH
|
||||
api.post('/auth/login', userController.login)
|
||||
api.get('/auth/user', fillUser, userController.current)
|
||||
api.get('/auth/user', fillUser, userController.current)
|
||||
|
||||
api.post('/user/recover', userController.forgotPassword)
|
||||
api.post('/user/check_recover_code', userController.checkRecoverCode)
|
||||
@@ -38,7 +38,7 @@ api.post('/user/recover_password', userController.updatePasswordWithRecoverCode)
|
||||
|
||||
// register and add users
|
||||
api.post('/user/register', userController.register)
|
||||
api.post('/user', isAuth, isAdmin, userController.create)
|
||||
api.post('/user', isAuth, isAdmin, userController.create)
|
||||
|
||||
// update user
|
||||
api.put('/user', isAuth, userController.update)
|
||||
@@ -95,7 +95,6 @@ api.get('/export/:type', exportController.export)
|
||||
// get events in this range
|
||||
api.get('/event/:month/:year', eventController.getAll)
|
||||
|
||||
|
||||
// Handle 404
|
||||
api.use((req, res) => {
|
||||
debug('404 Page not found: %s', req.path)
|
||||
|
||||
@@ -76,7 +76,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
cc: follower || [],
|
||||
content,
|
||||
summary: null,
|
||||
sensitive: false,
|
||||
sensitive: false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,5 +10,5 @@ module.exports = (sequelize, DataTypes) => {
|
||||
}
|
||||
}, {})
|
||||
|
||||
return event_notification
|
||||
return event_notification
|
||||
}
|
||||
|
||||
@@ -6,8 +6,9 @@ module.exports = (sequelize, DataTypes) => {
|
||||
},
|
||||
object: DataTypes.JSON
|
||||
}, {})
|
||||
fed_users.associate = function(models) {
|
||||
fed_users.associate = function (models) {
|
||||
fed_users.belongsTo(models.instances)
|
||||
// associations can be defined here
|
||||
};
|
||||
}
|
||||
return fed_users
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ let sequelize = null
|
||||
|
||||
try {
|
||||
sequelize = new Sequelize(config.db)
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
consola.warn(` ⚠️ Cannot connect to db, check your configuration => ${e}`)
|
||||
process.exit(-1)
|
||||
}
|
||||
|
||||
15
server/api/models/instances.js
Normal file
15
server/api/models/instances.js
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict'
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const instances = sequelize.define('instances', {
|
||||
domain: DataTypes.STRING,
|
||||
name: DataTypes.STRING,
|
||||
blocked: DataTypes.BOOLEAN,
|
||||
data: DataTypes.JSON
|
||||
}, {})
|
||||
|
||||
instances.associate = function (models) {
|
||||
instances.hasMany(models.fed_users)
|
||||
}
|
||||
|
||||
return instances
|
||||
}
|
||||
@@ -7,7 +7,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
index: true,
|
||||
primaryKey: true
|
||||
},
|
||||
weigth: { type: DataTypes.INTEGER, defaultValue: 0, allowNull: false },
|
||||
weigth: { type: DataTypes.INTEGER, defaultValue: 0, allowNull: false }
|
||||
}, {})
|
||||
|
||||
tag.associate = function (models) {
|
||||
|
||||
@@ -27,7 +27,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
recover_code: DataTypes.STRING,
|
||||
is_admin: DataTypes.BOOLEAN,
|
||||
is_active: DataTypes.BOOLEAN,
|
||||
rsa: DataTypes.JSON,
|
||||
rsa: DataTypes.JSON
|
||||
}, {
|
||||
scopes: {
|
||||
withoutPassword: {
|
||||
|
||||
Reference in New Issue
Block a user