Giter Site home page Giter Site logo

feathersjs / feathers Goto Github PK

View Code? Open in Web Editor NEW
14.9K 227.0 736.0 35.49 MB

The API and real-time application framework

Home Page: https://feathersjs.com

License: MIT License

JavaScript 0.40% HTML 3.63% TypeScript 95.97%
feathersjs javascript nodejs browser react-native framework feathers real-time typescript

feathers's Introduction

Feathers - The API and real-time application framework

CI Maintainability Test Coverage Download Status Discord

Feathers is a full-stack framework for creating web APIs and real-time applications with TypeScript or JavaScript.

Feathers can interact with any backend technology, supports many databases out of the box and works with any frontend like React, VueJS, Angular, React Native, Android or iOS.

Getting started

Get started with just three commands:

$ npm create feathers my-new-app
$ cd my-new-app
$ npm run dev

To learn more about Feathers visit the website at feathersjs.com or jump right into the Feathers guides.

Contributing

To start developing, clone this repository, then run:

cd feathers
npm install

To run all tests run

npm test

Individual tests can be run in the module you are working on:

cd packages/feathers
npm test

License

Copyright (c) 2023 Feathers contributors

Licensed under the MIT license.

feathers's People

Contributors

8ballbombom avatar abraaoalves avatar ashotn avatar b-steel avatar bertho-zero avatar cciocov avatar corymsmith avatar daddywarbucks avatar daffl avatar dependabot-preview[bot] avatar deskoh avatar eddyystop avatar ekryski avatar fossprime avatar fratzinger avatar glavin001 avatar greenkeeper[bot] avatar greenkeeperio-bot avatar j2l4e avatar jorgenvatle avatar kc-dot-io avatar kidkarolis avatar larkinscott avatar loris avatar marshallswain avatar nsainaney avatar superbarne avatar vodnicearv avatar vonagam avatar whollacsek 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  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

feathers's Issues

Express middleware

Express accepts functions and/or express apps as middleware.

var app = require('express')();
app.use(function(){
});
app.use('/path', require('./otherapp'));

It's really useful to split an express app into smaller modules with single responsibilities. Feathers doesn't support it.

Preconditions in a service

Hi,
i want to create a service with preconditions for the HTTP verbs POST, PUT, DEL. Only registered users should be allowed to POST new entries and only the creator should be able to PUT or DEL them. Express have a mechanism to assign multiple callbacks for an verb method . How can i do that for a service in feathers? I'm working on a feathers implementation for the MEAN-Stack.

HTTP status codes

hi,

how does one send an HTTP status code other than 200, either on success or on error? i'm trying to follow HTTP API best practices, something similar to this.

cheers!

Extend express server

The Feathers server should directly extend from Express to avoid passing it around and having to call things like this.config.app all the time. We are very likely to never use Feathers without HTTP anyway.

empty 'query' object in params argument

Considering the following service:

var Service = {
    find : function (params, callback) {
        // ...
        console.log(params);
    }
};

When called via the REST API the console output is:

GET /users
{ query : {} }

But if you call the same method through a socket connection:

primus.send('users::find', {}, function () {})
{}

In my opinion it should either be {} or { query : {} } in both cases to be consistent, while I think {} would make the most sense.

Upgrade to SocketIO 1.0

SocketIO 1.0 got released. We should migrate the provider and the examples for the 1.0 release.

SockJS provider

It would be nice to have a SockJS-based provider available. It's kinda like socket.io but more websocket-y.

Socket libraries should only set params.query

Brought up in canjs/canjs-feathers#2 for REST calls the user can only directly modify params.query. Maybe, in order to be consistent, SocketIO and Primus calls should do the same thing and map params from the client into params.query instead of passing them directly. That way it would be consistent and other params properties can only be set on the server.

We need to support route specific middleware

In lib > application.js inside the use() function we need to take all arguments and then take the the first one as the path, and the last one as the service. The rest are middleware that should be proxied to express in the order that they come in.

Add typescript definitions

Has anyone asked for Typescript definitions or tried using feathers with Typescript? I'm tempted to make them but unsure if they're actually wanted.

Use Metalsmith as site generator, add articles and plugins section

For the 1.0 release we should update the way we generate the http://feathersjs.com website. Currently we are using a custom Grunt task that grabs the readme.md from master and renders it into the template.

This works pretty well but it would be really nice to implement a simple static site generator Metalsmith that does the same thing but also adds a section for Feathers plugins (maybe there is a way to grab them directly from NPM) and articles. Articles can be how-tos and just submitted into the docs folder in the main repository. This hopefully makes it easy to contribute new ones.

Security: remove x-powered-by by default.

I think it's a good idea to remove the x-powered-by header by default. Typical users do not need to know what server technology we are using. Plus, it gives hackers a basic set of attack vectors that will and won't work.

Does anybody have any objections to disabling the x-powered-by header by default?

Koa version

I can imagine the desire for something supports the feathers service api but with Koa. Do you guys have thoughts on this?

REST and Socket.io in same application

Hi can i have both modes turned on at the same time in my application, some client side apps will use REST while the others (like my admin backend for real time service response) will use the socket.io module

Clustering / Multi-Core Server

Support for Cluster to create a multi-core Node.js server.

This could be a plugin for Feathers, or a built-in feature as is Socket.io and Primus.


Example of using Cluster:

Source http://adamnengland.wordpress.com/2013/01/30/node-js-cluster-with-socket-io-and-express-3/

cluster = require("cluster")
http = require("http")
numCPUs = require("os").cpus().length
RedisStore = require("socket.io/lib/stores/redis")
redis = require("socket.io/node_modules/redis")
pub = redis.createClient()
sub = redis.createClient()
client = redis.createClient()
if cluster.isMaster
  i = 0
  while i < numCPUs     cluster.fork()     i++   cluster.on 'fork', (worker) ->
    console.log 'forked worker ' + worker.process.pid
  cluster.on "listening", (worker, address) ->
    console.log "worker " + worker.process.pid + " is now connected to " + address.address + ":" + address.port
  cluster.on "exit", (worker, code, signal) ->
    console.log "worker " + worker.process.pid + " died"
else
  app = require("express")()
  server = require("http").createServer(app)
  io = require("socket.io").listen(server)
  io.set "store", new RedisStore(
    redisPub: pub
    redisSub: sub
    redisClient: client
  )
  server.listen 8000
  app.get "/", (req, res) ->
    res.sendfile(__dirname + '/index.html');
  io.sockets.on "connection", (socket) ->
    console.log 'socket call handled by worker with pid ' + process.pid
    socket.emit "news",
      hello: "world"

setup service method not called in async plugin

Even though the setup method isn't called, the services work properly.

// app.js
require('feathers')()
    .configure(function () {
        var app = this;
        app.use('/setup', {
            get : function (id, params, callback) {
                callback(null, {});
            },
            setup : function (app) {
                console.log('setup');
            }
        });

        setTimeout(function () {
            app.use('/nosetup', {
                get : function (id, params, callback) {
                    callback(null, {});
                },
                setup : function (app) {
                    console.log('no setup :(');
                }
            });
        }, 100);
    })
    .listen(8080);
$ node app.js
setup

A swagger plugin for automatic API docs

Also a must have feature, if you want to share your api to other developers

var todos = {
  version: 1,
  find: {
    doc : {
        description: 'Return a todo list',
        // The params that the method receive
        params: [ { 
          name: 'limit', 
          description: 'determine the number of items to return',
          type: 'numeric',
          required: false
        } ],
        // An output example
        output: [{
           name: 'Todo name',
           status: 'finished'
        }]
    }
    method: function(params...){...}
  }
}

feathers().configure('documentation', true)....

Then you can call it just like GET /v1/docs/todos if documentation is set to false it the docs path will not be initialised

It was inspired on Action Hero api documentation method

Mongoose plugin

I showed Feathers to my friends who are developing an app for a competition.
They are using MongoDB. I recommended Mongoose, since they are new to Node.js and such tools.
To get them started off I created a Mongoose Service that could be easily reused.
See example: https://github.com/DylanYoung/CoLab/blob/glavin/services/users.js

I plan on creating feathers-mongoose-service as a NPM package soon and publishing it. Just wanted to see if there is any interest ๐Ÿ‘

Proposed usage:

var mongooseService = require("feathers-mongoose-service");
app.use("/users", new mongooseService(connection, { mongoose schema });

Update

I will be using this repo here: https://github.com/Glavin001/feathers-mongoose-service

Feathers http server

It should not create a server but instead listening an existing server (http, https, express, etc).

Custom Events

It would be nice to have a way to send custom events to websocket clients. Is there an easy way to tap into the event system for that?

Refactor how we handle events

Turn the server into an event emitter.

feathry.service('/api/users'/, {});

// -> '/api/users created'
// -> '/api/users updated'
// -> '/api/users destroyed

socket.emit('/api/users::create', {}, function(error, data) {});

Request without Content-Type application/json have empty body

Request without Content-Type application/json have empty body.

I am using Postman REST Client and neglected to set the Content-Type to application/json which resulted in the body not being parsed by express.json and it was passing data = {} into my services' create handler.

I suggest that, since JSON is the notation being used for serialization with Feathers, that if the Content-Type is blank, it should default to application/json.

Update to Express 4.0

When Express 4.0 is officially out we should update as well. Might be a good time for a 1.0 release.

Todo example - getById() with String

I was playing around with the todo example and I found a little bug. When I try to access this url: /todos/0 I get an error message saying Todo not found. (And I know there is a todo with id 0).

I discovered that the TodoStore.Get() method receives the id as a string then passes it along to the TodoStore.getById() method which compares the passed in id to the ids in the todos list using the === operator. Since the ids stored in the todos list are numbers and do not match the type of the passed in string, the comparison fails.

The get method is never used in the todos example, so it probably never showed up.

Some possible solutions are to convert the string to a number before passing it to getById or use the == operator so that it will not check type as well.

Preconditions in a service (Socket.IO)

Hi,
I implemented the REST authentication mentioned in #43 .
Now I want the same for the Socket.IO communication.
A user can use the find and get service but for create, update and delete he has to be logged in. Is there a way with feathersjs to implement that?

Socket.io events - advanced pub/sub - listen to specific services and not others

See https://github.com/feathersjs/feathers/blob/master/lib/providers/socketio.js#L29

Currently when there is an event it's broadcasted to all connected sockets. However, I would lie to utilize Socketio rooms to improve performance such that the client can subscribe and unsubscribe to rooms that are watch particular services or even updates to particular nodes with a given id.

I may in some cases want to join the room watching for changes to only the TODO service but not Users service (too many users? Or UI does not depend on such info).
Furthermore, I may want to watch for updates to a particular id of a given service.

I wanted to check for interest for making this a built in standard feature of feathers, or I will make a separate Socketio provider plugin.

Add Grunt

At least want this for running tests.

Send Custom Errors (REST)

Hi, I'm in the process of creating an API using feathers. So far, it looks really promising!

One thing I haven't quite figured out is how to return custom error responses, especially ones that are well-formed JSON.

I got the following:

get: function(id, params, callback) {
  callback({
    status: 404,
    message: {info: 'Not found.'}
  });
},

I see that supplying an object with a status key allows me to set the HTTP status. (Is this documented somewhere?)

The response body is [object Object] though.

Create api versions

IMO is a must have feature, till now I can make by hand but will be nice if we can add just to the feather object version.

var todos = {
  version: 1,
  find: function() {...}
}

And when consume the api just you will call GET /v1/todos/

Support HTTPS

Maybe we can do this via .configure(ssl) which handle the ssl keys and overwrites our app.listen call.

Remove SocketIO default configuration

We should investigate if the SocketIO default configuration for transports should be changed to websockets first (or what other options make sense for production settings).

io.set('transports', [
  'xhr-polling', 'websocket', 'flashsocket',
  'htmlfile', 'jsonp-polling'
]);

authentication and user sessions example

It would be nice to see how do you propose to implement authentication/session services with feathers. Esp. how to treat such actions as user activation, login with external accounts in standard manner.

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.