Added basic rest api
This commit is contained in:
parent
903375a102
commit
8dc1ec63f2
5 changed files with 79 additions and 2 deletions
|
|
@ -65,3 +65,4 @@ nspangler:autoreconnect
|
||||||
saucecode:timezoned-synced-cron
|
saucecode:timezoned-synced-cron
|
||||||
meteorhacks:kadira
|
meteorhacks:kadira
|
||||||
meteorhacks:zones
|
meteorhacks:zones
|
||||||
|
nimble:restivus
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,7 @@ mongo-id@1.0.6
|
||||||
mongo-livedata@1.0.12
|
mongo-livedata@1.0.12
|
||||||
mys:fonts@0.0.2
|
mys:fonts@0.0.2
|
||||||
natestrauser:publish-performant-counts@0.1.2
|
natestrauser:publish-performant-counts@0.1.2
|
||||||
|
nimble:restivus@0.8.12
|
||||||
npm-bcrypt@0.9.3
|
npm-bcrypt@0.9.3
|
||||||
npm-mongo@2.2.34
|
npm-mongo@2.2.34
|
||||||
nspangler:autoreconnect@0.0.1
|
nspangler:autoreconnect@0.0.1
|
||||||
|
|
@ -126,6 +127,7 @@ service-configuration@1.0.11
|
||||||
session@1.1.7
|
session@1.1.7
|
||||||
sha@1.0.9
|
sha@1.0.9
|
||||||
shell-server@0.3.0
|
shell-server@0.3.0
|
||||||
|
simple:json-routes@2.1.0
|
||||||
spacebars@1.0.15
|
spacebars@1.0.15
|
||||||
spacebars-compiler@1.1.3
|
spacebars-compiler@1.1.3
|
||||||
srp@1.0.10
|
srp@1.0.10
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,10 @@ Feature: Test all secundary pages
|
||||||
|
|
||||||
Scenario: Check that other non visible pages work well
|
Scenario: Check that other non visible pages work well
|
||||||
Given a list of non visible pages ids and contents
|
Given a list of non visible pages ids and contents
|
||||||
| status | Status |
|
| status | Status |
|
||||||
| error | Upps |
|
| error | Upps |
|
||||||
|
# FIXME: find a way to monitor json pages
|
||||||
|
# | api/v1/status/last-fire-detected | updateAt |
|
||||||
|
# | api/v1/status/last-fire-check | description |
|
||||||
|
# | api/v1/status/active-fires-count | total |
|
||||||
Then I check that all non visible pages works properly
|
Then I check that all non visible pages works properly
|
||||||
|
|
|
||||||
|
|
@ -16,3 +16,4 @@ import './feedback';
|
||||||
import './cron';
|
import './cron';
|
||||||
import './isMaster';
|
import './isMaster';
|
||||||
import './segfaults';
|
import './segfaults';
|
||||||
|
import './rest';
|
||||||
|
|
|
||||||
69
imports/startup/server/rest.js
Normal file
69
imports/startup/server/rest.js
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
/* global Restivus */
|
||||||
|
/* eslint-disable import/no-absolute-path */
|
||||||
|
|
||||||
|
import { Meteor } from 'meteor/meteor';
|
||||||
|
import Fires from '/imports/api/Fires/Fires';
|
||||||
|
import SiteSettings from '/imports/api/SiteSettings/SiteSettings';
|
||||||
|
import ActiveFiresCollection from '/imports/api/ActiveFires/ActiveFires';
|
||||||
|
|
||||||
|
Meteor.startup(() => {
|
||||||
|
const apiV1 = new Restivus({
|
||||||
|
useDefaultAuth: true,
|
||||||
|
apiPath: 'api',
|
||||||
|
version: 'v1',
|
||||||
|
prettyJson: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// Generates: POST on /api/users and GET, DELETE /api/users/:id for
|
||||||
|
// Meteor.users collection
|
||||||
|
/* apiV1.addCollection(Meteor.users, {
|
||||||
|
* excludedEndpoints: ['getAll', 'put'],
|
||||||
|
* routeOptions: {
|
||||||
|
* authRequired: true
|
||||||
|
* },
|
||||||
|
* endpoints: {
|
||||||
|
* post: {
|
||||||
|
* authRequired: false
|
||||||
|
* },
|
||||||
|
* delete: {
|
||||||
|
* roleRequired: 'admin'
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }); */
|
||||||
|
|
||||||
|
apiV1.addCollection(Fires, {
|
||||||
|
excludedEndpoints: ['put', 'post', 'patch', 'delete'],
|
||||||
|
// excludedEndpoints: ['getAll', 'put', 'post', 'patch', 'delete'],
|
||||||
|
routeOptions: {
|
||||||
|
authRequired: false
|
||||||
|
},
|
||||||
|
endpoints: {
|
||||||
|
get: {
|
||||||
|
action: function getFire() {
|
||||||
|
return Fires.findOne(new Meteor.Collection.ObjectID(this.urlParams.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Maps to: /api/v1/status/last-fire-check
|
||||||
|
apiV1.addRoute('status/last-fire-check', { authRequired: false }, {
|
||||||
|
get: function get() {
|
||||||
|
return SiteSettings.findOne({ name: 'last-fire-check' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Maps to: /api/v1/status/last-fire-detected
|
||||||
|
apiV1.addRoute('status/last-fire-detected', { authRequired: false }, {
|
||||||
|
get: function get() {
|
||||||
|
return ActiveFiresCollection.findOne({}, { sort: { when: -1 } });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Maps to: /api/v1/status/last-fire-detected
|
||||||
|
apiV1.addRoute('status/active-fires-count', { authRequired: false }, {
|
||||||
|
get: function get() {
|
||||||
|
return { total: ActiveFiresCollection.find({}).count() };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue