mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
updated to express 4
This commit is contained in:
parent
d5e3f9b4c8
commit
2afc0894bc
5 changed files with 1209 additions and 475 deletions
|
@ -81,7 +81,7 @@ module.exports = MessageHttpController = {
|
|||
if (error != null) {
|
||||
return next(error)
|
||||
}
|
||||
return res.send(204)
|
||||
return res.sendStatus(204)
|
||||
})
|
||||
}, // No content
|
||||
|
||||
|
@ -92,7 +92,7 @@ module.exports = MessageHttpController = {
|
|||
if (error != null) {
|
||||
return next(error)
|
||||
}
|
||||
return res.send(204)
|
||||
return res.sendStatus(204)
|
||||
})
|
||||
}, // No content
|
||||
|
||||
|
@ -110,7 +110,7 @@ module.exports = MessageHttpController = {
|
|||
if (error != null) {
|
||||
return next(error)
|
||||
}
|
||||
return res.send(204)
|
||||
return res.sendStatus(204)
|
||||
})
|
||||
})
|
||||
}, // No content
|
||||
|
@ -138,7 +138,7 @@ module.exports = MessageHttpController = {
|
|||
if (error != null) {
|
||||
return next(error)
|
||||
}
|
||||
return res.send(204)
|
||||
return res.sendStatus(204)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
@ -161,7 +161,7 @@ module.exports = MessageHttpController = {
|
|||
if (error != null) {
|
||||
return next(error)
|
||||
}
|
||||
return res.send(204)
|
||||
return res.status(204).send()
|
||||
})
|
||||
})
|
||||
},
|
||||
|
@ -170,16 +170,15 @@ module.exports = MessageHttpController = {
|
|||
const { user_id, content } = req != null ? req.body : undefined
|
||||
const { project_id } = req.params
|
||||
if (!ObjectId.isValid(user_id)) {
|
||||
return res.send(400, 'Invalid user_id')
|
||||
return res.status(400).send('Invalid user_id')
|
||||
}
|
||||
if (content == null) {
|
||||
return res.send(400, 'No content provided')
|
||||
return res.status(400).send('No content provided')
|
||||
}
|
||||
if (content.length > this.MAX_MESSAGE_LENGTH) {
|
||||
return res.send(
|
||||
400,
|
||||
`Content too long (> ${this.MAX_MESSAGE_LENGTH} bytes)`
|
||||
)
|
||||
return res
|
||||
.status(400)
|
||||
.send(`Content too long (> ${this.MAX_MESSAGE_LENGTH} bytes)`)
|
||||
}
|
||||
logger.log(
|
||||
{ client_thread_id, project_id, user_id, content },
|
||||
|
@ -203,7 +202,7 @@ module.exports = MessageHttpController = {
|
|||
}
|
||||
message = MessageFormatter.formatMessageForClientSide(message)
|
||||
message.room_id = project_id
|
||||
return res.send(201, message)
|
||||
return res.status(201).send(message)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -249,7 +248,7 @@ module.exports = MessageHttpController = {
|
|||
}
|
||||
messages = MessageFormatter.formatMessagesForClientSide(messages)
|
||||
logger.log({ project_id, messages }, 'got messages')
|
||||
return res.send(200, messages)
|
||||
return res.status(200).send(messages)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ module.exports = Router = {
|
|||
if (ObjectId.isValid(project_id)) {
|
||||
return next()
|
||||
} else {
|
||||
return res.send(400, 'Invalid project_id')
|
||||
return res.status(400).send('Invalid project_id')
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -28,7 +28,7 @@ module.exports = Router = {
|
|||
if (ObjectId.isValid(thread_id)) {
|
||||
return next()
|
||||
} else {
|
||||
return res.send(400, 'Invalid thread_id')
|
||||
return res.status(400).send('Invalid thread_id')
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -61,7 +61,7 @@ module.exports = Router = {
|
|||
'/project/:project_id/thread/:thread_id/messages/:message_id/edit',
|
||||
MessageHttpController.editMessage
|
||||
)
|
||||
app.del(
|
||||
app.delete(
|
||||
'/project/:project_id/thread/:thread_id/messages/:message_id',
|
||||
MessageHttpController.deleteMessage
|
||||
)
|
||||
|
@ -74,7 +74,7 @@ module.exports = Router = {
|
|||
'/project/:project_id/thread/:thread_id/reopen',
|
||||
MessageHttpController.reopenThread
|
||||
)
|
||||
app.del(
|
||||
app.delete(
|
||||
'/project/:project_id/thread/:thread_id',
|
||||
MessageHttpController.deleteThread
|
||||
)
|
||||
|
|
|
@ -14,21 +14,25 @@ const logger = require('logger-sharelatex')
|
|||
logger.initialize('chat')
|
||||
const Path = require('path')
|
||||
const express = require('express')
|
||||
const bodyParser = require('body-parser')
|
||||
const errorHandler = require('errorhandler')
|
||||
const morganLogger = require('morgan')
|
||||
const app = express()
|
||||
const server = require('http').createServer(app)
|
||||
const Router = require('./router')
|
||||
|
||||
app.use(express.bodyParser())
|
||||
app.use(bodyParser.json())
|
||||
app.use(bodyParser.urlencoded({ extended: true }))
|
||||
app.use(metrics.http.monitor(logger))
|
||||
metrics.injectMetricsRoute(app)
|
||||
|
||||
if (app.get('env') === 'development') {
|
||||
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }))
|
||||
app.use(errorHandler({ dumpExceptions: true, showStack: true }))
|
||||
}
|
||||
|
||||
if (app.get('env') === 'production') {
|
||||
app.use(express.logger())
|
||||
app.use(express.errorHandler())
|
||||
app.use(morganLogger('tiny'))
|
||||
app.use(errorHandler())
|
||||
}
|
||||
|
||||
Router.route(app)
|
||||
|
|
1634
services/chat/package-lock.json
generated
1634
services/chat/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -19,10 +19,13 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"async": "3.2.0",
|
||||
"express": "3.3.1",
|
||||
"body-parser": "^1.19.0",
|
||||
"errorhandler": "^1.5.1",
|
||||
"express": "4.17.1",
|
||||
"logger-sharelatex": "^1.9.0",
|
||||
"metrics-sharelatex": "^2.5.0",
|
||||
"mongojs": "3.1.0",
|
||||
"morgan": "^1.9.1",
|
||||
"request": "^2.88.2",
|
||||
"settings-sharelatex": "^1.1.0"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue