var app = require('express')();
will need to write var app = require('feathers')();
// POST http://localhost:8000/todos { "description": "You have to do dishes!" } // GET http://localhost:8000/todos [ { "id": 0, "description": "You have to do dishes!" } ]
<script src="http://localhost:8000/socket.io/socket.io.js" /> <script type="text/javascript"> var socket = io.connect('http://localhost:8000/'); socket.on('todos created', function(todo) { console.log('Someone created a new Todo', todo); }); socket.emit('todos::create', { description: 'You have to do something real-time!' }, {}, function(error, todo) { socket.emit('todos::find', {}, function(error, todos) { console.log('Server todos:', todos); }); }); </script>
var myService = { find: function(params, callback) {}, get: function(id, params, callback) {}, create: function(data, params, callback) {}, update: function(id, data, params, callback) {}, remove: function(id, params, callback) {}, setup: function(app) {} }
Source: https://habr.com/ru/post/206092/
All Articles