Skip to content

Commit 80ef2ae

Browse files
readme update
1 parent 01ee0b1 commit 80ef2ae

File tree

2 files changed

+8
-106
lines changed

2 files changed

+8
-106
lines changed

readme.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This is a simple SPA built using [Koa](http://koajs.com/) (2.3) as the backend a
2828
- Prettier
2929
- Babel
3030
- PM2
31-
- MySQL
31+
- MySQL with Knex
3232
- log4js
3333
- And more...
3434

@@ -41,11 +41,14 @@ npm install
4141
# serve using nodemon with hot reload
4242
npm run watch
4343

44-
# build for production with prettier
44+
# build for production with prettier and babel
4545
npm run build
4646

4747
# serve in production using the pm2 ecosystem.json file
4848
npm run start-production
49+
50+
# run prettier on the project
51+
npm run pretty
4952
```
5053

5154
## General Information
@@ -67,7 +70,7 @@ As mentioned in the frontend code, the user authentication process is this:
6770
- User create an account
6871
- User logs in
6972
- The server sends and `accessToken` and a `refreshToken` back
70-
- We take the `accessToken` and decoded it using `jwt-decode`. This gets us the logged in user's information. We stick this in the Vuex variable `user`. Then we store the `refreshToken` amd `accessToken`.
73+
- We take the `accessToken` and decode it using `jwt-decode`. This gets us the logged in user's information. We stick this in the Vuex variable `user`. Then we store the `refreshToken` amd `accessToken`.
7174
- Each protected endpoint will be expecting you to attach the `accessToken` you have to the call (using Authentication: Bearer). After a short amount of time, the server will respond with `401 TOKEN EXPIRED`. When you see this - that means you need to send your `refreshToken` and `user.email` to the endpoint that deals with `accessToken` refreshing. Once you do that, you'll received a brand new `accessToken` and `refreshToken`.
7275
- Repeat the process as needed.
7376

@@ -79,11 +82,11 @@ The `src` folder is the heart of the program. I'll go over its subfolders now.
7982

8083
### controllers
8184

82-
We use controllers to keep our router thin. The controller's responsibility is to manage the request body and make sure it's nice and clean when it eventually gets sent to a `model` to make database calls. There are two controller files present - one for user signup/login/forgot... and one for notes.
85+
We use controllers to keep our router thin. The controller's responsibility is to manage the request body and make sure it's nice and clean when it eventually gets sent to a `model` to make database calls. There are two controller files present - one for user signup/login/forgot... and one for notes. Note: the `UserActionController.js` is a little different then normal controllers, as I believe the actions of a user signup/login/forgot/reset are seperate from the normal actions for a user - so that's why `UserActionController.js` in written in a more *functional* way.
8386

8487
### db
8588

86-
Here is our database setup. This project uses Knex to manage migarations and execute queries. I initially wrote raw SQL queries for the program, but the need for a migrations maanager pushed me towards an ORM for the MySQL database. Knex is awesome - very powerful, easy to use and make queries, and the migarations are nice to have for sure - especially for testing.
89+
Here is our database setup. This project uses Knex to manage migrations and execute queries. I initially wrote wrote all the MySQL calls using raw SQL, but the need for a migrations maanager pushed me towards an ORM for the MySQL database. Knex is awesome - very powerful, easy to use and make queries, and the migrations are nice to have for sure - especially for testing.
8790

8891
### middleware
8992

@@ -97,10 +100,6 @@ Our models folder contains two model files - one for users and one for notes. Th
97100

98101
Very simple - here are our routes. I've broken it down into two files - this keeps things in control. Each route is nice and thin - all it's doing is calling a controller. Some routes are using that jwt middleware I mentioned earlier. Koa make it really nice and easy to add middleware to a route. Very cool.
99102

100-
### sql
101-
102-
I provided the sql code here you'll need when creating your database. I was hoping to find a nice database-migration library for node - but unfortunately I came up empty-handed. I tried TJ's - but I think it's not really supported anymore - didn't work for me using the latest Node and ES6/7 syntax. I'm keeping my eye out for one - let me know if you use one you like.
103-
104103
### static
105104

106105
Static files - just used for the favicon.

src/sql/koa_vue_notes_2017-08-04.sql

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

0 commit comments

Comments
 (0)