Skip to content

Commit

Permalink
Add restivus templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfred J. Kwak committed Feb 12, 2017
1 parent 34c770c commit bf113a3
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 0 deletions.
1 change: 1 addition & 0 deletions generators/app/templates/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
15 changes: 15 additions & 0 deletions generators/app/templates/.meteor/.finished-upgraders
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file contains information which helps Meteor properly upgrade your
# app when you run 'meteor update'. You should check it into version control
# with your project.

notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
notices-for-facebook-graph-api-2
1.2.0-standard-minifiers-package
1.2.0-meteor-platform-split
1.2.0-cordova-changes
1.2.0-breaking-changes
1.3.0-split-minifiers-package
1.4.0-remove-old-dev-bundle-link
1.4.1-add-shell-server-package
1 change: 1 addition & 0 deletions generators/app/templates/.meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
7 changes: 7 additions & 0 deletions generators/app/templates/.meteor/.id
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file contains a token that is unique to your project.
# Check it into your repository along with the rest of this directory.
# It can be used for purposes such as:
# - ensuring you don't accidentally deploy one app on top of another
# - providing package authors with aggregated statistics

118uo1u8wjvlhfrieo5
9 changes: 9 additions & 0 deletions generators/app/templates/.meteor/packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

ecmascript
ajkwak:restivus
ajkwak:restivus-swagger
2 changes: 2 additions & 0 deletions generators/app/templates/.meteor/platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
browser
server
1 change: 1 addition & 0 deletions generators/app/templates/.meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
METEOR@1.4.2.6
Empty file.
12 changes: 12 additions & 0 deletions generators/app/templates/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "<%= appName %>",
"private": true,
"scripts": {
"start": "meteor run"
},
"dependencies": {
"babel-runtime": "^6.22.0",
"bcrypt": "^1.0.2",
"meteor-node-stubs": "~0.2.0"
}
}
29 changes: 29 additions & 0 deletions generators/app/templates/server/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {Restivus} from 'meteor/ajkwak:restivus';

const Api = new Restivus({
apiPath: 'api',
version: 'v1',
defaultHeaders: {
'Content-Type': 'application/json'
},
useDefaultAuth: true,
prettyJson: true,
enableCors: true
});

// Add Restivus Swagger configuration
// - meta, tags, params, definitions
Api.swagger = {
meta: {
swagger: '2.0',
info: {
version: '<%= version %>',
title: '<%= title %>'
}
}
};

// Generate Swagger to route /api/v1/swagger.json
Api.addSwagger('swagger.json');

export default Api;
48 changes: 48 additions & 0 deletions generators/app/templates/server/users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {Meteor} from 'meteor/meteor';
import Api from '/server/api';

// Enable user endpoints if authentication is enabled
if (Api._config.useDefaultAuth) {
// Generates: POST on /api/v1/users and GET, DELETE /api/v1/users/:id for
// Meteor.users collection
Api.addCollection(Meteor.users, {
excludedEndpoints: ['getAll', 'put'],
routeOptions: {
authRequired: true
},
endpoints: {
get: {
swagger: {
description: 'Returns user with given ID.',
responses: {
200: {
description: 'One user.'
}
}
}
},
post: {
authRequired: false,
swagger: {
description: 'Add user.',
responses: {
200: {
description: 'Return user that was added.'
}
}
}
},
delete: {
roleRequired: 'admin',
swagger: {
description: 'Delete user.',
responses: {
200: {
description: 'Successful delete.'
}
}
}
}
}
});
}

0 comments on commit bf113a3

Please # to comment.