├── .eslintignore ├── .prettierrc ├── globals.js ├── docs ├── assets │ ├── swagger.png │ └── appy-api-screenshot.png ├── testing.md ├── questions.md ├── model-generation.md ├── swagger-documentation.md ├── soft-delete.md ├── quick-start.md ├── misc.md ├── support.md ├── authentication.md ├── introduction.md ├── metadata.md ├── route-customization.md ├── middleware.md ├── audit-logs.md └── querying.md ├── website ├── static │ └── img │ │ ├── joi.png │ │ ├── appy.png │ │ ├── favicon.png │ │ ├── oss_logo.png │ │ ├── querying.png │ │ ├── flexible_icon.png │ │ ├── powerful_icon.png │ │ ├── efficient_icon.png │ │ ├── favicon │ │ └── favicon.ico │ │ ├── rest-hapi-logo.png │ │ ├── rest-hapi-logo-alt.png │ │ └── appy-api-screenshot.png ├── publish.sh ├── versions.json ├── versioned_docs │ ├── version-1.6.x │ │ ├── testing.md │ │ ├── questions.md │ │ ├── model-generation.md │ │ ├── swagger-documentation.md │ │ ├── soft-delete.md │ │ ├── quick-start.md │ │ ├── misc.md │ │ ├── support.md │ │ ├── authentication.md │ │ ├── introduction.md │ │ ├── metadata.md │ │ ├── route-customization.md │ │ ├── middleware.md │ │ ├── audit-logs.md │ │ ├── querying.md │ │ └── validation.md │ ├── version-2.0.x │ │ ├── quick-start.md │ │ ├── introduction.md │ │ └── querying.md │ ├── version-3.0.x │ │ └── quick-start.md │ ├── version-2.2.x │ │ └── route-customization.md │ └── version-3.2.x │ │ └── middleware.md ├── data │ └── users.js ├── package.json ├── pages │ └── en │ │ ├── demo.js │ │ ├── users.js │ │ ├── help.js │ │ └── versions.js ├── sidebars.json ├── versioned_sidebars │ ├── version-3.0.x-sidebars.json │ └── version-1.6.x-sidebars.json ├── siteConfig.js ├── core │ └── Footer.js └── blog │ └── 2016-11-19-The-Problem-With-APIs.md ├── .npmignore ├── .gitignore ├── seed ├── linking-models │ ├── role_permission.model.js │ ├── user_permission.model.js │ └── group_permission.model.js ├── group.model.js ├── role.model.js ├── permission.model.js └── user.model.js ├── tests └── e2e │ ├── test-scenarios │ ├── scenario-5 │ │ └── models │ │ │ ├── linking-models │ │ │ └── segment_tag.model.js │ │ │ ├── video.model.js │ │ │ ├── tag.model.js │ │ │ └── segment.model.js │ ├── scenario-3 │ │ └── models │ │ │ ├── linking-models │ │ │ └── user_permission.model.js │ │ │ ├── hashtag.model.js │ │ │ ├── business.model.js │ │ │ ├── user-profile.model.js │ │ │ ├── permission.model.js │ │ │ ├── role.model.js │ │ │ └── user.model.js │ ├── scenario-4 │ │ └── models │ │ │ ├── facility.model.js │ │ │ └── building.model.js │ ├── scenario-2 │ │ └── models │ │ │ └── role.model.js │ └── scenario-1 │ │ └── models │ │ └── role.model.js │ ├── end-to-end.tests.js │ └── advance-assoc.tests.js ├── .github ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── workflows │ ├── test-on-pull.yml │ └── manual.yml ├── utilities ├── policy-generator.js ├── validation-helper.js ├── api-generator.js ├── log-util.js ├── model-generator.js ├── auth-helper.js └── test-helper.js ├── .eslintrc.js ├── LICENSE.txt ├── rest-hapi-cli.js ├── policies ├── add-document-scope.js ├── populate-duplicate-fields.js ├── track-duplicated-fields.js ├── add-by-meta-data.js └── authorize-document-creator.js ├── CONTRIBUTING.md ├── scripts └── seed.js ├── models └── audit-log.model.js ├── CODE_OF_CONDUCT.md └── package.json /.eslintignore: -------------------------------------------------------------------------------- 1 | coverage 2 | website 3 | docs -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "semi": false 4 | } 5 | -------------------------------------------------------------------------------- /globals.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | mongoose: {} 5 | } 6 | -------------------------------------------------------------------------------- /docs/assets/swagger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JKHeadley/rest-hapi/HEAD/docs/assets/swagger.png -------------------------------------------------------------------------------- /website/static/img/joi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JKHeadley/rest-hapi/HEAD/website/static/img/joi.png -------------------------------------------------------------------------------- /website/static/img/appy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JKHeadley/rest-hapi/HEAD/website/static/img/appy.png -------------------------------------------------------------------------------- /website/static/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JKHeadley/rest-hapi/HEAD/website/static/img/favicon.png -------------------------------------------------------------------------------- /website/static/img/oss_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JKHeadley/rest-hapi/HEAD/website/static/img/oss_logo.png -------------------------------------------------------------------------------- /website/static/img/querying.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JKHeadley/rest-hapi/HEAD/website/static/img/querying.png -------------------------------------------------------------------------------- /website/publish.sh: -------------------------------------------------------------------------------- 1 | GIT_USER=JKHeadley \ 2 | CURRENT_BRANCH=master \ 3 | USE_SSH=true \ 4 | yarn run publish-gh-pages -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .travis.yml 2 | _config.yml 3 | .idea 4 | tests 5 | .nyc_output 6 | coverage 7 | coverage.lcov 8 | docs 9 | website -------------------------------------------------------------------------------- /docs/assets/appy-api-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JKHeadley/rest-hapi/HEAD/docs/assets/appy-api-screenshot.png -------------------------------------------------------------------------------- /website/static/img/flexible_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JKHeadley/rest-hapi/HEAD/website/static/img/flexible_icon.png -------------------------------------------------------------------------------- /website/static/img/powerful_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JKHeadley/rest-hapi/HEAD/website/static/img/powerful_icon.png -------------------------------------------------------------------------------- /website/static/img/efficient_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JKHeadley/rest-hapi/HEAD/website/static/img/efficient_icon.png -------------------------------------------------------------------------------- /website/static/img/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JKHeadley/rest-hapi/HEAD/website/static/img/favicon/favicon.ico -------------------------------------------------------------------------------- /website/static/img/rest-hapi-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JKHeadley/rest-hapi/HEAD/website/static/img/rest-hapi-logo.png -------------------------------------------------------------------------------- /website/static/img/rest-hapi-logo-alt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JKHeadley/rest-hapi/HEAD/website/static/img/rest-hapi-logo-alt.png -------------------------------------------------------------------------------- /website/static/img/appy-api-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JKHeadley/rest-hapi/HEAD/website/static/img/appy-api-screenshot.png -------------------------------------------------------------------------------- /website/versions.json: -------------------------------------------------------------------------------- 1 | [ 2 | "3.2.x", 3 | "3.1.x", 4 | "3.0.x", 5 | "2.3.x", 6 | "2.2.x", 7 | "2.0.x", 8 | "1.9.x", 9 | "1.8.x", 10 | "1.7.x", 11 | "1.6.x" 12 | ] 13 | -------------------------------------------------------------------------------- /docs/testing.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: testing 3 | title: Testing 4 | sidebar_label: Testing 5 | --- 6 | 7 | If you have downloaded the source you can run the tests with: 8 | ``` 9 | $ npm test 10 | ``` 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #api/config.js 2 | api/node_modules 3 | *npm-debug.log 4 | .idea/ 5 | build 6 | node_modules 7 | .nyc_output 8 | coverage 9 | coverage.lcov 10 | 11 | # local uploads 12 | uploads/* 13 | 14 | # OSX files 15 | *.DS_Store -------------------------------------------------------------------------------- /website/versioned_docs/version-1.6.x/testing.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: version-1.6.x-testing 3 | title: Testing 4 | sidebar_label: Testing 5 | original_id: testing 6 | --- 7 | 8 | If you have downloaded the source you can run the tests with: 9 | ``` 10 | $ npm test 11 | ``` 12 | -------------------------------------------------------------------------------- /website/data/users.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | // Please add your logo in alphabetical order of caption. 3 | { 4 | caption: 'appy', 5 | image: '/img/appy.png', 6 | infoLink: 'https://www.appyapp.io', 7 | pinned: true 8 | } 9 | // Please add your logo in alphabetical order of caption. 10 | ] 11 | -------------------------------------------------------------------------------- /docs/questions.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: questions 3 | title: Questions 4 | sidebar_label: Questions 5 | --- 6 | 7 | If you have any questions/issues/feature requests, please feel free to open an [issue](https://github.com/JKHeadley/rest-hapi/issues/new). We'd love to hear from you! 8 | 9 | For more options please see the [help page](https://resthapi.com/help). -------------------------------------------------------------------------------- /seed/linking-models/role_permission.model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | module.exports = function() { 4 | const Types = mongoose.Schema.Types 5 | 6 | const Model = { 7 | Schema: { 8 | enabled: { 9 | type: Types.Boolean, 10 | default: true 11 | } 12 | }, 13 | modelName: 'role_permission' 14 | } 15 | 16 | return Model 17 | } 18 | -------------------------------------------------------------------------------- /seed/linking-models/user_permission.model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | module.exports = function() { 4 | const Types = mongoose.Schema.Types 5 | 6 | const Model = { 7 | Schema: { 8 | enabled: { 9 | type: Types.Boolean, 10 | default: true 11 | } 12 | }, 13 | modelName: 'user_permission' 14 | } 15 | 16 | return Model 17 | } 18 | -------------------------------------------------------------------------------- /seed/linking-models/group_permission.model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | module.exports = function() { 4 | const Types = mongoose.Schema.Types 5 | 6 | const Model = { 7 | Schema: { 8 | enabled: { 9 | type: Types.Boolean, 10 | default: true 11 | } 12 | }, 13 | modelName: 'group_permission' 14 | } 15 | 16 | return Model 17 | } 18 | -------------------------------------------------------------------------------- /tests/e2e/test-scenarios/scenario-5/models/linking-models/segment_tag.model.js: -------------------------------------------------------------------------------- 1 | var mongoose = require('mongoose') 2 | 3 | module.exports = function() { 4 | var Types = mongoose.Schema.Types 5 | 6 | var Model = { 7 | Schema: { 8 | rank: { 9 | type: Types.Number, 10 | required: true 11 | } 12 | }, 13 | modelName: 'segment_tag' 14 | } 15 | 16 | return Model 17 | } 18 | -------------------------------------------------------------------------------- /website/versioned_docs/version-1.6.x/questions.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: version-1.6.x-questions 3 | title: Questions 4 | sidebar_label: Questions 5 | original_id: questions 6 | --- 7 | 8 | If you have any questions/issues/feature requests, please feel free to open an [issue](https://github.com/JKHeadley/rest-hapi/issues/new). We'd love to hear from you! 9 | 10 | For more options please see the [help page](https://resthapi.com/help). -------------------------------------------------------------------------------- /tests/e2e/test-scenarios/scenario-3/models/linking-models/user_permission.model.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const mongoose = require('mongoose') 4 | 5 | module.exports = function() { 6 | const Types = mongoose.Schema.Types 7 | 8 | const Model = { 9 | Schema: { 10 | enabled: { 11 | type: Types.Boolean, 12 | default: true 13 | } 14 | }, 15 | modelName: 'user_permission' 16 | } 17 | 18 | return Model 19 | } 20 | -------------------------------------------------------------------------------- /website/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "examples": "docusaurus-examples", 4 | "start": "docusaurus-start", 5 | "build": "docusaurus-build", 6 | "publish-gh-pages": "docusaurus-publish", 7 | "write-translations": "docusaurus-write-translations", 8 | "version": "docusaurus-version", 9 | "rename-version": "docusaurus-rename-version" 10 | }, 11 | "devDependencies": { 12 | "docusaurus": "^1.14.7" 13 | }, 14 | "version": "3.0.0" 15 | } 16 | -------------------------------------------------------------------------------- /tests/e2e/test-scenarios/scenario-4/models/facility.model.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function(mongoose) { 4 | const modelName = 'facility' 5 | const Types = mongoose.Schema.Types 6 | const Schema = new mongoose.Schema( 7 | { 8 | name: { 9 | type: Types.String 10 | } 11 | }, 12 | { collection: modelName } 13 | ) 14 | 15 | Schema.statics = { 16 | collectionName: modelName, 17 | routeOptions: { 18 | associations: {} 19 | } 20 | } 21 | 22 | return Schema 23 | } 24 | -------------------------------------------------------------------------------- /docs/model-generation.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: model-generation 3 | title: Model Generation 4 | sidebar_label: Model Generation 5 | --- 6 | 7 | In some situations models may be required before or without endpoint generation. For example some hapi plugins may require models to exist before the routes are registered. In these cases rest-hapi provides a ``generateModels`` function that can be called independently. 8 | 9 | > **NOTE:** See [scripts/seed.js](https://github.com/JKHeadley/rest-hapi/blob/master/scripts/seed.js) for an example usage of ``generateModels``. 10 | 11 | -------------------------------------------------------------------------------- /tests/e2e/test-scenarios/scenario-3/models/hashtag.model.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = function(mongoose) { 4 | const modelName = 'hashtag' 5 | const Types = mongoose.Schema.Types 6 | const Schema = new mongoose.Schema( 7 | { 8 | text: { 9 | type: Types.String, 10 | required: true 11 | } 12 | }, 13 | { collection: modelName } 14 | ) 15 | 16 | Schema.statics = { 17 | collectionName: modelName, 18 | routeOptions: { 19 | associations: {} 20 | } 21 | } 22 | 23 | return Schema 24 | } 25 | -------------------------------------------------------------------------------- /website/pages/en/demo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | const React = require('react') 9 | 10 | class Demo extends React.Component { 11 | render() { 12 | return ( 13 |