A project with AngularJS + Node.js + MongoDB + Karma that mimics a friendship-based news feed (i.e. friends can see their friends' posts and their own). Here's how it works:
- Pick one of the users to enter
- See updates (posts) from friends
- Post a new update
- Refresh the page to be able to enter as another user
Run npm install
followed by bower install
.
Run npm install
.
Make sure to properly set the constants that will point to the server side app in app.js
:
- AppConfig.api_url - By default, it will be pointing to a deployed app online.
- AppConfig.image_server_url - By default, it will be pointing to a deployed app online.
Run grunt
for building and grunt serve
for preview.
For your convenience, there is a deployed app online in case you don't want to set up the server application on your machine. The client app points to it by default.
Make sure to properly set the MongoDB connection URI MONGO_URI
as an environment variable. The dotenv plug-in allows setting this through the .env
file.
Make sure to run the seed script seed.js
by running node seed.js
. This will create 3 users with the following relationships:
- John is friends with Jessica and Peter
- Jessica is friends with John
- Peter is friends with John
- Note that Jessica is not friends with Peter
The seed script will create no posts.
Run npm start
If environment variable PORT
is not set, it will run at port 3000.
Assume 1
for the user ID in the examples below:
POST /posts
Content-Type: application/json
{ userId: 1, content: 'This is a new post' }
GET /posts?userId=1
GET /users
GET /users?userId=1
Run grunt build
and grab a distribution-ready version from the dist
folder.
Running grunt test
will run the unit tests with karma.
Copyright 2015 Natã Barbosa.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.