-
Notifications
You must be signed in to change notification settings - Fork 7
Home
- Api
-
Class representing the client api.
- DB
-
The DB Client Interface.
- Realtime
-
The Realtime Client Interface.
- FileStore
-
The FileStore Client Interface.
Class representing the client api.
Kind: global class
-
Api
- new Api(projectId, url)
- .setToken(token)
- .setProjectId(projectId)
.Mongo() ⇒DB
.Postgres() ⇒DB
.MySQL() ⇒external:Db
-
.DB(db) ⇒
DB
-
.call(service, endpoint, params, [timeout]) ⇒
Promise
-
.FileStore() ⇒
FileStore
Create an instance of the Client API.
Param | Type | Default | Description |
---|---|---|---|
projectId | string |
The Project Id. | |
url | string |
"/" |
Base url of space-cloud server. |
Example
import { API } from 'space-api';
const api = new API('my-project', 'http://localhost:4122');
Initialse the Client Api with the JWT token
Kind: instance method of Api
Param | Type | Description |
---|---|---|
token | string |
The signed JWT token received from the server on successful authentication. |
Set the new Project Id
Kind: instance method of Api
Param | Type | Description |
---|---|---|
projectId | string |
The Project Id. |
api.Mongo() ⇒ DB
DB
Deprecated
Returns a Mongo DB client instance
Kind: instance method of Api
Returns: DB
- DB client instance
api.Postgres() ⇒ DB
DB
Deprecated
Returns a Postgres DB client instance
Kind: instance method of Api
Returns: DB
- DB client instance
Deprecated
Returns a MySQL Db client instance
Kind: instance method of Api
Returns: external:Db
- Db client instance
api.DB(db) ⇒ DB
Returns a DB client instance
Kind: instance method of Api
Returns: DB
- DB client instance
Param | Type | Description |
---|---|---|
db | string |
The alias name of the database |
Calls an endpoint from the remote service
Kind: instance method of Api
Returns: Promise
- Returns a promise
Param | Type | Default | Description |
---|---|---|---|
service | string |
The name of service | |
endpoint | string |
The name of endpoint to be called | |
params | Object |
The params to be sent to the remote service | |
[timeout] | string |
5000 |
Timeout in milliseconds |
Example
api.call('my_service', 'my_endpoint', { msg: 'Remote services are awesome!' }, 1000)
.then(res => {
if (res.status === 200) {
// res.data contains the response given by the function
console.log('Response:', res.data);
return;
}
}).catch(ex => {
// Exception occured while processing request
});
api.FileStore() ⇒ FileStore
Returns a FileStore client instance
Kind: instance method of Api
Returns: FileStore
- FileStore client instance
The DB Client Interface.
Kind: global external
See: https://github.com/spaceuptech/space-api-js/wiki/DB
The Realtime Client Interface.
Kind: global external
See: https://github.com/spaceuptech/space-api-js/wiki/Realtime
The FileStore Client Interface.
Kind: global external
See: https://github.com/spaceuptech/space-api-js/wiki/FileStore