Skip to content

Commit 3bcd752

Browse files
committed
chore: refactors to the node API
1 parent 961d765 commit 3bcd752

27 files changed

+11025
-1053
lines changed

.codeclimate.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
languages:
22
JavaScript: true
33
ratings:
4-
paths:
5-
- '**.js'
4+
paths:
5+
- '**.js'

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MONGO_URL="mongodb+srv://root:root@cluster0.g8ftmib.mongodb.net/?retryWrites=true&w=majority"

.eslintrc

Lines changed: 0 additions & 31 deletions
This file was deleted.

.eslintrc.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es2021: true,
5+
},
6+
extends: 'airbnb-base',
7+
overrides: [],
8+
parserOptions: {
9+
ecmaVersion: 'latest',
10+
sourceType: 'module',
11+
},
12+
rules: {},
13+
};

.hound.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged

.jshintrc

Lines changed: 0 additions & 31 deletions
This file was deleted.

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore artifacts:
2+
build
3+
coverage

.prettierrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"tabWidth": 2,
5+
"trailingComma": "all"
6+
}

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
1-
[![Code Climate](https://codeclimate.com/github/andela-nmartin/docms2/badges/gpa.svg)](https://codeclimate.com/github/andela-nmartin/docms2)
2-
[![Test Coverage](https://codeclimate.com/github/andela-nmartin/docms2/badges/coverage.svg)](https://codeclimate.com/github/andela-nmartin/docms2/coverage)
1+
[![Code Climate](https://codeclimate.com/github/n8e/docs_api_node/badges/gpa.svg)](https://codeclimate.com/github/n8e/docs_api_node)
2+
[![Test Coverage](https://codeclimate.com/github/n8e/docs_api_node/badges/coverage.svg)](https://codeclimate.com/github/n8e/docs_api_node/coverage)
3+
34
# Document Management System (Node, Express, Mongo)
45

5-
## Models
6-
The models contained are `users`, `documents` and `roles`. A document belongs to a `User` and is related to them using the `ownerId`. A `Role` is related to the `User` using the `id` field. Each `Document` has restrictions on the roles. A `Role` also relates to the `Document` using the `title`.
6+
## Models
7+
8+
The models contained are `users` and `documents`. A document belongs to a `User` and is related to them using the `ownerId`. A `Role` is related to the `User` using the `id` field. Each `Document` has restrictions on the roles. A `Role` also relates to the `Document` using the `title`.
79

810
## Testing
9-
Testing is done using the `superagent` node module which is installed via `npm` when you install all the other node modules in `package.json`. `superagent` is used to make requests to the api routes and receive responses. The tests are run on terminal using the command:
11+
12+
Testing is done using the `superagent` node module which is installed via `npm` when you install all the other node modules in `package.json`. `superagent` is used to make requests to the api routes and receive responses. The tests are run on terminal using the command:
13+
1014
```
11-
jasmine-node tests/ --verbose
15+
mocha tests/ --verbose
1216
```
1317

1418
## Express Routes
19+
1520
The routes are created using `express` routers. The server needs to be started using the terminal command `nodemon server.js`. Our server file is called `server.js`. The routes are defined in the `./server/routes/api.js` file.
1621

1722
## Mongo Database
18-
One needs an installation of `Mongodb` locally. Our database is called `docms`. We connect to it using the configurations in `./server/config/config.js` file.
23+
24+
One needs an installation of `Mongodb` locally. Our database is called `docs_api_node`. We connect to it using the configurations in `./server/config/config.js` file.
25+
1926
```
20-
'database': 'mongodb://localhost/docms',
27+
'database': 'mongodb://localhost/docs_api_node',
2128
```
29+
2230
This line in particular is needed. To use this database throughout the run-time of the application, one needs to run the command `mongod` on the terminal.
2331
The database needs to be dropped first, before the tests are run. It is dropped in the express server by the command:
32+
2433
```
2534
mongoose.connection.db.dropDatabase(function(err) {
2635
if (err) {
@@ -34,5 +43,4 @@ mongoose.connection.db.dropDatabase(function(err) {
3443
});
3544
```
3645

37-
38-
@3nj0y!
46+
@3nj0y!

0 commit comments

Comments
 (0)