You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-13Lines changed: 38 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,21 @@
1
1
## Quick start
2
2
3
3
- Make sure Node.js and NPM should be installed (I prefer to do it using NVM). This project was developed on Node 0.6.x.
4
-
- Install dependencies with NPM: "npm install ." in the project root
4
+
- Install project dependencies with NPM by running the following command in the terminal (project root):
5
+
6
+
npm install .
7
+
5
8
- Configure the ports for the application (for multiple environments: dev, test, production) and also the settings for the MongoDB connection (you can either host MongoDB locally or try a free hosting provider such as MongoLab). The config data is in /config
6
-
- Run 'npm start' or 'NODE_ENV=production node app.js' to start the server
9
+
- Start the server:
10
+
11
+
a) Production
12
+
13
+
npm start
14
+
15
+
b) Development (note that if you want to load all the files uncompressed you should visit http://<server>:<port>/dev.html):
16
+
17
+
node app.js
18
+
7
19
8
20
## App structure
9
21
@@ -23,20 +35,35 @@ Frontend:
23
35
- '/css' and '/img' stores the static stylesheets and images needed
24
36
- '/test' has the logic for the test runner (with Mocha), and specs
25
37
26
-
## Dev gotchas with Jake
38
+
## Dev gotchas with Jake (in the terminal)
27
39
28
-
You can empty the database by running 'jake db:empty' and populate it with data by running 'jake db:populate[20]' for ex (that will empty db and insert 20 new records).
40
+
Empty the database:
41
+
42
+
jake db:empty
43
+
44
+
Populate database with data:
45
+
46
+
jake db:populate[20]
47
+
48
+
That will empty db and insert 20 new records).
49
+
50
+
Compress & concatenate assets (one file for JS & one file for CSS):
51
+
52
+
jake app:assets
29
53
30
54
## Testing
31
55
32
56
I've chosen Mocha for all tests in this project. To run unit tests & function tests use 'npm test' in the application root (make sure things are setup properly -> the app can connect to MongoDB, can bind to the specified port).
33
-
If you're testing on Windows, install Mocha globally: 'npm install [email protected] -g' and run 'mocha --ui bdd --recursive --reporter spec --timeout 10000 --slow 300' instead.
34
-
For client side tests, open 'http://server:port/test'.
57
+
If you're testing on Windows, run the following commands in the terminal:
The first command installs mocha globally and the second one runs the test suite.
35
63
36
-
## Build
64
+
For client side tests, open the browser
37
65
38
-
I've concatenated and minified the css into a single file and the JS into 2 files: one file that contains libraries (such as jQuery, underscore etc.. including RequireJS) and another file that includes all the RequireJS modules (minified and concatenated with r.js, the RequireJS optimizer).
39
-
To see all the original files during development, use http://host:port/development.html.
66
+
http://<server>:<port>/test
40
67
41
68
## Small JS styleguide for the project
42
69
@@ -49,15 +76,13 @@ To see all the original files during development, use http://host:port/developme
49
76
50
77
## Browser compatibility
51
78
52
-
I haven't had time to properly test the app, but it should work fine in modern browsers.
79
+
I haven't had time to properly test the app, but it *should* work fine in modern browsers.
53
80
54
81
## TODO / Improvements:
55
82
56
83
Client-side:
57
84
58
-
- Compress & concatenate JS & CSS (each into single file, using build script)
59
85
- Add popups after deleting / saving client
60
-
- Put each template into an element with an id, concatenate them (using a build script) into a single HTML file which is fetched at startup and export the object containing them (this way there's only 1 request instead of <numberoftemplates> requests, they are kept out of the main html file and each into their own files during development).
61
86
- More tests
62
87
63
88
Server-side:
@@ -66,7 +91,7 @@ Server-side:
66
91
- Split contents of utils.js into multiple files (more specific categories)
67
92
- Implement content-negotiation (return 406 Not Acceptable where needed)
68
93
[this is present by default in Express 3.x, upgrade when it is stable enough]
69
-
- Implement authentication and check authorization when modifying resources
94
+
- Implement authentication and check authorization when modifying resources (OAuth maybe?)
70
95
- Implement ETags properly for the /clients and /clients/:id GET routes
71
96
72
97
## Useful links that helped me while developing this app
0 commit comments