diff --git a/client.d.ts b/client.d.ts new file mode 100644 index 0000000000..937231e954 --- /dev/null +++ b/client.d.ts @@ -0,0 +1,2 @@ +import * as feathers from './'; +export = feathers; \ No newline at end of file diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000000..0371ea4129 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,86 @@ +import * as express from 'express'; +import * as expressCore from "express-serve-static-core"; +import * as events from 'events'; + +declare function feathers(): feathers.Application; + +declare namespace feathers { + export var static: typeof express.static; + + type NullableId = number | string | null; + + interface Params { + query?: any; + } + + interface Service extends events.EventEmitter { + + /** + * Retrieves a list of all resources from the service. + * Provider parameters will be passed as params.query + */ + find(params?: Params, callback?: any): Promise; + + /** + * Retrieves a single resource with the given id from the service. + */ + get(id: number | string, params?: Params, callback?: any): Promise; + + /** + * Creates a new resource with data. + */ + create(data: T | T[], params?: Params, callback?: any): Promise; + + /** + * Replaces the resource identified by id with data. + * Update multiples resources with id equal `null` + */ + update(id: NullableId, data: T, params?: Params, callback?: any): Promise; + + /** + * Merges the existing data of the resource identified by id with the new data. + * Implement patch additionally to update if you want to separate between partial and full updates and support the PATCH HTTP method. + * Patch multiples resources with id equal `null` + */ + patch(id: NullableId, data: any, params?: Params, callback?: any): Promise; + + /** + * Removes the resource with id. + * Delete multiple resources with id equal `null` + */ + remove(id: NullableId, params?: Params, callback?: any): Promise; + + /** + * Initialize your service with any special configuration or if connecting services that are very tightly coupled + */ + setup(app?: Application, path?: string): void; + } + + interface FeathersUseHandler extends expressCore.IRouterHandler, express.IRouterMatcher { + (location: string, service: Service): T + } + + interface Application extends express.Application { + /** + * It either returns the Feathers wrapped service object for the given path + */ + service(location: string): Service; + + /** + * Registers a new service for that path and returns the wrapped service object + */ + service(location: string, service: Service, options?: any): Service; + + /** + * Initialize all services by calling each services .setup(app, path) method (if available) + */ + setup(): this; + + /** + * Register a service object + */ + use: FeathersUseHandler; + } +} + +export = feathers; diff --git a/package.json b/package.json index f081e973b6..53b034da5b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "feathers", "description": "Build Better APIs, Faster than Ever.", - "version": "2.0.3", + "version": "2.1.0", "homepage": "http://feathersjs.com", "repository": { "type": "git", @@ -14,6 +14,10 @@ "realtime" ], "main": "lib/index", + "types": [ + "./index.d.ts", + "./client.d.ts" + ], "author": "Feathers (http://feathersjs.com)", "contributors": [ "Eric Kryski (http://erickryski.com)", @@ -49,32 +53,33 @@ "node": ">= 4" }, "dependencies": { - "babel-polyfill": "^6.3.14", - "debug": "^2.1.1", - "events": "^1.1.0", - "express": "^4.12.3", + "@types/express": "~4.0.35", + "babel-polyfill": "^6.20.0", + "debug": "^2.6.0", + "events": "^1.1.1", + "express": "^4.14.0", "feathers-commons": "^0.8.7", - "rubberduck": "^1.0.0", + "rubberduck": "^1.1.1", "uberproto": "^1.2.0" }, "devDependencies": { - "babel-cli": "^6.3.17", - "babel-core": "^6.3.26", - "babel-plugin-add-module-exports": "^0.2.0", - "babel-preset-es2015": "^6.3.13", - "body-parser": "^1.13.2", + "babel-cli": "^6.18.0", + "babel-core": "^6.21.0", + "babel-plugin-add-module-exports": "^0.2.1", + "babel-preset-es2015": "^6.18.0", + "body-parser": "^1.15.2", "eslint-if-supported": "^1.0.1", - "feathers-rest": "^1.1.0", - "feathers-socketio": "^1.1.0", + "feathers-rest": "^1.5.3", + "feathers-socketio": "^1.4.2", "istanbul": "^1.1.0-alpha.1", - "jshint": "^2.6.3", - "mocha": "^3.0.0", - "nsp": "^2.2.0", - "q": "^1.0.1", + "jshint": "^2.9.4", + "mocha": "^3.2.0", + "nsp": "^2.6.2", + "q": "^1.4.1", "request": "^2.x", "rimraf": "^2.5.4", - "semistandard": "^9.1.0", - "socket.io-client": "^1.4.6" + "semistandard": "^9.2.1", + "socket.io-client": "^1.7.2" }, "browser": { "./lib/index": "./lib/client/index"