mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
[misc] bump the dev-env to 3.3.2
This commit is contained in:
parent
512cb5df79
commit
e992166680
27 changed files with 199 additions and 280 deletions
|
@ -1,7 +1,6 @@
|
||||||
// this file was auto-generated, do not edit it directly.
|
// this file was auto-generated, do not edit it directly.
|
||||||
// instead run bin/update_build_scripts from
|
// instead run bin/update_build_scripts from
|
||||||
// https://github.com/sharelatex/sharelatex-dev-environment
|
// https://github.com/sharelatex/sharelatex-dev-environment
|
||||||
// Version: 1.4.0
|
|
||||||
{
|
{
|
||||||
"extends": [
|
"extends": [
|
||||||
"standard",
|
"standard",
|
||||||
|
@ -9,7 +8,7 @@
|
||||||
"prettier/standard"
|
"prettier/standard"
|
||||||
],
|
],
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 2017
|
"ecmaVersion": 2018
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"mocha",
|
"mocha",
|
||||||
|
|
17
services/chat/.github/dependabot.yml
vendored
Normal file
17
services/chat/.github/dependabot.yml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
|
||||||
|
pull-request-branch-name:
|
||||||
|
# Separate sections of the branch name with a hyphen
|
||||||
|
# Docker images use the branch name and do not support slashes in tags
|
||||||
|
# https://github.com/overleaf/google-ops/issues/822
|
||||||
|
# https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#pull-request-branch-nameseparator
|
||||||
|
separator: "-"
|
||||||
|
|
||||||
|
# Block informal upgrades -- security upgrades use a separate queue.
|
||||||
|
# https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#open-pull-requests-limit
|
||||||
|
open-pull-requests-limit: 0
|
3
services/chat/.gitignore
vendored
3
services/chat/.gitignore
vendored
|
@ -7,3 +7,6 @@ node_modules/
|
||||||
plato/
|
plato/
|
||||||
|
|
||||||
**/*.map
|
**/*.map
|
||||||
|
|
||||||
|
# managed by dev-environment$ bin/update_build_scripts
|
||||||
|
.npmrc
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# This file was auto-generated, do not edit it directly.
|
# This file was auto-generated, do not edit it directly.
|
||||||
# Instead run bin/update_build_scripts from
|
# Instead run bin/update_build_scripts from
|
||||||
# https://github.com/sharelatex/sharelatex-dev-environment
|
# https://github.com/sharelatex/sharelatex-dev-environment
|
||||||
# Version: 1.4.0
|
|
||||||
{
|
{
|
||||||
"semi": false,
|
"semi": false,
|
||||||
"singleQuote": true
|
"singleQuote": true
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# This file was auto-generated, do not edit it directly.
|
# This file was auto-generated, do not edit it directly.
|
||||||
# Instead run bin/update_build_scripts from
|
# Instead run bin/update_build_scripts from
|
||||||
# https://github.com/sharelatex/sharelatex-dev-environment
|
# https://github.com/sharelatex/sharelatex-dev-environment
|
||||||
# Version: 1.4.0
|
|
||||||
|
|
||||||
FROM node:10.21.0 as base
|
FROM node:10.21.0 as base
|
||||||
|
|
||||||
|
@ -12,12 +11,10 @@ FROM base as app
|
||||||
#wildcard as some files may not be in all repos
|
#wildcard as some files may not be in all repos
|
||||||
COPY package*.json npm-shrink*.json /app/
|
COPY package*.json npm-shrink*.json /app/
|
||||||
|
|
||||||
RUN npm install --quiet
|
RUN npm ci --quiet
|
||||||
|
|
||||||
COPY . /app
|
COPY . /app
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FROM base
|
FROM base
|
||||||
|
|
||||||
COPY --from=app /app /app
|
COPY --from=app /app /app
|
||||||
|
|
131
services/chat/Jenkinsfile
vendored
131
services/chat/Jenkinsfile
vendored
|
@ -1,131 +0,0 @@
|
||||||
String cron_string = BRANCH_NAME == "master" ? "@daily" : ""
|
|
||||||
|
|
||||||
pipeline {
|
|
||||||
agent any
|
|
||||||
|
|
||||||
environment {
|
|
||||||
GIT_PROJECT = "chat"
|
|
||||||
JENKINS_WORKFLOW = "chat-sharelatex"
|
|
||||||
TARGET_URL = "${env.JENKINS_URL}blue/organizations/jenkins/${JENKINS_WORKFLOW}/detail/$BRANCH_NAME/$BUILD_NUMBER/pipeline"
|
|
||||||
GIT_API_URL = "https://api.github.com/repos/overleaf/${GIT_PROJECT}/statuses/$GIT_COMMIT"
|
|
||||||
}
|
|
||||||
|
|
||||||
triggers {
|
|
||||||
pollSCM('* * * * *')
|
|
||||||
cron(cron_string)
|
|
||||||
}
|
|
||||||
|
|
||||||
stages {
|
|
||||||
|
|
||||||
stage('Install') {
|
|
||||||
steps {
|
|
||||||
withCredentials([usernamePassword(credentialsId: 'GITHUB_INTEGRATION', usernameVariable: 'GH_AUTH_USERNAME', passwordVariable: 'GH_AUTH_PASSWORD')]) {
|
|
||||||
sh "curl $GIT_API_URL \
|
|
||||||
--data '{ \
|
|
||||||
\"state\" : \"pending\", \
|
|
||||||
\"target_url\": \"$TARGET_URL\", \
|
|
||||||
\"description\": \"Your build is underway\", \
|
|
||||||
\"context\": \"ci/jenkins\" }' \
|
|
||||||
-u $GH_AUTH_USERNAME:$GH_AUTH_PASSWORD"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Build') {
|
|
||||||
steps {
|
|
||||||
sh 'make build'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Linting') {
|
|
||||||
steps {
|
|
||||||
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make format'
|
|
||||||
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make lint'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Unit Tests') {
|
|
||||||
steps {
|
|
||||||
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_unit'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Acceptance Tests') {
|
|
||||||
steps {
|
|
||||||
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_acceptance'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Package and docker push') {
|
|
||||||
steps {
|
|
||||||
sh 'echo ${BUILD_NUMBER} > build_number.txt'
|
|
||||||
sh 'touch build.tar.gz' // Avoid tar warning about files changing during read
|
|
||||||
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make tar'
|
|
||||||
|
|
||||||
withCredentials([file(credentialsId: 'gcr.io_overleaf-ops', variable: 'DOCKER_REPO_KEY_PATH')]) {
|
|
||||||
sh 'docker login -u _json_key --password-stdin https://gcr.io/overleaf-ops < ${DOCKER_REPO_KEY_PATH}'
|
|
||||||
}
|
|
||||||
sh 'DOCKER_REPO=gcr.io/overleaf-ops make publish'
|
|
||||||
sh 'docker logout https://gcr.io/overleaf-ops'
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Publish to s3') {
|
|
||||||
steps {
|
|
||||||
sh 'echo ${BRANCH_NAME}-${BUILD_NUMBER} > build_number.txt'
|
|
||||||
withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
|
|
||||||
s3Upload(file:'build.tar.gz', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/${BUILD_NUMBER}.tar.gz")
|
|
||||||
}
|
|
||||||
withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
|
|
||||||
// The deployment process uses this file to figure out the latest build
|
|
||||||
s3Upload(file:'build_number.txt', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/latest")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
post {
|
|
||||||
always {
|
|
||||||
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_clean'
|
|
||||||
sh 'make clean'
|
|
||||||
}
|
|
||||||
|
|
||||||
success {
|
|
||||||
withCredentials([usernamePassword(credentialsId: 'GITHUB_INTEGRATION', usernameVariable: 'GH_AUTH_USERNAME', passwordVariable: 'GH_AUTH_PASSWORD')]) {
|
|
||||||
sh "curl $GIT_API_URL \
|
|
||||||
--data '{ \
|
|
||||||
\"state\" : \"success\", \
|
|
||||||
\"target_url\": \"$TARGET_URL\", \
|
|
||||||
\"description\": \"Your build succeeded!\", \
|
|
||||||
\"context\": \"ci/jenkins\" }' \
|
|
||||||
-u $GH_AUTH_USERNAME:$GH_AUTH_PASSWORD"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
failure {
|
|
||||||
mail(from: "${EMAIL_ALERT_FROM}",
|
|
||||||
to: "${EMAIL_ALERT_TO}",
|
|
||||||
subject: "Jenkins build failed: ${JOB_NAME}:${BUILD_NUMBER}",
|
|
||||||
body: "Build: ${BUILD_URL}")
|
|
||||||
withCredentials([usernamePassword(credentialsId: 'GITHUB_INTEGRATION', usernameVariable: 'GH_AUTH_USERNAME', passwordVariable: 'GH_AUTH_PASSWORD')]) {
|
|
||||||
sh "curl $GIT_API_URL \
|
|
||||||
--data '{ \
|
|
||||||
\"state\" : \"failure\", \
|
|
||||||
\"target_url\": \"$TARGET_URL\", \
|
|
||||||
\"description\": \"Your build failed\", \
|
|
||||||
\"context\": \"ci/jenkins\" }' \
|
|
||||||
-u $GH_AUTH_USERNAME:$GH_AUTH_PASSWORD"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The options directive is for configuration that applies to the whole job.
|
|
||||||
options {
|
|
||||||
// we'd like to make sure remove old builds, so we don't fill up our storage!
|
|
||||||
buildDiscarder(logRotator(numToKeepStr:'50'))
|
|
||||||
|
|
||||||
// And we'd really like to be sure that this build doesn't hang forever, so let's time it out after:
|
|
||||||
timeout(time: 30, unit: 'MINUTES')
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +1,12 @@
|
||||||
# This file was auto-generated, do not edit it directly.
|
# This file was auto-generated, do not edit it directly.
|
||||||
# Instead run bin/update_build_scripts from
|
# Instead run bin/update_build_scripts from
|
||||||
# https://github.com/sharelatex/sharelatex-dev-environment
|
# https://github.com/sharelatex/sharelatex-dev-environment
|
||||||
# Version: 1.4.0
|
|
||||||
|
|
||||||
BUILD_NUMBER ?= local
|
BUILD_NUMBER ?= local
|
||||||
BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
|
BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
|
||||||
PROJECT_NAME = chat
|
PROJECT_NAME = chat
|
||||||
|
BUILD_DIR_NAME = $(shell pwd | xargs basename | tr -cd '[a-zA-Z0-9_.\-]')
|
||||||
|
|
||||||
DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml
|
DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml
|
||||||
DOCKER_COMPOSE := BUILD_NUMBER=$(BUILD_NUMBER) \
|
DOCKER_COMPOSE := BUILD_NUMBER=$(BUILD_NUMBER) \
|
||||||
BRANCH_NAME=$(BRANCH_NAME) \
|
BRANCH_NAME=$(BRANCH_NAME) \
|
||||||
|
@ -13,39 +14,63 @@ DOCKER_COMPOSE := BUILD_NUMBER=$(BUILD_NUMBER) \
|
||||||
MOCHA_GREP=${MOCHA_GREP} \
|
MOCHA_GREP=${MOCHA_GREP} \
|
||||||
docker-compose ${DOCKER_COMPOSE_FLAGS}
|
docker-compose ${DOCKER_COMPOSE_FLAGS}
|
||||||
|
|
||||||
|
DOCKER_COMPOSE_TEST_ACCEPTANCE = \
|
||||||
|
COMPOSE_PROJECT_NAME=test_acceptance_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE)
|
||||||
|
|
||||||
|
DOCKER_COMPOSE_TEST_UNIT = \
|
||||||
|
COMPOSE_PROJECT_NAME=test_unit_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
docker rmi ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
|
docker rmi ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
|
||||||
docker rmi gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
|
docker rmi gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
|
||||||
|
|
||||||
format:
|
format:
|
||||||
$(DOCKER_COMPOSE) run --rm test_unit npm run format
|
$(DOCKER_COMPOSE) run --rm test_unit npm run --silent format
|
||||||
|
|
||||||
format_fix:
|
format_fix:
|
||||||
$(DOCKER_COMPOSE) run --rm test_unit npm run format:fix
|
$(DOCKER_COMPOSE) run --rm test_unit npm run --silent format:fix
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
$(DOCKER_COMPOSE) run --rm test_unit npm run lint
|
$(DOCKER_COMPOSE) run --rm test_unit npm run --silent lint
|
||||||
|
|
||||||
test: format lint test_unit test_acceptance
|
test: format lint test_unit test_acceptance
|
||||||
|
|
||||||
test_unit:
|
test_unit:
|
||||||
@[ ! -d test/unit ] && echo "chat has no unit tests" || $(DOCKER_COMPOSE) run --rm test_unit
|
ifneq (,$(wildcard test/unit))
|
||||||
|
$(DOCKER_COMPOSE_TEST_UNIT) run --rm test_unit
|
||||||
|
$(MAKE) test_unit_clean
|
||||||
|
endif
|
||||||
|
|
||||||
test_acceptance: test_clean test_acceptance_pre_run test_acceptance_run
|
test_clean: test_unit_clean
|
||||||
|
test_unit_clean:
|
||||||
|
ifneq (,$(wildcard test/unit))
|
||||||
|
$(DOCKER_COMPOSE_TEST_UNIT) down -v -t 0
|
||||||
|
endif
|
||||||
|
|
||||||
test_acceptance_debug: test_clean test_acceptance_pre_run test_acceptance_run_debug
|
test_acceptance: test_acceptance_clean test_acceptance_pre_run test_acceptance_run
|
||||||
|
$(MAKE) test_acceptance_clean
|
||||||
|
|
||||||
|
test_acceptance_debug: test_acceptance_clean test_acceptance_pre_run test_acceptance_run_debug
|
||||||
|
$(MAKE) test_acceptance_clean
|
||||||
|
|
||||||
test_acceptance_run:
|
test_acceptance_run:
|
||||||
@[ ! -d test/acceptance ] && echo "chat has no acceptance tests" || $(DOCKER_COMPOSE) run --rm test_acceptance
|
ifneq (,$(wildcard test/acceptance))
|
||||||
|
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance
|
||||||
|
endif
|
||||||
|
|
||||||
test_acceptance_run_debug:
|
test_acceptance_run_debug:
|
||||||
@[ ! -d test/acceptance ] && echo "chat has no acceptance tests" || $(DOCKER_COMPOSE) run -p 127.0.0.9:19999:19999 --rm test_acceptance npm run test:acceptance -- --inspect=0.0.0.0:19999 --inspect-brk
|
ifneq (,$(wildcard test/acceptance))
|
||||||
|
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run -p 127.0.0.9:19999:19999 --rm test_acceptance npm run test:acceptance -- --inspect=0.0.0.0:19999 --inspect-brk
|
||||||
|
endif
|
||||||
|
|
||||||
test_clean:
|
test_clean: test_acceptance_clean
|
||||||
$(DOCKER_COMPOSE) down -v -t 0
|
test_acceptance_clean:
|
||||||
|
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) down -v -t 0
|
||||||
|
|
||||||
test_acceptance_pre_run:
|
test_acceptance_pre_run:
|
||||||
@[ ! -f test/acceptance/js/scripts/pre-run ] && echo "chat has no pre acceptance tests task" || $(DOCKER_COMPOSE) run --rm test_acceptance test/acceptance/js/scripts/pre-run
|
ifneq (,$(wildcard test/acceptance/js/scripts/pre-run))
|
||||||
|
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance test/acceptance/js/scripts/pre-run
|
||||||
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
|
docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
|
||||||
|
|
|
@ -15,14 +15,14 @@ if (!module.parent) {
|
||||||
const port =
|
const port =
|
||||||
__guard__(
|
__guard__(
|
||||||
settings.internal != null ? settings.internal.chat : undefined,
|
settings.internal != null ? settings.internal.chat : undefined,
|
||||||
x => x.port
|
(x) => x.port
|
||||||
) || 3010
|
) || 3010
|
||||||
const host =
|
const host =
|
||||||
__guard__(
|
__guard__(
|
||||||
settings.internal != null ? settings.internal.chat : undefined,
|
settings.internal != null ? settings.internal.chat : undefined,
|
||||||
x1 => x1.host
|
(x1) => x1.host
|
||||||
) || 'localhost'
|
) || 'localhost'
|
||||||
Server.server.listen(port, host, function(error) {
|
Server.server.listen(port, host, function (error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ module.exports = MessageFormatter = {
|
||||||
},
|
},
|
||||||
|
|
||||||
formatMessagesForClientSide(messages) {
|
formatMessagesForClientSide(messages) {
|
||||||
return Array.from(messages).map(message =>
|
return Array.from(messages).map((message) =>
|
||||||
this.formatMessageForClientSide(message)
|
this.formatMessageForClientSide(message)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -44,7 +44,7 @@ module.exports = MessageFormatter = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const threads = {}
|
const threads = {}
|
||||||
const getThread = function(room) {
|
const getThread = function (room) {
|
||||||
const thread_id = room.thread_id.toString()
|
const thread_id = room.thread_id.toString()
|
||||||
if (threads[thread_id] != null) {
|
if (threads[thread_id] != null) {
|
||||||
return threads[thread_id]
|
return threads[thread_id]
|
||||||
|
|
|
@ -53,12 +53,15 @@ module.exports = MessageHttpController = {
|
||||||
getAllThreads(req, res, next) {
|
getAllThreads(req, res, next) {
|
||||||
const { project_id } = req.params
|
const { project_id } = req.params
|
||||||
logger.log({ project_id }, 'getting all threads')
|
logger.log({ project_id }, 'getting all threads')
|
||||||
return ThreadManager.findAllThreadRooms(project_id, function(error, rooms) {
|
return ThreadManager.findAllThreadRooms(project_id, function (
|
||||||
|
error,
|
||||||
|
rooms
|
||||||
|
) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return next(error)
|
return next(error)
|
||||||
}
|
}
|
||||||
const room_ids = rooms.map(r => r._id)
|
const room_ids = rooms.map((r) => r._id)
|
||||||
return MessageManager.findAllMessagesInRooms(room_ids, function(
|
return MessageManager.findAllMessagesInRooms(room_ids, function (
|
||||||
error,
|
error,
|
||||||
messages
|
messages
|
||||||
) {
|
) {
|
||||||
|
@ -75,20 +78,23 @@ module.exports = MessageHttpController = {
|
||||||
const { project_id, thread_id } = req.params
|
const { project_id, thread_id } = req.params
|
||||||
const { user_id } = req.body
|
const { user_id } = req.body
|
||||||
logger.log({ user_id, project_id, thread_id }, 'marking thread as resolved')
|
logger.log({ user_id, project_id, thread_id }, 'marking thread as resolved')
|
||||||
return ThreadManager.resolveThread(project_id, thread_id, user_id, function(
|
return ThreadManager.resolveThread(
|
||||||
error
|
project_id,
|
||||||
) {
|
thread_id,
|
||||||
if (error != null) {
|
user_id,
|
||||||
return next(error)
|
function (error) {
|
||||||
|
if (error != null) {
|
||||||
|
return next(error)
|
||||||
|
}
|
||||||
|
return res.sendStatus(204)
|
||||||
}
|
}
|
||||||
return res.sendStatus(204)
|
)
|
||||||
})
|
|
||||||
}, // No content
|
}, // No content
|
||||||
|
|
||||||
reopenThread(req, res, next) {
|
reopenThread(req, res, next) {
|
||||||
const { project_id, thread_id } = req.params
|
const { project_id, thread_id } = req.params
|
||||||
logger.log({ project_id, thread_id }, 'reopening thread')
|
logger.log({ project_id, thread_id }, 'reopening thread')
|
||||||
return ThreadManager.reopenThread(project_id, thread_id, function(error) {
|
return ThreadManager.reopenThread(project_id, thread_id, function (error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return next(error)
|
return next(error)
|
||||||
}
|
}
|
||||||
|
@ -99,14 +105,14 @@ module.exports = MessageHttpController = {
|
||||||
deleteThread(req, res, next) {
|
deleteThread(req, res, next) {
|
||||||
const { project_id, thread_id } = req.params
|
const { project_id, thread_id } = req.params
|
||||||
logger.log({ project_id, thread_id }, 'deleting thread')
|
logger.log({ project_id, thread_id }, 'deleting thread')
|
||||||
return ThreadManager.deleteThread(project_id, thread_id, function(
|
return ThreadManager.deleteThread(project_id, thread_id, function (
|
||||||
error,
|
error,
|
||||||
room_id
|
room_id
|
||||||
) {
|
) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return next(error)
|
return next(error)
|
||||||
}
|
}
|
||||||
return MessageManager.deleteAllMessagesInRoom(room_id, function(error) {
|
return MessageManager.deleteAllMessagesInRoom(room_id, function (error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return next(error)
|
return next(error)
|
||||||
}
|
}
|
||||||
|
@ -122,7 +128,7 @@ module.exports = MessageHttpController = {
|
||||||
{ project_id, thread_id, message_id, content },
|
{ project_id, thread_id, message_id, content },
|
||||||
'editing message'
|
'editing message'
|
||||||
)
|
)
|
||||||
return ThreadManager.findOrCreateThread(project_id, thread_id, function(
|
return ThreadManager.findOrCreateThread(project_id, thread_id, function (
|
||||||
error,
|
error,
|
||||||
room
|
room
|
||||||
) {
|
) {
|
||||||
|
@ -134,7 +140,7 @@ module.exports = MessageHttpController = {
|
||||||
message_id,
|
message_id,
|
||||||
content,
|
content,
|
||||||
Date.now(),
|
Date.now(),
|
||||||
function(error) {
|
function (error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return next(error)
|
return next(error)
|
||||||
}
|
}
|
||||||
|
@ -147,14 +153,14 @@ module.exports = MessageHttpController = {
|
||||||
deleteMessage(req, res, next) {
|
deleteMessage(req, res, next) {
|
||||||
const { project_id, thread_id, message_id } = req.params
|
const { project_id, thread_id, message_id } = req.params
|
||||||
logger.log({ project_id, thread_id, message_id }, 'deleting message')
|
logger.log({ project_id, thread_id, message_id }, 'deleting message')
|
||||||
return ThreadManager.findOrCreateThread(project_id, thread_id, function(
|
return ThreadManager.findOrCreateThread(project_id, thread_id, function (
|
||||||
error,
|
error,
|
||||||
room
|
room
|
||||||
) {
|
) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return next(error)
|
return next(error)
|
||||||
}
|
}
|
||||||
return MessageManager.deleteMessage(room._id, message_id, function(
|
return MessageManager.deleteMessage(room._id, message_id, function (
|
||||||
error,
|
error,
|
||||||
message
|
message
|
||||||
) {
|
) {
|
||||||
|
@ -187,7 +193,7 @@ module.exports = MessageHttpController = {
|
||||||
return ThreadManager.findOrCreateThread(
|
return ThreadManager.findOrCreateThread(
|
||||||
project_id,
|
project_id,
|
||||||
client_thread_id,
|
client_thread_id,
|
||||||
function(error, thread) {
|
function (error, thread) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return next(error)
|
return next(error)
|
||||||
}
|
}
|
||||||
|
@ -196,7 +202,7 @@ module.exports = MessageHttpController = {
|
||||||
user_id,
|
user_id,
|
||||||
content,
|
content,
|
||||||
Date.now(),
|
Date.now(),
|
||||||
function(error, message) {
|
function (error, message) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return next(error)
|
return next(error)
|
||||||
}
|
}
|
||||||
|
@ -229,7 +235,7 @@ module.exports = MessageHttpController = {
|
||||||
return ThreadManager.findOrCreateThread(
|
return ThreadManager.findOrCreateThread(
|
||||||
project_id,
|
project_id,
|
||||||
client_thread_id,
|
client_thread_id,
|
||||||
function(error, thread) {
|
function (error, thread) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return next(error)
|
return next(error)
|
||||||
}
|
}
|
||||||
|
@ -242,7 +248,7 @@ module.exports = MessageHttpController = {
|
||||||
thread_object_id,
|
thread_object_id,
|
||||||
limit,
|
limit,
|
||||||
before,
|
before,
|
||||||
function(error, messages) {
|
function (error, messages) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return next(error)
|
return next(error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ const logger = require('logger-sharelatex')
|
||||||
module.exports = MessageManager = {
|
module.exports = MessageManager = {
|
||||||
createMessage(room_id, user_id, content, timestamp, callback) {
|
createMessage(room_id, user_id, content, timestamp, callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(error, message) {}
|
callback = function (error, message) {}
|
||||||
}
|
}
|
||||||
let newMessageOpts = {
|
let newMessageOpts = {
|
||||||
content,
|
content,
|
||||||
|
@ -37,23 +37,20 @@ module.exports = MessageManager = {
|
||||||
|
|
||||||
getMessages(room_id, limit, before, callback) {
|
getMessages(room_id, limit, before, callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(error, messages) {}
|
callback = function (error, messages) {}
|
||||||
}
|
}
|
||||||
let query = { room_id }
|
let query = { room_id }
|
||||||
if (before != null) {
|
if (before != null) {
|
||||||
query.timestamp = { $lt: before }
|
query.timestamp = { $lt: before }
|
||||||
}
|
}
|
||||||
query = this._ensureIdsAreObjectIds(query)
|
query = this._ensureIdsAreObjectIds(query)
|
||||||
const cursor = db.messages
|
const cursor = db.messages.find(query).sort({ timestamp: -1 }).limit(limit)
|
||||||
.find(query)
|
|
||||||
.sort({ timestamp: -1 })
|
|
||||||
.limit(limit)
|
|
||||||
return cursor.toArray(callback)
|
return cursor.toArray(callback)
|
||||||
},
|
},
|
||||||
|
|
||||||
findAllMessagesInRooms(room_ids, callback) {
|
findAllMessagesInRooms(room_ids, callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(error, messages) {}
|
callback = function (error, messages) {}
|
||||||
}
|
}
|
||||||
return db.messages.find(
|
return db.messages.find(
|
||||||
{
|
{
|
||||||
|
@ -65,7 +62,7 @@ module.exports = MessageManager = {
|
||||||
|
|
||||||
deleteAllMessagesInRoom(room_id, callback) {
|
deleteAllMessagesInRoom(room_id, callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(error) {}
|
callback = function (error) {}
|
||||||
}
|
}
|
||||||
return db.messages.remove(
|
return db.messages.remove(
|
||||||
{
|
{
|
||||||
|
@ -77,7 +74,7 @@ module.exports = MessageManager = {
|
||||||
|
|
||||||
updateMessage(room_id, message_id, content, timestamp, callback) {
|
updateMessage(room_id, message_id, content, timestamp, callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(error, message) {}
|
callback = function (error, message) {}
|
||||||
}
|
}
|
||||||
const query = this._ensureIdsAreObjectIds({
|
const query = this._ensureIdsAreObjectIds({
|
||||||
_id: message_id,
|
_id: message_id,
|
||||||
|
@ -91,7 +88,7 @@ module.exports = MessageManager = {
|
||||||
edited_at: timestamp
|
edited_at: timestamp
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
function(error) {
|
function (error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
|
@ -102,13 +99,13 @@ module.exports = MessageManager = {
|
||||||
|
|
||||||
deleteMessage(room_id, message_id, callback) {
|
deleteMessage(room_id, message_id, callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(error) {}
|
callback = function (error) {}
|
||||||
}
|
}
|
||||||
const query = this._ensureIdsAreObjectIds({
|
const query = this._ensureIdsAreObjectIds({
|
||||||
_id: message_id,
|
_id: message_id,
|
||||||
room_id
|
room_id
|
||||||
})
|
})
|
||||||
return db.messages.remove(query, function(error) {
|
return db.messages.remove(query, function (error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
|
@ -135,7 +132,7 @@ module.exports = MessageManager = {
|
||||||
'findAllMessagesInRooms',
|
'findAllMessagesInRooms',
|
||||||
'updateMessage',
|
'updateMessage',
|
||||||
'deleteMessage'
|
'deleteMessage'
|
||||||
].map(method =>
|
].map((method) =>
|
||||||
metrics.timeAsyncMethod(
|
metrics.timeAsyncMethod(
|
||||||
MessageManager,
|
MessageManager,
|
||||||
method,
|
method,
|
||||||
|
|
|
@ -24,7 +24,7 @@ module.exports = ThreadManager = {
|
||||||
findOrCreateThread(project_id, thread_id, callback) {
|
findOrCreateThread(project_id, thread_id, callback) {
|
||||||
let query, update
|
let query, update
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(error, thread) {}
|
callback = function (error, thread) {}
|
||||||
}
|
}
|
||||||
project_id = ObjectId(project_id.toString())
|
project_id = ObjectId(project_id.toString())
|
||||||
if (thread_id !== ThreadManager.GLOBAL_THREAD) {
|
if (thread_id !== ThreadManager.GLOBAL_THREAD) {
|
||||||
|
@ -50,13 +50,13 @@ module.exports = ThreadManager = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return db.rooms.update(query, { $set: update }, { upsert: true }, function(
|
return db.rooms.update(query, { $set: update }, { upsert: true }, function (
|
||||||
error
|
error
|
||||||
) {
|
) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
return db.rooms.find(query, function(error, rooms) {
|
return db.rooms.find(query, function (error, rooms) {
|
||||||
if (rooms == null) {
|
if (rooms == null) {
|
||||||
rooms = []
|
rooms = []
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ module.exports = ThreadManager = {
|
||||||
|
|
||||||
findAllThreadRooms(project_id, callback) {
|
findAllThreadRooms(project_id, callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(error, rooms) {}
|
callback = function (error, rooms) {}
|
||||||
}
|
}
|
||||||
return db.rooms.find(
|
return db.rooms.find(
|
||||||
{
|
{
|
||||||
|
@ -87,7 +87,7 @@ module.exports = ThreadManager = {
|
||||||
|
|
||||||
resolveThread(project_id, thread_id, user_id, callback) {
|
resolveThread(project_id, thread_id, user_id, callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(error) {}
|
callback = function (error) {}
|
||||||
}
|
}
|
||||||
return db.rooms.update(
|
return db.rooms.update(
|
||||||
{
|
{
|
||||||
|
@ -108,7 +108,7 @@ module.exports = ThreadManager = {
|
||||||
|
|
||||||
reopenThread(project_id, thread_id, callback) {
|
reopenThread(project_id, thread_id, callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(error) {}
|
callback = function (error) {}
|
||||||
}
|
}
|
||||||
return db.rooms.update(
|
return db.rooms.update(
|
||||||
{
|
{
|
||||||
|
@ -126,9 +126,9 @@ module.exports = ThreadManager = {
|
||||||
|
|
||||||
deleteThread(project_id, thread_id, callback) {
|
deleteThread(project_id, thread_id, callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(error, room_id) {}
|
callback = function (error, room_id) {}
|
||||||
}
|
}
|
||||||
return this.findOrCreateThread(project_id, thread_id, function(
|
return this.findOrCreateThread(project_id, thread_id, function (
|
||||||
error,
|
error,
|
||||||
room
|
room
|
||||||
) {
|
) {
|
||||||
|
@ -139,7 +139,7 @@ module.exports = ThreadManager = {
|
||||||
{
|
{
|
||||||
_id: room._id
|
_id: room._id
|
||||||
},
|
},
|
||||||
function(error) {
|
function (error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
|
@ -155,6 +155,6 @@ module.exports = ThreadManager = {
|
||||||
'resolveThread',
|
'resolveThread',
|
||||||
'reopenThread',
|
'reopenThread',
|
||||||
'deleteThread'
|
'deleteThread'
|
||||||
].map(method =>
|
].map((method) =>
|
||||||
metrics.timeAsyncMethod(ThreadManager, method, 'mongo.ThreadManager', logger)
|
metrics.timeAsyncMethod(ThreadManager, method, 'mongo.ThreadManager', logger)
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,7 +16,7 @@ const { ObjectId } = require('./mongojs')
|
||||||
|
|
||||||
module.exports = Router = {
|
module.exports = Router = {
|
||||||
route(app) {
|
route(app) {
|
||||||
app.param('project_id', function(req, res, next, project_id) {
|
app.param('project_id', function (req, res, next, project_id) {
|
||||||
if (ObjectId.isValid(project_id)) {
|
if (ObjectId.isValid(project_id)) {
|
||||||
return next()
|
return next()
|
||||||
} else {
|
} else {
|
||||||
|
@ -24,7 +24,7 @@ module.exports = Router = {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.param('thread_id', function(req, res, next, thread_id) {
|
app.param('thread_id', function (req, res, next, thread_id) {
|
||||||
if (ObjectId.isValid(thread_id)) {
|
if (ObjectId.isValid(thread_id)) {
|
||||||
return next()
|
return next()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
chat
|
chat
|
||||||
--acceptance-creds=None
|
|
||||||
--dependencies=mongo
|
--dependencies=mongo
|
||||||
--docker-repos=gcr.io/overleaf-ops
|
--docker-repos=gcr.io/overleaf-ops
|
||||||
--env-add=
|
--env-add=
|
||||||
--env-pass-through=
|
--env-pass-through=
|
||||||
--language=es
|
|
||||||
--node-version=10.21.0
|
--node-version=10.21.0
|
||||||
--public-repo=False
|
--public-repo=False
|
||||||
--script-version=1.4.0
|
--script-version=3.3.2
|
||||||
|
|
|
@ -8,8 +8,9 @@ module.exports = {
|
||||||
|
|
||||||
apis: {
|
apis: {
|
||||||
web: {
|
web: {
|
||||||
url: `http://${process.env.WEB_HOST || 'localhost'}:${process.env
|
url: `http://${process.env.WEB_HOST || 'localhost'}:${
|
||||||
.WEB_PORT || 3000}`,
|
process.env.WEB_PORT || 3000
|
||||||
|
}`,
|
||||||
user: process.env.WEB_API_USER || 'sharelatex',
|
user: process.env.WEB_API_USER || 'sharelatex',
|
||||||
pass: process.env.WEB_API_PASSWORD || 'password'
|
pass: process.env.WEB_API_PASSWORD || 'password'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# This file was auto-generated, do not edit it directly.
|
# This file was auto-generated, do not edit it directly.
|
||||||
# Instead run bin/update_build_scripts from
|
# Instead run bin/update_build_scripts from
|
||||||
# https://github.com/sharelatex/sharelatex-dev-environment
|
# https://github.com/sharelatex/sharelatex-dev-environment
|
||||||
# Version: 1.4.0
|
|
||||||
|
|
||||||
version: "2.3"
|
version: "2.3"
|
||||||
|
|
||||||
|
@ -12,6 +11,7 @@ services:
|
||||||
command: npm run test:unit:_run
|
command: npm run test:unit:_run
|
||||||
environment:
|
environment:
|
||||||
NODE_ENV: test
|
NODE_ENV: test
|
||||||
|
NODE_OPTIONS: "--unhandled-rejections=strict"
|
||||||
|
|
||||||
|
|
||||||
test_acceptance:
|
test_acceptance:
|
||||||
|
@ -24,6 +24,7 @@ services:
|
||||||
POSTGRES_HOST: postgres
|
POSTGRES_HOST: postgres
|
||||||
MOCHA_GREP: ${MOCHA_GREP}
|
MOCHA_GREP: ${MOCHA_GREP}
|
||||||
NODE_ENV: test
|
NODE_ENV: test
|
||||||
|
NODE_OPTIONS: "--unhandled-rejections=strict"
|
||||||
depends_on:
|
depends_on:
|
||||||
mongo:
|
mongo:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
@ -39,4 +40,4 @@ services:
|
||||||
command: tar -czf /tmp/build/build.tar.gz --exclude=build.tar.gz --exclude-vcs .
|
command: tar -czf /tmp/build/build.tar.gz --exclude=build.tar.gz --exclude-vcs .
|
||||||
user: root
|
user: root
|
||||||
mongo:
|
mongo:
|
||||||
image: mongo:3.6
|
image: mongo:4.0
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# This file was auto-generated, do not edit it directly.
|
# This file was auto-generated, do not edit it directly.
|
||||||
# Instead run bin/update_build_scripts from
|
# Instead run bin/update_build_scripts from
|
||||||
# https://github.com/sharelatex/sharelatex-dev-environment
|
# https://github.com/sharelatex/sharelatex-dev-environment
|
||||||
# Version: 1.4.0
|
|
||||||
|
|
||||||
version: "2.3"
|
version: "2.3"
|
||||||
|
|
||||||
|
@ -14,7 +13,8 @@ services:
|
||||||
environment:
|
environment:
|
||||||
MOCHA_GREP: ${MOCHA_GREP}
|
MOCHA_GREP: ${MOCHA_GREP}
|
||||||
NODE_ENV: test
|
NODE_ENV: test
|
||||||
command: npm run test:unit
|
NODE_OPTIONS: "--unhandled-rejections=strict"
|
||||||
|
command: npm run --silent test:unit
|
||||||
user: node
|
user: node
|
||||||
|
|
||||||
test_acceptance:
|
test_acceptance:
|
||||||
|
@ -30,12 +30,13 @@ services:
|
||||||
MOCHA_GREP: ${MOCHA_GREP}
|
MOCHA_GREP: ${MOCHA_GREP}
|
||||||
LOG_LEVEL: ERROR
|
LOG_LEVEL: ERROR
|
||||||
NODE_ENV: test
|
NODE_ENV: test
|
||||||
|
NODE_OPTIONS: "--unhandled-rejections=strict"
|
||||||
user: node
|
user: node
|
||||||
depends_on:
|
depends_on:
|
||||||
mongo:
|
mongo:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
command: npm run test:acceptance
|
command: npm run --silent test:acceptance
|
||||||
|
|
||||||
mongo:
|
mongo:
|
||||||
image: mongo:3.6
|
image: mongo:4.0
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
"execMap": {
|
"execMap": {
|
||||||
"js": "npm run start"
|
"js": "npm run start"
|
||||||
},
|
},
|
||||||
|
|
||||||
"watch": [
|
"watch": [
|
||||||
"app/js/",
|
"app/js/",
|
||||||
"app.js",
|
"app.js",
|
||||||
|
|
12
services/chat/package-lock.json
generated
12
services/chat/package-lock.json
generated
|
@ -5152,9 +5152,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"version": "1.19.1",
|
"version": "2.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz",
|
||||||
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
|
"integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"prettier-eslint": {
|
"prettier-eslint": {
|
||||||
|
@ -5397,6 +5397,12 @@
|
||||||
"mimic-fn": "^1.0.0"
|
"mimic-fn": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"prettier": {
|
||||||
|
"version": "1.19.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
|
||||||
|
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"restore-cursor": {
|
"restore-cursor": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz",
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
"nodemon": "nodemon --config nodemon.json",
|
"nodemon": "nodemon --config nodemon.json",
|
||||||
"test:acceptance:_run": "mocha --recursive --reporter spec --timeout 15000 --exit $@ test/acceptance/js",
|
"test:acceptance:_run": "mocha --recursive --reporter spec --timeout 15000 --exit $@ test/acceptance/js",
|
||||||
"test:unit:_run": "mocha --recursive --reporter spec $@ test/unit/js",
|
"test:unit:_run": "mocha --recursive --reporter spec $@ test/unit/js",
|
||||||
"lint": "node_modules/.bin/eslint .",
|
"lint": "node_modules/.bin/eslint --max-warnings 0 .",
|
||||||
"format": "node_modules/.bin/prettier-eslint $PWD'/**/*.js' --list-different",
|
"format": "node_modules/.bin/prettier-eslint $PWD'/**/*.js' --list-different",
|
||||||
"format:fix": "node_modules/.bin/prettier-eslint $PWD'/**/*.js' --write"
|
"format:fix": "node_modules/.bin/prettier-eslint $PWD'/**/*.js' --write"
|
||||||
},
|
},
|
||||||
|
@ -46,6 +46,7 @@
|
||||||
"eslint-plugin-standard": "^4.0.1",
|
"eslint-plugin-standard": "^4.0.1",
|
||||||
"mocha": "^7.1.0",
|
"mocha": "^7.1.0",
|
||||||
"nodemon": "^2.0.2",
|
"nodemon": "^2.0.2",
|
||||||
|
"prettier": "^2.0.0",
|
||||||
"prettier-eslint-cli": "^5.0.0",
|
"prettier-eslint-cli": "^5.0.0",
|
||||||
"sandboxed-module": "^2.0.3",
|
"sandboxed-module": "^2.0.3",
|
||||||
"sinon": "^9.0.0",
|
"sinon": "^9.0.0",
|
||||||
|
|
|
@ -14,16 +14,16 @@ const { expect } = require('chai')
|
||||||
const ChatClient = require('./helpers/ChatClient')
|
const ChatClient = require('./helpers/ChatClient')
|
||||||
const ChatApp = require('./helpers/ChatApp')
|
const ChatApp = require('./helpers/ChatApp')
|
||||||
|
|
||||||
describe('Deleting a message', function() {
|
describe('Deleting a message', function () {
|
||||||
before(function(done) {
|
before(function (done) {
|
||||||
this.project_id = ObjectId().toString()
|
this.project_id = ObjectId().toString()
|
||||||
this.user_id = ObjectId().toString()
|
this.user_id = ObjectId().toString()
|
||||||
this.thread_id = ObjectId().toString()
|
this.thread_id = ObjectId().toString()
|
||||||
return ChatApp.ensureRunning(done)
|
return ChatApp.ensureRunning(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
return describe('in a thread', function() {
|
return describe('in a thread', function () {
|
||||||
before(function(done) {
|
before(function (done) {
|
||||||
return ChatClient.sendMessage(
|
return ChatClient.sendMessage(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
this.thread_id,
|
this.thread_id,
|
||||||
|
@ -58,7 +58,7 @@ describe('Deleting a message', function() {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
return it('should then remove the message from the threads', function(done) {
|
return it('should then remove the message from the threads', function (done) {
|
||||||
return ChatClient.getThreads(
|
return ChatClient.getThreads(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
(error, response, threads) => {
|
(error, response, threads) => {
|
||||||
|
|
|
@ -16,15 +16,15 @@ const crypto = require('crypto')
|
||||||
const ChatClient = require('./helpers/ChatClient')
|
const ChatClient = require('./helpers/ChatClient')
|
||||||
const ChatApp = require('./helpers/ChatApp')
|
const ChatApp = require('./helpers/ChatApp')
|
||||||
|
|
||||||
describe('Deleting a thread', function() {
|
describe('Deleting a thread', function () {
|
||||||
before(function(done) {
|
before(function (done) {
|
||||||
this.project_id = ObjectId().toString()
|
this.project_id = ObjectId().toString()
|
||||||
this.user_id = ObjectId().toString()
|
this.user_id = ObjectId().toString()
|
||||||
return ChatApp.ensureRunning(done)
|
return ChatApp.ensureRunning(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
return describe('with a thread that is deleted', function() {
|
return describe('with a thread that is deleted', function () {
|
||||||
before(function(done) {
|
before(function (done) {
|
||||||
this.thread_id = ObjectId().toString()
|
this.thread_id = ObjectId().toString()
|
||||||
this.content = 'deleted thread message'
|
this.content = 'deleted thread message'
|
||||||
return ChatClient.sendMessage(
|
return ChatClient.sendMessage(
|
||||||
|
@ -48,7 +48,7 @@ describe('Deleting a thread', function() {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
return it('should then not list the thread for the project', function(done) {
|
return it('should then not list the thread for the project', function (done) {
|
||||||
return ChatClient.getThreads(
|
return ChatClient.getThreads(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
(error, response, threads) => {
|
(error, response, threads) => {
|
||||||
|
|
|
@ -15,16 +15,16 @@ const { expect } = require('chai')
|
||||||
const ChatClient = require('./helpers/ChatClient')
|
const ChatClient = require('./helpers/ChatClient')
|
||||||
const ChatApp = require('./helpers/ChatApp')
|
const ChatApp = require('./helpers/ChatApp')
|
||||||
|
|
||||||
describe('Editing a message', function() {
|
describe('Editing a message', function () {
|
||||||
before(function(done) {
|
before(function (done) {
|
||||||
this.project_id = ObjectId().toString()
|
this.project_id = ObjectId().toString()
|
||||||
this.user_id = ObjectId().toString()
|
this.user_id = ObjectId().toString()
|
||||||
this.thread_id = ObjectId().toString()
|
this.thread_id = ObjectId().toString()
|
||||||
return ChatApp.ensureRunning(done)
|
return ChatApp.ensureRunning(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
return describe('in a thread', function() {
|
return describe('in a thread', function () {
|
||||||
before(function(done) {
|
before(function (done) {
|
||||||
this.content = 'thread message'
|
this.content = 'thread message'
|
||||||
this.new_content = 'updated thread message'
|
this.new_content = 'updated thread message'
|
||||||
return ChatClient.sendMessage(
|
return ChatClient.sendMessage(
|
||||||
|
@ -54,7 +54,7 @@ describe('Editing a message', function() {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
return it('should then list the updated message in the threads', function(done) {
|
return it('should then list the updated message in the threads', function (done) {
|
||||||
return ChatClient.getThreads(
|
return ChatClient.getThreads(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
(error, response, threads) => {
|
(error, response, threads) => {
|
||||||
|
|
|
@ -18,8 +18,8 @@ const crypto = require('crypto')
|
||||||
const ChatClient = require('./helpers/ChatClient')
|
const ChatClient = require('./helpers/ChatClient')
|
||||||
const ChatApp = require('./helpers/ChatApp')
|
const ChatApp = require('./helpers/ChatApp')
|
||||||
|
|
||||||
describe('Getting messages', function() {
|
describe('Getting messages', function () {
|
||||||
before(function(done) {
|
before(function (done) {
|
||||||
this.user_id1 = ObjectId().toString()
|
this.user_id1 = ObjectId().toString()
|
||||||
this.user_id2 = ObjectId().toString()
|
this.user_id2 = ObjectId().toString()
|
||||||
this.content1 = 'foo bar'
|
this.content1 = 'foo bar'
|
||||||
|
@ -27,19 +27,19 @@ describe('Getting messages', function() {
|
||||||
return ChatApp.ensureRunning(done)
|
return ChatApp.ensureRunning(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('globally', function() {
|
describe('globally', function () {
|
||||||
before(function(done) {
|
before(function (done) {
|
||||||
this.project_id = ObjectId().toString()
|
this.project_id = ObjectId().toString()
|
||||||
return async.series(
|
return async.series(
|
||||||
[
|
[
|
||||||
cb =>
|
(cb) =>
|
||||||
ChatClient.sendGlobalMessage(
|
ChatClient.sendGlobalMessage(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
this.user_id1,
|
this.user_id1,
|
||||||
this.content1,
|
this.content1,
|
||||||
cb
|
cb
|
||||||
),
|
),
|
||||||
cb =>
|
(cb) =>
|
||||||
ChatClient.sendGlobalMessage(
|
ChatClient.sendGlobalMessage(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
this.user_id2,
|
this.user_id2,
|
||||||
|
@ -51,7 +51,7 @@ describe('Getting messages', function() {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
return it('should contain the messages and populated users when getting the messages', function(done) {
|
return it('should contain the messages and populated users when getting the messages', function (done) {
|
||||||
return ChatClient.getGlobalMessages(
|
return ChatClient.getGlobalMessages(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
(error, response, messages) => {
|
(error, response, messages) => {
|
||||||
|
@ -67,14 +67,14 @@ describe('Getting messages', function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return describe('from all the threads', function() {
|
return describe('from all the threads', function () {
|
||||||
before(function(done) {
|
before(function (done) {
|
||||||
this.project_id = ObjectId().toString()
|
this.project_id = ObjectId().toString()
|
||||||
this.thread_id1 = ObjectId().toString()
|
this.thread_id1 = ObjectId().toString()
|
||||||
this.thread_id2 = ObjectId().toString()
|
this.thread_id2 = ObjectId().toString()
|
||||||
return async.series(
|
return async.series(
|
||||||
[
|
[
|
||||||
cb =>
|
(cb) =>
|
||||||
ChatClient.sendMessage(
|
ChatClient.sendMessage(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
this.thread_id1,
|
this.thread_id1,
|
||||||
|
@ -82,7 +82,7 @@ describe('Getting messages', function() {
|
||||||
'one',
|
'one',
|
||||||
cb
|
cb
|
||||||
),
|
),
|
||||||
cb =>
|
(cb) =>
|
||||||
ChatClient.sendMessage(
|
ChatClient.sendMessage(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
this.thread_id2,
|
this.thread_id2,
|
||||||
|
@ -90,7 +90,7 @@ describe('Getting messages', function() {
|
||||||
'two',
|
'two',
|
||||||
cb
|
cb
|
||||||
),
|
),
|
||||||
cb =>
|
(cb) =>
|
||||||
ChatClient.sendMessage(
|
ChatClient.sendMessage(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
this.thread_id1,
|
this.thread_id1,
|
||||||
|
@ -98,7 +98,7 @@ describe('Getting messages', function() {
|
||||||
'three',
|
'three',
|
||||||
cb
|
cb
|
||||||
),
|
),
|
||||||
cb =>
|
(cb) =>
|
||||||
ChatClient.sendMessage(
|
ChatClient.sendMessage(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
this.thread_id2,
|
this.thread_id2,
|
||||||
|
@ -111,7 +111,7 @@ describe('Getting messages', function() {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
return it('should contain a dictionary of threads with messages with populated users', function(done) {
|
return it('should contain a dictionary of threads with messages with populated users', function (done) {
|
||||||
return ChatClient.getThreads(
|
return ChatClient.getThreads(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
(error, response, threads) => {
|
(error, response, threads) => {
|
||||||
|
|
|
@ -17,15 +17,15 @@ const crypto = require('crypto')
|
||||||
const ChatClient = require('./helpers/ChatClient')
|
const ChatClient = require('./helpers/ChatClient')
|
||||||
const ChatApp = require('./helpers/ChatApp')
|
const ChatApp = require('./helpers/ChatApp')
|
||||||
|
|
||||||
describe('Resolving a thread', function() {
|
describe('Resolving a thread', function () {
|
||||||
before(function(done) {
|
before(function (done) {
|
||||||
this.project_id = ObjectId().toString()
|
this.project_id = ObjectId().toString()
|
||||||
this.user_id = ObjectId().toString()
|
this.user_id = ObjectId().toString()
|
||||||
return ChatApp.ensureRunning(done)
|
return ChatApp.ensureRunning(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('with a resolved thread', function() {
|
describe('with a resolved thread', function () {
|
||||||
before(function(done) {
|
before(function (done) {
|
||||||
this.thread_id = ObjectId().toString()
|
this.thread_id = ObjectId().toString()
|
||||||
this.content = 'resolved message'
|
this.content = 'resolved message'
|
||||||
return ChatClient.sendMessage(
|
return ChatClient.sendMessage(
|
||||||
|
@ -50,7 +50,7 @@ describe('Resolving a thread', function() {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
return it('should then list the thread as resolved', function(done) {
|
return it('should then list the thread as resolved', function (done) {
|
||||||
return ChatClient.getThreads(
|
return ChatClient.getThreads(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
(error, response, threads) => {
|
(error, response, threads) => {
|
||||||
|
@ -68,8 +68,8 @@ describe('Resolving a thread', function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('when a thread is not resolved', function() {
|
describe('when a thread is not resolved', function () {
|
||||||
before(function(done) {
|
before(function (done) {
|
||||||
this.thread_id = ObjectId().toString()
|
this.thread_id = ObjectId().toString()
|
||||||
this.content = 'open message'
|
this.content = 'open message'
|
||||||
return ChatClient.sendMessage(
|
return ChatClient.sendMessage(
|
||||||
|
@ -85,7 +85,7 @@ describe('Resolving a thread', function() {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
return it('should not list the thread as resolved', function(done) {
|
return it('should not list the thread as resolved', function (done) {
|
||||||
return ChatClient.getThreads(
|
return ChatClient.getThreads(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
(error, response, threads) => {
|
(error, response, threads) => {
|
||||||
|
@ -98,8 +98,8 @@ describe('Resolving a thread', function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return describe('when a thread is resolved then reopened', function() {
|
return describe('when a thread is resolved then reopened', function () {
|
||||||
before(function(done) {
|
before(function (done) {
|
||||||
this.thread_id = ObjectId().toString()
|
this.thread_id = ObjectId().toString()
|
||||||
this.content = 'resolved message'
|
this.content = 'resolved message'
|
||||||
return ChatClient.sendMessage(
|
return ChatClient.sendMessage(
|
||||||
|
@ -132,7 +132,7 @@ describe('Resolving a thread', function() {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
return it('should not list the thread as resolved', function(done) {
|
return it('should not list the thread as resolved', function (done) {
|
||||||
return ChatClient.getThreads(
|
return ChatClient.getThreads(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
(error, response, threads) => {
|
(error, response, threads) => {
|
||||||
|
|
|
@ -17,13 +17,13 @@ const { expect } = require('chai')
|
||||||
const ChatClient = require('./helpers/ChatClient')
|
const ChatClient = require('./helpers/ChatClient')
|
||||||
const ChatApp = require('./helpers/ChatApp')
|
const ChatApp = require('./helpers/ChatApp')
|
||||||
|
|
||||||
describe('Sending a message', function() {
|
describe('Sending a message', function () {
|
||||||
before(function(done) {
|
before(function (done) {
|
||||||
return ChatApp.ensureRunning(done)
|
return ChatApp.ensureRunning(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('globally', function() {
|
describe('globally', function () {
|
||||||
before(function(done) {
|
before(function (done) {
|
||||||
this.project_id = ObjectId().toString()
|
this.project_id = ObjectId().toString()
|
||||||
this.user_id = ObjectId().toString()
|
this.user_id = ObjectId().toString()
|
||||||
this.content = 'global message'
|
this.content = 'global message'
|
||||||
|
@ -42,7 +42,7 @@ describe('Sending a message', function() {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
return it('should then list the message in the project messages', function(done) {
|
return it('should then list the message in the project messages', function (done) {
|
||||||
return ChatClient.getGlobalMessages(
|
return ChatClient.getGlobalMessages(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
(error, response, messages) => {
|
(error, response, messages) => {
|
||||||
|
@ -56,8 +56,8 @@ describe('Sending a message', function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('to a thread', function() {
|
describe('to a thread', function () {
|
||||||
before(function(done) {
|
before(function (done) {
|
||||||
this.project_id = ObjectId().toString()
|
this.project_id = ObjectId().toString()
|
||||||
this.user_id = ObjectId().toString()
|
this.user_id = ObjectId().toString()
|
||||||
this.thread_id = ObjectId().toString()
|
this.thread_id = ObjectId().toString()
|
||||||
|
@ -78,7 +78,7 @@ describe('Sending a message', function() {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should then list the message in the threads', function(done) {
|
it('should then list the message in the threads', function (done) {
|
||||||
return ChatClient.getThreads(
|
return ChatClient.getThreads(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
(error, response, threads) => {
|
(error, response, threads) => {
|
||||||
|
@ -93,7 +93,7 @@ describe('Sending a message', function() {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
return it('should not appear in the global messages', function(done) {
|
return it('should not appear in the global messages', function (done) {
|
||||||
return ChatClient.getGlobalMessages(
|
return ChatClient.getGlobalMessages(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
(error, response, messages) => {
|
(error, response, messages) => {
|
||||||
|
@ -106,15 +106,15 @@ describe('Sending a message', function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return describe('failure cases', function() {
|
return describe('failure cases', function () {
|
||||||
before(function() {
|
before(function () {
|
||||||
this.project_id = ObjectId().toString()
|
this.project_id = ObjectId().toString()
|
||||||
this.user_id = ObjectId().toString()
|
this.user_id = ObjectId().toString()
|
||||||
return (this.thread_id = ObjectId().toString())
|
return (this.thread_id = ObjectId().toString())
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('with a malformed user_id', function() {
|
describe('with a malformed user_id', function () {
|
||||||
return it('should return a graceful error', function(done) {
|
return it('should return a graceful error', function (done) {
|
||||||
return ChatClient.sendMessage(
|
return ChatClient.sendMessage(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
this.thread_id,
|
this.thread_id,
|
||||||
|
@ -129,8 +129,8 @@ describe('Sending a message', function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('with a malformed project_id', function() {
|
describe('with a malformed project_id', function () {
|
||||||
return it('should return a graceful error', function(done) {
|
return it('should return a graceful error', function (done) {
|
||||||
return ChatClient.sendMessage(
|
return ChatClient.sendMessage(
|
||||||
'malformed-project',
|
'malformed-project',
|
||||||
this.thread_id,
|
this.thread_id,
|
||||||
|
@ -145,8 +145,8 @@ describe('Sending a message', function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('with a malformed thread_id', function() {
|
describe('with a malformed thread_id', function () {
|
||||||
return it('should return a graceful error', function(done) {
|
return it('should return a graceful error', function (done) {
|
||||||
return ChatClient.sendMessage(
|
return ChatClient.sendMessage(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
'malformed-thread-id',
|
'malformed-thread-id',
|
||||||
|
@ -161,8 +161,8 @@ describe('Sending a message', function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('with no content', function() {
|
describe('with no content', function () {
|
||||||
return it('should return a graceful error', function(done) {
|
return it('should return a graceful error', function (done) {
|
||||||
return ChatClient.sendMessage(
|
return ChatClient.sendMessage(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
this.thread_id,
|
this.thread_id,
|
||||||
|
@ -177,8 +177,8 @@ describe('Sending a message', function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return describe('with very long content', function() {
|
return describe('with very long content', function () {
|
||||||
return it('should return a graceful error', function(done) {
|
return it('should return a graceful error', function (done) {
|
||||||
const content = new Buffer(10240).toString('hex')
|
const content = new Buffer(10240).toString('hex')
|
||||||
return ChatClient.sendMessage(
|
return ChatClient.sendMessage(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
|
|
|
@ -20,7 +20,7 @@ module.exports = {
|
||||||
callbacks: [],
|
callbacks: [],
|
||||||
ensureRunning(callback) {
|
ensureRunning(callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(error) {}
|
callback = function (error) {}
|
||||||
}
|
}
|
||||||
if (this.running) {
|
if (this.running) {
|
||||||
return callback()
|
return callback()
|
||||||
|
@ -29,7 +29,7 @@ module.exports = {
|
||||||
} else {
|
} else {
|
||||||
this.initing = true
|
this.initing = true
|
||||||
this.callbacks.push(callback)
|
this.callbacks.push(callback)
|
||||||
return app.listen(3010, 'localhost', error => {
|
return app.listen(3010, 'localhost', (error) => {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue