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
- Migrated Bootstrap to CDN, and removed static versions
- Created a bit of a layout using Bootstrap that advertises and gives
credit to the facilities used
- Added finishing touches to user facilities
- Added install folder with .sql file that developers can use to seed
their database
- Updated mmod.css to restyle the 404 from nk, and then I changed the
name to nk-mvc.css
- Updated all areas according to changes in nk and nk-mysql, too much to
list at this point.
- Updated README
- Updated version
Change-Id: I268bbad2c7eeab152cd1b6cc59e96185c5402af6
Signed-off-by: Richard Winters <rik@mmogp.com>
Copy file name to clipboardExpand all lines: README.md
+124-15
Original file line number
Diff line number
Diff line change
@@ -1,32 +1,143 @@
1
-
# nk-mvc
1
+
# nk-mvc ( v0.1.0 )
2
2
3
-
The 'Hello World!' example of a nodakwaeri MVC Application.
3
+
The 'Hello World!' example of - and project template for - a nodakwaeri MVC Application.
4
4
5
+
<b>Notice:</b>
6
+
Please keep in mind that while the version is '0'.<anything> ( the key part being '0' in front ), this package should be considered - and used as if it were - a pre-release. Things should work, but you may find issues. I would encourage you to please report them [here](https://github.com/mmod/nk-mvc/issues).
5
7
6
-
##Installation
7
8
8
-
To get started, open terminal/shell/command prompt and browse to the root of your application. Clone the nk-mvc repository:
9
+
## Downloading
10
+
11
+
To get started, open terminal/shell/command prompt and browse to the root of where you'll store your application. Clone the nk-mvc repository:
When finished we need to install the dependencies. Unless I'm wrong:
17
+
Alternatively, you could just download a [zip of the source](https://github.com/mmod/nk-mvc/archive/master.zip) and extract it to where you wish to keep the application.
18
+
19
+
When finished we need to install the dependencies but before we do that we need to make sure we have some prerequisites in place.
20
+
21
+
22
+
## Required Prerequisites
23
+
24
+
Whether you wish to build or not build any of the components, the [nk-mysql documentation](http://github.com/mmod/nk-mysql) will guide you in ensuring you meet any and all requirements. Once you've gone through the respective documentation, a link is provided which will redirect you back here in order to complete installation.
25
+
26
+
27
+
## The actual installation
28
+
29
+
Since we already have nk-mvc, all we need to do is install the dependencies for it and we'll be good to go. Assuming we've ensured we meet all of the prerequisites/requirements...
15
30
16
31
```
17
-
path_to_application/> npm install .
32
+
path_to_nk-mvc-application/> npm install .
18
33
```
19
34
20
-
Should do the trick, but in case it doesn't:
35
+
...will do the trick.
21
36
37
+
38
+
## Configuration
39
+
40
+
### Seed the Database
41
+
42
+
In the root of your nk-mvc application, you'll find a directory named <i>install</i> containing a file named <i>seed.sql</i>. If you open the file you will see in 2 places exists the string: <b><ReplaceWithAHashedPassword></b>. You will need to replace these with - you guessed it - a hashed password.
43
+
44
+
In order to do this, create a file <i>whatever.js</i> in the root of your application, and add the following code to it (replacing <YourPasswordHere> and <YourSecretHere>) with your actual password and secret, respectively:
Please note, that the secret can be a 10 character or 100 character string; nodakwaeri will use it to generate a 256-bit salt. You will want to remember the string you used for the secret so as you build your user system out you have it to generate the hash again for comparison during login.
57
+
58
+
Save the file and execute it using node.js:
59
+
60
+
```node
61
+
path_to_nk-mvc_application/>node whatever.js
62
+
```
63
+
64
+
Alternatively, you could just throw the console.log bit into the index.js file and start your server...either way:
65
+
66
+
The hash function let's you supply a secret that it then hashes; so that you can supply it either with the same string over and over, or by invoking a function that will return a secret from elsewhere, since - being realistic - the more acceptable and professionally practiced way to build a <i>secure</i> authentication system is to store secrets and/or encrypt passwords on an external device; but we're not going to do that just to play around are we?
67
+
68
+
Take the hashed password printed on your console window / terminal as a result of the console.log (wherever it came from), and add it to the .sql file - replacing the existing <ReplaceWithHashedPassword> values where they are.
69
+
70
+
BTW, I really don't mind if you want to pretend to be me, but you could go ahead and change the other identifying info in the .sql file as well - like the username, name, etc. And unless you want to have to make modifications to the account controller and model, and don't care to even run the example, I'd suggest you only change database names, database user names, and database passwords; leaving the table names and columns as they are until you're ready to start developing.
71
+
72
+
Run/Execute the contents of the .sql file either in MySQL Workbench, or via your favorite means (in the future nk-mysql will have additional tools which will provide features similar to Microsoft's Migrations, but until then...)
73
+
74
+
### Configure the Application
75
+
76
+
To finish configuring your application, open the config.js file in the root of your nk-mvc application. In this file, notice the URL and SERVER members of both the development and production configuration schemas; You probably need to update at least one of them, as well as any mail config (though we can't use it yet, its there to remind me to build that in!). If you're developing locally and not using a host entry (meaning you're typing localhost into your browser), then the URL <i>should</i> be http://localhost:XXXX 'lest you want problems.
77
+
78
+
The only other changes you may need to make, are in the database sections of the configuration file.
79
+
80
+
You're all configured now, moving on.
81
+
26
82
27
83
## Usage
28
84
29
-
At this time, all examples can be found within the app/ directory of the source.
Some console output should have alerted you that the application is running. Try visiting http://localhost:7724 if you did not make any changes to the configuration...otherwise I'm guessing you know what you're doing :)
102
+
103
+
104
+
## Developing with nk-mvc
105
+
106
+
<i>At this time, all examples can be found within the app/ directory of the source.</i>
107
+
108
+
### The Gist
109
+
110
+
Like any MVC Framework, it's up to the developers to supply the Controllers, Models, and Views which make up the application.
111
+
112
+
#### Controllers
113
+
114
+
Controllers are where we set/get session variables, they're where we invoke data queries, and they are where we place most application or business logic specific to our application.
115
+
116
+
Properties of a controller object are considered the different 'actions' the controller provides to the application; simply adding a new action to an existing controller will yield a new usable URL: domain/<controller>/<action>. Adding 'Post' to the end of a controller action name will let the framework know that it should be called when a POST is made upon that URL.
117
+
118
+
Take a look at the account.js file in the /app/controllers/ directory to see some examples.
119
+
120
+
121
+
<i>Currently there are no examples for API transactions, however -> responding to API requests will take place directly in the controller. Example coming soon.</i>
122
+
123
+
#### Models
124
+
125
+
Models are where we define data queries, and data properties.
126
+
127
+
Members of a model file's object are considered 'models'; You could essentially have numerous related models within a single model file. From within a model, we are able to access the database object, and are typically fed a callback to make data processing implicitly asynchronous.
128
+
129
+
Take a look at the account.js file in the /app/models/ directory to see an example.
130
+
131
+
#### Views
132
+
133
+
Views are where we define what the end user is going to see when the response is set (and we are returning a content type of text/html). This involves preparation of a layout as well as content for the layout.
134
+
135
+
Each directory under /app/views (aside from shared), denotes a set of views for each controller's various actions. The _shared directory under /app/views allows developers to create 'layouts' or 'templates' which are available to the entire application.
136
+
137
+
Take a look at the various files within the /app/views/ directory to see some examples.
138
+
139
+
<b>A little note</b>
140
+
<i>To change your favicon, just replace the favicon.ico that exists in the assets/ directory. Icons cache in Windows, so after dropping your new favicon you may notice that in file explorer the old icon is still displaying (yea, until you restart). Rest assured that once you've deleted your browsers cache, in the browser the proper favicon will show (even before restarting).</i>
30
141
31
142
32
143
## Development
@@ -36,11 +147,9 @@ Feel free to fork the repository and submit pull requests. As the framework dev
0 commit comments