Mad
♥️ to Chris Pena for putting together the video.
With NodeJS installed, you can quickly scaffold your first REST and real-time API by following these few steps.
ProTip: Make sure you have set up your development environment properly. We recommend node v5.x+.
-
Install the Feathers CLI.
$ npm install -g feathers-cli
-
Create a directory for your new app.
$ mkdir feathers-chat $ cd feathers-chat/
-
Generate the app and confirm all the prompts with the default by pressing enter:
$ feathers generate
-
Generate a new service. When asked
What do you want to call your service?
, typemessages
and confirm the other prompts with the default:$ feathers generate service
-
Start your brand new app! 💥
$ npm start
-
Go to localhost:3030 to see the homepage. The message CRUD service is available at localhost:3030/messages
-
Create a new message on the localhost:3030/messages endpoint. This can be done by sending a POST request with a REST client like Postman or via CURL like this:
$ curl 'http://localhost:3030/messages/' -H 'Content-Type: application/json' --data-binary '{ "text": "Hello Feathers!" }'
In just a couple minutes we created a real-time API that is accessible via REST and websockets! We now have a database backed API that already provides CORS, authentication, pagination, logging, error handling and a few other goodies.
This is a great start! Let's take this a bit further and build our first real application.
ProTip: If you chose a different database than the default NeDB you will have to start the database server and make sure the connection can be established.