The Employee API is a RESTful API to get information from each employee. The information includes:
- Background information
- Skill Ratings (protected access)
- Current and past projects
- Deparment information
- Project information
- Lower database hits to 1 read for common operations
API:
- Authentication required for skills: login and auto-expiring keys
- Passwords are Bcrypted (Hash + Salt) before storing
- Password Protection for skill ratings
- Organize folder structure: http://code.tutsplus.com/tutorials/introduction-to-the-mean-stack--cms-19918
- Finish org chart for top level
Directive: UserService: handle the login
Don't inject service into directive, do it on the controller.
- vendor.js app.js
- https://www.codefellows.org/blogs/quick-intro-to-gulp-js /assets/js/vendor/**/*.js -> /assets/js/vendor.min.js
- http://travismaynard.com/writing/no-need-to-grunt-take-a-gulp-of-fresh-air
- How to do top nav. Look at second example: http://stackoverflow.com/questions/15686155/conditional-partials-in-angular-js
mongo use baseball
mongoexport --db baseball --collection users --out baseball_users.json mongoexport --db baseball --collection logins --out baseball_logins.json mongoexport --db baseball --collection keys --out baseball_keys.json
mongoimport --db baseball --collection users --file baseball_users.json --jsonArray --stopOnError mongoimport --db baseball --collection logins --file baseball_logins.json --jsonArray --stopOnError mongoimport --db baseball --collection keys --file baseball_keys.json --jsonArray --stopOnError
npm outdated --depth 0
Returns JSON feed of all employees and their IDs
curl -i -X GET http://localhost:5000/users
Returns JSON feed of one of more users specified by id. If you pass a valid key you will receive protected user information.
curl -i -X GET http://localhost:5000/users/{id},{id}
curl -i -X GET http://localhost:5000/users/{id},{id}?key={validKey}
Adds a new user to the collection
curl -i -X POST -H 'Content-Type: application/json' -d
'{"name": "Jose Pulgar", "headshot": "http://goo.gl/dofijdf", "startDate": "2014-01-01", "jobTitle": "Manager"}' http://localhost:5000/users?key={validKey}
Modifies required user information (name, headshot, job title and start date)
curl -i -X PUT -H 'Content-Type: application/json' -d '{"jobTitle": "CEO"}' http://localhost:5000/users/{id}?key={validKey}
Modifies a user skill and ratings
curl -i -X PUT -H 'Content-Type: application/json' -d '[{"title": "HTML", "rating": "5.0"}, {"title": "CSS", "rating": "4.5"}]' http://localhost:5000/users/{id}/skills?key={validKey}
Deletes a user
curl -i -X DELETE http://localhost:5000/users/{id}?key={validKey}
Returns JSON feed of all project names and their IDs
curl -i -X GET http://localhost:5000/projects
Returns JSON feed of one and more projects with user IDs that belong to them
curl -i -X GET http://localhost:5000/projects/{id},{id}
Adds a new project
curl -i -X POST -H 'Content-Type: application/json' -d '{"name": "Baseball Card" }' http://localhost:5000/projects?key={validKey}
Modify a project
curl -i -X PUT -H 'Content-Type: application/json' -d '{"name": "Awesome Baseball Card" }' http://localhost:5000/projects/{id}?key={validKey}
Add a user(s) to a project
curl -i -X PUT http://localhost:5000/projects/{id}/members/{id}?key={validKey}
Deletes a user from a project
curl -i -X DELETE http://localhost:5000/projects/{id}/members/{id}?key={validKey}
Deletes a project
curl -i -X DELETE http://localhost:5000/projects/{id}?key={validKey}
Returns valid key or empty string. The valid key expires in MongoDB after x number of seconds. You should save this key as a cookie. Only store hashed passwords on server: http://devsmash.com/blog/password-authentication-with-mongoose-and-bcrypt
curl -i -X POST -H 'Content-Type: application/json' -d '{"username": "jpulgar", "password": "securePassword!!!" }' http://localhost:5000/logins
===
{
"_id" : "John Smith",
"headshot": "http://goo.gl/oafjewnefa",
"startDate": ISODate("2014-02-01T06:00:00Z"),
"jobTitle": "UX Architect",
"username": "jpulgar",
"password": "$2a$10$FEUvnoMB73s6T4aSZiZDyOi/2KJ92Pz6bQC1UmyRr.EM3bc2I9TXG",
"level": 1,
"email": "[email protected]",
"skype": "johnsmithsears",
"employeeType": "FTE",
"department": "FED",
"manager": "First Last",
"directs": ["First Last", "First Last"],
"strengths": ["Leadership", "Prototyping"],
"skills": [
{
"title": "User Research",
"rating": "3.5"
},
{
"title": "Information Architecture",
"rating": "4.0"
}
]
}
{
"level" : 3,
"self" : "Jose Pulgar",
"_id" : ObjectId("534eb2cd483362d60e3356e6"),
"createdAt" : ISODate("2014-04-16T16:41:49.297Z"),
"edit" : [
"Manager1",
"Manager2",
"Manager3",
"Test",
"Contributor1",
"Contributor2",
"Contributor3"
]
}
These instructions are for Mac. It assumes you already have Homebrew (http://brew.sh/) installed.
Install MongoDB using Homebrew
brew update
brew install mongodb
Create symbolic link and run background MongoDB service
ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Create MongoDB's default data directory
sudo mkdir -p /data/db
sudo chown `id -u` /data/db
brew upgrade mongodb
- Example RESTful API: http://developers.flattr.net/api/resources/things/
- IP White Listing: https://www.npmjs.org/package/express-ipfilter https://www.npmjs.org/package/ipfilter
- Mongoose Schema validation: http://mongoosejs.com/docs/validation.html
- Express 3.x to 4.x: https://github.com/visionmedia/express/wiki/Migrating-from-3.x-to-4.x
- Error handling: http://blog.safaribooksonline.com/2014/03/12/error-handling-express-js-applications/