HTTP method | Service layer method | Real-time event |
---|---|---|
GET /messages | messages.find() | - |
GET /messages/1 | messages.get(1) | - |
POST /messages | messages.create(body) | message created |
PUT /messages/1 | messages.update(1, body) | message updated |
PATCH /messages/1 | messages.patch(1, body) | message patched |
DELETE /users/1 | messages.remove(1, body) | message removed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Koa = require('koa'); | |
const app = new Koa(); | |
app.use(async (ctx, next) => { | |
// Store the start time | |
const start = Date.now(); | |
// Pass to the next middleware and wait for everything to return | |
await next(); |
HTTP method | Service layer method |
---|---|
GET /messages | messages.find() |
GET /messages/1 | messages.get(1) |
POST /messages | messages.create(body) |
PUT /messages/1 | messages.update(1, body) |
PATCH /messages/1 | messages.patch(1, body) |
DELETE /messages/1 | messages.remove(1, body) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MessageService { | |
// Find a list of resources | |
find(params) {}, | |
// Get a single resource by its id | |
get(id, params) {}, | |
// Create a new resource | |
create(data, params) {}, | |
// Replace an existing resource by its id with data | |
update(id, data, params) {}, | |
// Merge new data into a resource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ChatApplication { | |
login (username, password) {}, | |
logout (user) {}, | |
joinChatRoom(roomId, user) {} | |
sendMessage(message, roomId, user) {} | |
sendPrivateMessage(message, receiverId, user) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dat://5757862252cb4131892a5a88c23570ba3e013cef0ecc95344172745b8af0b6ef |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const feathers = require('@feathersjs/feathers'); | |
const express = require('@feathersjs/express'); | |
const mongodb = require('mongodb'); | |
const service = require('feathers-mongodb'); | |
mongodb.MongoClient.connect(`mongodb://localhost:27017`).then(client => { | |
const app = express(feathers()) | |
.configure(express.rest()) | |
.use('/messages', express.json(), service({ | |
Model: client.db('feathers').collection('messages') |
I hereby claim:
- I am daffl on github.
- I am daffl (https://keybase.io/daffl) on keybase.
- I have a public key ASCYmmwbPb3c_9R7roOLDRTIkkg1pQe4g2CIiAJZ1Pd0Ywo
To claim this, I am signing this object:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const app = require('express')(); | |
const http = require('http').Server(app); | |
const io = require('socket.io')(http); | |
let counter = 0; | |
app.get('/', function(req, res){ | |
res.sendFile(__dirname + '/index.html'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const feathers = require('@feathersjs/feathers'); | |
const express = require('@feathersjs/express'); | |
const socketio = require('@feathersjs/socketio'); | |
// Heroku will set the PORT environment variable. Otherwise use 3030 | |
const port = process.env.PORT || 3030; | |
// Creates an Express compatible Feathers application | |
const app = express(feathers()); |