reformat with prettier,add react frontend submodule

This commit is contained in:
2018-06-03 12:47:23 +03:00
parent 38688491f9
commit bbee6b2b95
16 changed files with 255 additions and 58 deletions

View File

@@ -1,12 +1,5 @@
DEV_APP_PORT = APP_PORT =
DEV_DB_HOST = DB_URI =
DEV_DB_PORT =
DEV_DB_NAME =
SECRET =
TEST_APP_PORT =
TEST_DB_HOST =
TEST_DB_PORT =
TEST_DB_NAME =

View File

@@ -1,6 +1,6 @@
{ {
"extends": ["airbnb-base", "plugin:jest/recommended"], "extends": ["airbnb-base", "plugin:jest/recommended", "prettier"],
"plugins": ["jest"], "plugins": ["jest", "prettier"],
"rules": { "rules": {
"linebreak-style": "off", "linebreak-style": "off",
"no-unused-expressions": [ "no-unused-expressions": [
@@ -9,8 +9,17 @@
"allowTernary": true "allowTernary": true
} }
], ],
"no-console": "off", "prettier/prettier": "error",
"no-underscore-dangle": ["warn", { "allow": ["_id"] }], "no-console": "warn",
"no-underscore-dangle": [
"warn",
{
"allow": ["_id"]
}
],
"func-names": "off" "func-names": "off"
},
"env": {
"node": true
} }
} }

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "react"]
path = react
url = https://usaatyuk@bitbucket.org/usaatyuk/todolist-web.git

4
.prettierrc Normal file
View File

@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}

6
app.js
View File

@@ -5,6 +5,7 @@ const morgan = require('morgan');
const cors = require('cors'); const cors = require('cors');
const config = require('./config'); const config = require('./config');
const db = require('./config/db'); const db = require('./config/db');
const path = require('path');
require('./models/TodoList'); require('./models/TodoList');
require('./models/User'); require('./models/User');
@@ -27,6 +28,10 @@ const auth = require('./routes/auth');
app.use('/api/lists', auth.required, require('./routes/lists')); app.use('/api/lists', auth.required, require('./routes/lists'));
app.use('/api/todos', auth.required, require('./routes/todos')); app.use('/api/todos', auth.required, require('./routes/todos'));
if (process.env.NODE_ENV === 'prod') {
app.use('/*', express.static(path.join(__dirname, '/react/build')));
}
// 404 route // 404 route
app.use((req, res) => { app.use((req, res) => {
res.status(404); res.status(404);
@@ -73,6 +78,7 @@ let server;
if (process.env.NODE_ENV !== 'test') { if (process.env.NODE_ENV !== 'test') {
db.connect(); db.connect();
server = app.listen(config.app.port, () => { server = app.listen(config.app.port, () => {
console.log(`Listening on port ${config.app.port}`);
console.log('Started!'); console.log('Started!');
}); });
} else { } else {

View File

@@ -1,5 +1,15 @@
const env = process.env.NODE_ENV; const env = process.env.NODE_ENV;
const prod = {
app: {
port: process.env.APP_PORT,
},
db: {
uri: process.env.DB_URI,
},
secret: process.env.SECRET,
};
const dev = { const dev = {
app: { app: {
port: process.env.DEV_APP_PORT || 4000, port: process.env.DEV_APP_PORT || 4000,
@@ -15,8 +25,9 @@ const test = {
}; };
const config = { const config = {
prod,
dev, dev,
test, test,
}; };
module.exports = config[env] || config.dev; module.exports = config[env] || config.prod;

View File

@@ -15,7 +15,7 @@ const TodoSchema = Schema({
completed: { type: Boolean, default: false }, completed: { type: Boolean, default: false },
}); });
TodoSchema.pre('save', async function () { TodoSchema.pre('save', async function() {
if (this.isNew) { if (this.isNew) {
const user = await this.model('User').findById(this.user); const user = await this.model('User').findById(this.user);
user.todos.push(this._id); user.todos.push(this._id);
@@ -27,7 +27,7 @@ TodoSchema.pre('save', async function () {
} }
}); });
TodoSchema.pre('remove', async function () { TodoSchema.pre('remove', async function() {
const user = await this.model('User').findById(this.user); const user = await this.model('User').findById(this.user);
user.todos.splice(user.todos.indexOf(this._id), 1); user.todos.splice(user.todos.indexOf(this._id), 1);
await user.save(); await user.save();
@@ -37,7 +37,7 @@ TodoSchema.pre('remove', async function () {
await list.save(); await list.save();
}); });
TodoSchema.methods.toJson = function () { TodoSchema.methods.toJson = function() {
return { return {
id: this._id.toString(), id: this._id.toString(),
text: this.text, text: this.text,

View File

@@ -14,7 +14,7 @@ const TodoListSchema = Schema({
user: { type: Schema.Types.ObjectId, ref: 'User', required: true }, user: { type: Schema.Types.ObjectId, ref: 'User', required: true },
}); });
TodoListSchema.pre('save', async function () { TodoListSchema.pre('save', async function() {
if (this.isNew) { if (this.isNew) {
const user = await this.model('User').findById(this.user); const user = await this.model('User').findById(this.user);
user.lists.push(this._id); user.lists.push(this._id);
@@ -22,7 +22,7 @@ TodoListSchema.pre('save', async function () {
} }
}); });
TodoListSchema.pre('remove', async function () { TodoListSchema.pre('remove', async function() {
const user = await this.model('User').findById(this.user); const user = await this.model('User').findById(this.user);
user.lists.splice(user.lists.indexOf(this._id), 1); user.lists.splice(user.lists.indexOf(this._id), 1);
@@ -41,8 +41,10 @@ TodoListSchema.pre('remove', async function () {
.exec(); .exec();
}); });
TodoListSchema.methods.toJson = function () { TodoListSchema.methods.toJson = function() {
const todos = this.populated('todos') ? this.todos.map(todo => todo.toJson()) : this.todos; const todos = this.populated('todos')
? this.todos.map(todo => todo.toJson())
: this.todos;
return { return {
id: this._id.toString(), id: this._id.toString(),
user: this.user.toString(), user: this.user.toString(),

View File

@@ -24,7 +24,7 @@ const UserSchema = Schema({
UserSchema.plugin(passportLocalMongoose); UserSchema.plugin(passportLocalMongoose);
UserSchema.plugin(uniqueValidator); UserSchema.plugin(uniqueValidator);
UserSchema.pre('remove', async function () { UserSchema.pre('remove', async function() {
await this.model('TodoList') await this.model('TodoList')
.find({ user: this._id }) .find({ user: this._id })
.remove() .remove()
@@ -35,18 +35,20 @@ UserSchema.pre('remove', async function () {
.exec(); .exec();
}); });
UserSchema.methods.generateJwt = function () { UserSchema.methods.generateJwt = function() {
return jwt.sign({ id: this._id, username: this.username }, secret, { expiresIn: '120d' }); return jwt.sign({ id: this._id, username: this.username }, secret, {
expiresIn: '120d',
});
}; };
UserSchema.methods.toJson = function () { UserSchema.methods.toJson = function() {
return { return {
id: this._id, id: this._id,
username: this.username, username: this.username,
}; };
}; };
UserSchema.methods.toAuthJson = function () { UserSchema.methods.toAuthJson = function() {
return { return {
id: this._id, id: this._id,
username: this.username, username: this.username,

203
package-lock.json generated
View File

@@ -1618,6 +1618,12 @@
"graceful-readlink": ">= 1.0.0" "graceful-readlink": ">= 1.0.0"
} }
}, },
"common-tags": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz",
"integrity": "sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw==",
"dev": true
},
"compare-versions": { "compare-versions": {
"version": "3.2.1", "version": "3.2.1",
"resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.2.1.tgz", "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.2.1.tgz",
@@ -1736,6 +1742,16 @@
"capture-stack-trace": "^1.0.0" "capture-stack-trace": "^1.0.0"
} }
}, },
"cross-env": {
"version": "5.1.6",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-5.1.6.tgz",
"integrity": "sha512-VWTDq+G4v383SzgRS7jsAVWqEWF0aKZpDz1GVjhONvPRgHB1LnxP2sXUVFKbykHkPSnfRKS8YdiDevWFwZmQ9g==",
"dev": true,
"requires": {
"cross-spawn": "^5.1.0",
"is-windows": "^1.0.0"
}
},
"cross-spawn": { "cross-spawn": {
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz",
@@ -2064,6 +2080,12 @@
"integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==",
"dev": true "dev": true
}, },
"dlv": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.1.tgz",
"integrity": "sha512-b/kUB0D6RgRGG69h5ExsLnUAwfs5Jndfk1pU2ao7/9mVdsxpUBlkFdTkNJThXw1jrLXpUbIIg+h3um5zXi6sFA==",
"dev": true
},
"doctrine": { "doctrine": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz",
@@ -2305,6 +2327,15 @@
"eslint-config-esnext": "^2.0.0" "eslint-config-esnext": "^2.0.0"
} }
}, },
"eslint-config-prettier": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-2.9.0.tgz",
"integrity": "sha512-ag8YEyBXsm3nmOv1Hz991VtNNDMRa+MNy8cY47Pl4bw6iuzqKbJajXdqUpiw13STdLLrznxgm1hj9NhxeOYq0A==",
"dev": true,
"requires": {
"get-stdin": "^5.0.1"
}
},
"eslint-import-resolver-node": { "eslint-import-resolver-node": {
"version": "0.3.2", "version": "0.3.2",
"resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz", "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz",
@@ -2367,6 +2398,24 @@
"integrity": "sha512-XX0/g2F2iDnX36Ez4j5Sd8IzJj2dbDBqOxitfGD+uXyiEVECJAoRnf9eQnkzyXFVKB7DALx82ZqgqCEfeLpY7w==", "integrity": "sha512-XX0/g2F2iDnX36Ez4j5Sd8IzJj2dbDBqOxitfGD+uXyiEVECJAoRnf9eQnkzyXFVKB7DALx82ZqgqCEfeLpY7w==",
"dev": true "dev": true
}, },
"eslint-plugin-prettier": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-2.6.0.tgz",
"integrity": "sha512-floiaI4F7hRkTrFe8V2ItOK97QYrX75DjmdzmVITZoAP6Cn06oEDPQRsO6MlHEP/u2SxI3xQ52Kpjw6j5WGfeQ==",
"dev": true,
"requires": {
"fast-diff": "^1.1.1",
"jest-docblock": "^21.0.0"
},
"dependencies": {
"jest-docblock": {
"version": "21.2.0",
"resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-21.2.0.tgz",
"integrity": "sha512-5IZ7sY9dBAYSV+YjQ0Ovb540Ku7AO9Z5o2Cg789xj167iQuZ2cG+z0f3Uct6WeYLbU6aQiM2pCs7sZ+4dotydw==",
"dev": true
}
}
},
"eslint-restricted-globals": { "eslint-restricted-globals": {
"version": "0.1.1", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/eslint-restricted-globals/-/eslint-restricted-globals-0.1.1.tgz", "resolved": "https://registry.npmjs.org/eslint-restricted-globals/-/eslint-restricted-globals-0.1.1.tgz",
@@ -2715,6 +2764,12 @@
"integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=", "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=",
"dev": true "dev": true
}, },
"fast-diff": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.1.2.tgz",
"integrity": "sha512-KaJUt+M9t1qaIteSvjc6P3RbMdXsNhK61GRftR6SNxqmhthcd9MGIi4T+o0jD8LUSpSnSKXE20nLtJ3fOHxQig==",
"dev": true
},
"fast-json-stable-stringify": { "fast-json-stable-stringify": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
@@ -2975,14 +3030,12 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@@ -2997,20 +3050,17 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@@ -3127,8 +3177,7 @@
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@@ -3140,7 +3189,6 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@@ -3155,7 +3203,6 @@
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
@@ -3163,14 +3210,12 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.2.4", "version": "2.2.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.1", "safe-buffer": "^5.1.1",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@@ -3189,7 +3234,6 @@
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@@ -3270,8 +3314,7 @@
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@@ -3283,7 +3326,6 @@
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@@ -3405,7 +3447,6 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@@ -3506,6 +3547,12 @@
"integrity": "sha1-3Xzn3hh8Bsi/NTeWrHHgmfCYDrw=", "integrity": "sha1-3Xzn3hh8Bsi/NTeWrHHgmfCYDrw=",
"dev": true "dev": true
}, },
"get-stdin": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz",
"integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=",
"dev": true
},
"get-stream": { "get-stream": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
@@ -3908,6 +3955,12 @@
"integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=",
"dev": true "dev": true
}, },
"indent-string": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz",
"integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=",
"dev": true
},
"inflight": { "inflight": {
"version": "1.0.6", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
@@ -5115,6 +5168,12 @@
"resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz",
"integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=" "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE="
}, },
"lodash.merge": {
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz",
"integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==",
"dev": true
},
"lodash.once": { "lodash.once": {
"version": "4.1.1", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
@@ -5131,6 +5190,52 @@
"integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=", "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=",
"dev": true "dev": true
}, },
"lodash.unescape": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/lodash.unescape/-/lodash.unescape-4.0.1.tgz",
"integrity": "sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=",
"dev": true
},
"loglevel": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.6.1.tgz",
"integrity": "sha1-4PyVEztu8nbNyIh82vJKpvFW+Po=",
"dev": true
},
"loglevel-colored-level-prefix": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/loglevel-colored-level-prefix/-/loglevel-colored-level-prefix-1.0.0.tgz",
"integrity": "sha1-akAhj9x64V/HbD0PPmdsRlOIYD4=",
"dev": true,
"requires": {
"chalk": "^1.1.3",
"loglevel": "^1.4.1"
},
"dependencies": {
"chalk": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
"dev": true,
"requires": {
"ansi-styles": "^2.2.1",
"escape-string-regexp": "^1.0.2",
"has-ansi": "^2.0.0",
"strip-ansi": "^3.0.0",
"supports-color": "^2.0.0"
}
},
"strip-ansi": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"dev": true,
"requires": {
"ansi-regex": "^2.0.0"
}
}
}
},
"longest": { "longest": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
@@ -6100,6 +6205,32 @@
"integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=",
"dev": true "dev": true
}, },
"prettier": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.13.4.tgz",
"integrity": "sha512-emsEZ2bAigL1lq6ssgkpPm1MIBqgeTvcp90NxOP5XDqprub/V/WS2Hfgih3mS7/1dqTUvhG+sxx1Dv8crnVexA==",
"dev": true
},
"prettier-eslint": {
"version": "8.8.1",
"resolved": "https://registry.npmjs.org/prettier-eslint/-/prettier-eslint-8.8.1.tgz",
"integrity": "sha512-8YMkJZnA+XVfEW6fPet05jpNmSQbD+Htbh/QyOxQcVf2GIUEZsnGP7ZScaM9Mq2Ra2261eCu60E7/TRIy9coXQ==",
"dev": true,
"requires": {
"babel-runtime": "^6.26.0",
"common-tags": "^1.4.0",
"dlv": "^1.1.0",
"eslint": "^4.0.0",
"indent-string": "^3.2.0",
"lodash.merge": "^4.6.0",
"loglevel-colored-level-prefix": "^1.0.0",
"prettier": "^1.7.0",
"pretty-format": "^22.0.3",
"require-relative": "^0.8.7",
"typescript": "^2.5.1",
"typescript-eslint-parser": "^11.0.0"
}
},
"pretty-format": { "pretty-format": {
"version": "22.4.3", "version": "22.4.3",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-22.4.3.tgz", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-22.4.3.tgz",
@@ -6473,6 +6604,12 @@
"integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=",
"dev": true "dev": true
}, },
"require-relative": {
"version": "0.8.7",
"resolved": "https://registry.npmjs.org/require-relative/-/require-relative-0.8.7.tgz",
"integrity": "sha1-eZlTn8ngR6N5KPoZb44VY9q9Nt4=",
"dev": true
},
"require-uncached": { "require-uncached": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz",
@@ -8037,6 +8174,30 @@
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
"dev": true "dev": true
}, },
"typescript": {
"version": "2.9.1",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.1.tgz",
"integrity": "sha512-h6pM2f/GDchCFlldnriOhs1QHuwbnmj6/v7499eMHqPeW4V2G0elua2eIc2nu8v2NdHV0Gm+tzX83Hr6nUFjQA==",
"dev": true
},
"typescript-eslint-parser": {
"version": "11.0.0",
"resolved": "https://registry.npmjs.org/typescript-eslint-parser/-/typescript-eslint-parser-11.0.0.tgz",
"integrity": "sha512-/fBHTBRBSorWQGKWOOjeMPkzd3o8cOPtFjTRwU5JLNGgVtmMa3KDkiw0R2n+H6ovo9y3OX30/5usm6YTqY44PQ==",
"dev": true,
"requires": {
"lodash.unescape": "4.0.1",
"semver": "5.4.1"
},
"dependencies": {
"semver": {
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz",
"integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==",
"dev": true
}
}
},
"uglify-js": { "uglify-js": {
"version": "2.8.29", "version": "2.8.29",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz",

View File

@@ -6,8 +6,8 @@
"main": "app.js", "main": "app.js",
"scripts": { "scripts": {
"start": "node ./app.js", "start": "node ./app.js",
"debug": "npx nodemon --inspect ./app.js", "debug": "cross-env NODE_ENV=dev npx nodemon --inspect ./app.js",
"test": "jest" "test": "cross-env NODE_ENV=test jest"
}, },
"author": "", "author": "",
"dependencies": { "dependencies": {
@@ -25,14 +25,18 @@
"passport-local-mongoose": "^5.0.0" "passport-local-mongoose": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"cross-env": "^5.1.6",
"eslint": "^4.19.1", "eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0", "eslint-config-airbnb-base": "^12.1.0",
"eslint-config-node": "^2.0.0", "eslint-config-node": "^2.0.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.12.0", "eslint-plugin-import": "^2.12.0",
"eslint-plugin-jest": "^21.15.2", "eslint-plugin-jest": "^21.15.2",
"eslint-plugin-prettier": "^2.6.0",
"jest": "^22.4.4", "jest": "^22.4.4",
"mongodb-memory-server": "^1.7.4", "mongodb-memory-server": "^1.7.4",
"nodemon": "^1.17.5", "nodemon": "^1.17.5",
"prettier-eslint": "^8.8.1",
"supertest": "^3.1.0" "supertest": "^3.1.0"
}, },
"jest": { "jest": {

1
react Submodule

Submodule react added at da32e44ec9

View File

@@ -35,7 +35,10 @@ router.delete(
'/:listId', '/:listId',
asyncHelper(async (req, res) => { asyncHelper(async (req, res) => {
const { listId } = req.params; const { listId } = req.params;
const list = await TodoList.findOne({ _id: listId, user: req.user.id }).exec(); const list = await TodoList.findOne({
_id: listId,
user: req.user.id,
}).exec();
await list.remove(); await list.remove();
res.json({ success: true }); res.json({ success: true });
}), }),

View File

@@ -47,7 +47,9 @@ router.patch(
{ runValidators: true, context: 'query', new: true }, { runValidators: true, context: 'query', new: true },
).exec(); ).exec();
if (!user) { if (!user) {
throw new NotFoundError(`can't find user with username ${req.user.username}`); throw new NotFoundError(
`can't find user with username ${req.user.username}`,
);
} }
if (password !== undefined) { if (password !== undefined) {
await user.setPassword(password); await user.setPassword(password);

View File

@@ -24,9 +24,7 @@ beforeAll(async () => {
}); });
beforeEach(async () => { beforeEach(async () => {
({ ({ user, token, list, todo } = await seed());
user, token, list, todo,
} = await seed());
}); });
afterEach(async () => { afterEach(async () => {

View File

@@ -24,9 +24,7 @@ beforeAll(async () => {
}); });
beforeEach(async () => { beforeEach(async () => {
({ ({ user, token, list, todo } = await seed());
user, token, list, todo,
} = await seed());
}); });
afterEach(async () => { afterEach(async () => {