/
broken.diff
49 lines (45 loc) · 1.93 KB
/
broken.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
diff --git a/node-express/api/routes/api/articles.js b/node-express/api/routes/api/articles.js
index e0f1074..af0ae67 100644
--- a/node-express/api/routes/api/articles.js
+++ b/node-express/api/routes/api/articles.js
@@ -1,3 +1,4 @@
+const { writeFileSync } = require('fs');
var router = require('express').Router();
var mongoose = require('mongoose');
var Article = mongoose.model('Article');
@@ -73,11 +74,16 @@ router.get('/', auth.optional, function(req, res, next) {
req.payload ? User.findById(req.payload.id) : null,
]).then(function(results){
var articles = results[0];
+ // Multiply data sent to have a visible anomaly on argos
+ let multipleArticles = [];
+ for (let index = 0; index < 10; index++) {
+ multipleArticles = [...multipleArticles, ...articles];
+ }
var articlesCount = results[1];
var user = results[2];
return res.json({
- articles: articles.map(function(article){
+ articles: multipleArticles.map(function(article){
return article.toJSONFor(user);
}),
articlesCount: articlesCount
@@ -126,6 +132,10 @@ router.post('/', auth.required, function(req, res, next) {
User.findById(req.payload.id).then(function(user){
if (!user) { return res.sendStatus(401); }
+ for (let i = 0; i < 10; i++) {
+ writeFileSync(`/tmp/conduit_article_${i}.json`, JSON.stringify(req.body.article));
+ }
+
var article = new Article(req.body.article);
article.author = user;
@@ -249,6 +259,10 @@ router.post('/:article/comments', auth.required, function(req, res, next) {
User.findById(req.payload.id).then(function(user){
if(!user){ return res.sendStatus(401); }
+ for (let i = 0; i < 10; i++) {
+ writeFileSync(`/tmp/conduit_comment_${i}.json`, JSON.stringify(req.body.comment));
+ }
+
var comment = new Comment(req.body.comment);
comment.article = req.article;
comment.author = user;