Coder Social home page Coder Social logo

ac-socialapi's Introduction

Social API

This is the code example for AvenueCode Node and Express Course.

Installation

npm install

This will install all the dependencies and grunt-cli (the last one as a global package).

###Dependencies

Run Server

To run the server you just have to execute: $ grunt serverExpress

Interacting With API

After you have set up the server and executed $ grunt serverExpress, you can access http://localhost:3000 and use the interface to test responses and behavior. (This code is in 'serverExpress/public/index.html').

Endpoints Available

  • '/users/?q=query' - GET - List of all users or search by name using query
  • '/users/' - POST - Create user
  • '/users/me' - GET - Get logged user
  • '/users/me' - PUT - Update logged user profile
  • '/users/available' - GET - Get all users that can be added as a friend
  • '/users/:userId' - GET - Get user with given ID
  • '/users/:userId' - DELETE - Delete user with given ID
  • '/users/password/:userId' - PUT - Change user's password
  • '/friendships/' - GET - Get all friendships
  • '/friendships/me' - GET - Get all logged user's friendships
  • '/friendships/requests' - GET - Get all friendships that requests logged user
  • '/friendships/requested' - GET - Get friendships that were requested by logged user
  • '/friendships/:friendId' - GET - Get friendships between logged user and user with the ID provided
  • '/friendships/:friendId' - POST - Invite user with the ID provided
  • '/friendships/:friendId' - PUT - Accept request from user with ID provided
  • '/friendships/:friendId' - DELETE - Reject requests from user with ID provided
  • '/friendships/vip/:friendId' - POST - Set friendship with user as VIP
  • '/friendships/vip/:friendId' - DELETE - Unset friendship with user as VIP
  • '/friendships/block/:friendId' - POST - Block friendship with user
  • '/friendships/block/:friendId' - DELETE - Block friendship with user

All endpoints are authenticated/authorized, but creating user. This endpoint is public. And the endpoint to delete user is authorized only to a admin.

Auth

Authorization/Authentication is done using token, by JWT. You can choose to use authentication by cookie or by Authorization header in the request.

Test

We are using mocha, supertest and should to do Unit Testing. We also added blanket as a coverage tool.

Obs.: Windows users BE WARNED! To execute the grunt test task you need to perform a change in the blanket lib. In the file node_modules/blanket/src/index.js (lines 128-134) we have this code:

 //instrument js files
 require.extensions['.js'] = function(localModule, filename) {
   var pattern = blanket.options("filter"),
       reporter_options = blanket.options("reporter_options"),
       originalFilename = filename,
 		  inputFilename = filename;
   filename = blanket.normalizeBackslashes(filename);

Please, kindly change it to:

 //instrument js files
 require.extensions['.js'] = function(localModule, filename) {
   var pattern = blanket.options("filter"),
       reporter_options = blanket.options("reporter_options"),
       originalFilename = filename,
 			 inputFilename = blanket.normalizeBackslashes(filename);
   filename = inputFilename;

Otherwise a exception will explode in the console because of windows path. Blanket Issue 491

ac-socialapi's People

Contributors

andrebot avatar edudiego avatar hcbelias avatar lscoder avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.