GithubHelp home page GithubHelp logo

node-web-api's Introduction

Node Basics

A repository for Node as a Web Api talk at Angle Brackets 2015 conference

Slides available here

Requirements

Clone the repo

git clone [email protected]:sartioli/node-web-api.git
cd node-web-api

01 Basic Server

cd 01-basic_server
node index.js

http://localhost:3000

02 Express

cd 02-express
npm install
node index.js

http://localhost:3000

03 Crud

cd 03-express
npm install
node index.js


curl -s -H "Content-Type: application/json" -X POST -d '{"name":"jessy","age":"3","type":"siamese"}' http://localhost:3000/cat | json

curl -s -H "Content-Type: application/json" -X POST -d '{"name":"sam","age":"5","type":"alley"}' http://localhost:3000/cat | json

curl -s -X GET http://localhost:3000/cat | json

curl -s -H "Content-Type: application/json" -X PUT -d '{"name":"sam","age":"8","type":"alley"}' http://localhost:3000/cat/sam | json

curl -s -X DELETE http://localhost:3000/cat/sam | json

04 MongoDB

https://www.mongodb.org/downloads

On Mac I recommend homebrew

brew up
brew install mongodb

cd 04-mongodb
npm install
nodemon index.js

# mongo commands
show dbs
use cats
db.cats.find()
db.cats.remove({})
use cats
db.dropDatabase()

05 Request

https://github.com/request/request

cd 05-request
npm install
forever start cat_server.js
forever start dog_server.js
forever list

curl -s -H "Content-Type: application/json" -X POST -d '{"name":"jessy","age":"3","type":"boxer"}' http://localhost:3000/dog | json

curl -s -H "Content-Type: application/json" -X POST -d '{"name":"sam","age":"5","type":"bulldog"}' http://localhost:3000/dog | json

curl -s -X GET http://localhost:3000/dog | json

curl -s -H "Content-Type: application/json" -X PUT -d '{"name":"sam","age":"8","type":"bulldog"}' http://localhost:3000/dog/ID | json

curl -s -X DELETE http://localhost:3000/dog/ID | json

nodemon pet_server.js

http://localhost:3002/pets

06 Async

https://github.com/caolan/async

cd 06-async
npm install
forever start cat_server.js
forever start dog_server.js
forever list
nodemon pet_server.js

http://localhost:3002/pets

07 Non Blocking

https://github.com/caolan/async

cd 07-non_blocking
npm install
forever stopall
forever start cat_server.js
forever start dog_server.js
forever list
nodemon pet_server.js

http://localhost:3002/pets http://localhost:3002/ping

08 Redis

http://redis.io/download

On Mac I recommend homebrew

brew up
brew install redis

cd 08-redis
npm install
forever stopall
forever start cat_server.js
forever start dog_server.js
forever list
nodemon pet_server.js

curl -s -H "Content-Type: application/json" -X POST -d '{"name":"jessy","age":"3","type":"siamese"}' http://localhost:3000/cat | json

curl -s -H "Content-Type: application/json" -X POST -d '{"name":"sam","age":"5","type":"alley"}' http://localhost:3000/cat | json

curl -s -H "Content-Type: application/json" -X POST -d '{"name":"joe","age":"4","type":"garfield"}' http://localhost:3000/cat | json

curl -s -H "Content-Type: application/json" -X POST -d '{"name":"mama","age":"9","type":"tabby"}' http://localhost:3000/cat | json

curl -s -X GET http://localhost:3000/cat | json

http://localhost:3002/catname/ID

# Useful redis commands
redis-cli
set key value
get key
keys *
flushdb

09 Auth

cd 09-auth
npm install
gulp | bunyan -l info --color

http://localhost:3000/api/latest/basic/ping http://localhost:3000/api/latest/basic/config http://localhost:3000/api/latest/basic/echo/yourname

curl -s -H "Content-Type: application/json" -X POST -d '{"email":"[email protected]","password":"123"}' http://localhost:3000/api/latest/auth/signup | json

http://localhost:3000/api/latest/auth/ping

curl -s -X GET -H "x-access-token: TOKEN" http://localhost:3000/api/latest/auth/ping | json

curl -s -H "Content-Type: application/json" -X POST -d '{"email":"[email protected]","password":"123"}' http://localhost:3000/api/latest/auth/login | json

node-web-api's People

Contributors

samartioli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-web-api's Issues

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.