Skip to content

developernka/nptt-server-mongoDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nptt-Server-MongoDB

Nptt-Server-MongoDB is REST API server implementation built on top Node.js and Express.js with Mongoose.js for MongoDB integration. Access control follows OAuth 2.0 spec with the help of OAuth2orize and Passport.js.

Running project

Manual

You need to have Node.js and MongoDB installed.

Run server

npm start # alias for node bin/www

Create demo data

npm run-script generate # alias for node generateData.js

Make Requests

Create and refresh access tokens:

http POST http://localhost:1337/api/oauth/token grant_type=password client_id=android client_secret=SomeRandomCharsAndNumbers username=myapi password=abc1234 http POST http://localhost:1337/api/oauth/token grant_type=refresh_token client_id=android client_secret=SomeRandomCharsAndNumbers refresh_token=[REFRESH_TOKEN]

Create your article data:

http POST http://localhost:1337/api/articles title='New Article' author='John Doe' description='Lorem ipsum dolar sit amet' images:='[{"kind":"thumbnail", "url":"http://habrahabr.ru/images/write-topic.png"}, {"kind":"detail", "url":"http://habrahabr.ru/images/write-topic.png"}]' Authorization:'Bearer ACCESS_TOKEN'

Update your article data:

http PUT http://localhost:1337/api/articles/EXISTING_ARTICLE_ID title='Updated Article' author='Jane Doe' description='This is now updated' Authorization:'Bearer ACCESS_TOKEN'

Get your data:

http http://localhost:1337/api/users/info Authorization:'Bearer ACCESS_TOKEN' http http://localhost:1337/api/articles Authorization:'Bearer ACCESS_TOKEN'

Tests

npm test # alias for node ./test/server.test.js

Modules used

Some of non-standard modules used:

Test modules:

Tools used

  • httpie - command line HTTP client

JSHint

npm install jshint -g jshint libs/**/*.js generateData.js

Author

Created and maintained by Developer NKA ([@developernka]).

License

Nptt-Server-MongoDB is available under the MIT license. See the LICENSE.md file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published