This is a template project using Node Express as backend and Angular as frontend in CoffeeScript.
The project is a extremely simple blog app to demonstrate the framework, features includes sign in/sign up, list all posts and create a new post.
MongoDB is used as database and JWT token for authentication instead of cookie since tokens are more secure and mobile friendly (token vs cookie).
git clone https://github.com/FindBoat/angular-express-coffee [project-name]
cd [project-name]
npm install
npm install -g coffeescript
In dev mode:
npm run dev
In prod mode:
npm run build
npm run start
/.app `compiled js for server and manage, created on the fly`
/manage
/server
/public `compiled js and css for client, created on the fly`
/src
/client
/app
/auth `Views, controllers for sign in/sign up features`
/blocks `Reusable codes throughout different projects`
/core `Services used throughout the app`
/posts `Views, controllers for posts features`
app.module.coffee `Define the overall app module`
index.jade
styles.styl
/server `CoffeeScript for server code`
/config
/controllers `Each controller is responsible for a single resource request`
/models
app.coffee
routes.coffee `Route follows RESTful rule and requests are routed to the corresponding controller`
/manage `Convenient management codes`
Instead of using cookie for authentication, I choose JWT due to better security and mobile friendly. After user login/signup, token is returned to client. For client, each request should contain 'x-access-token' in the HTTP header.
APIs follow RESTful rules, in this project, user and post are two resources and have corresponding route and APIs. Server uses different controllers and client uses Angular $resource.
Since Express framework supports Jade & Stylus, we don't need to do much work to compile them. Boostrap-styl & nib are used, so we add few lines of code at src/server/app.coffee to config stylus compilation. Coffee is compiled into .app for server and manage code, and public/client for client code.
Instead of grouping code into /controllers, /services, /directives etc., it is recommended to group by features (otherwise you're gonna end up w/ huge folders when project becomes larger).
- express-coffee The server side code is mostly inspired by this project.
- ng-demos The Angular style and code organization are inspired by this project. TODO: Write credits
See LICENSE
pull requests are welcome