├── .gitignore ├── LICENSE.txt ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 18 | .grunt 19 | 20 | # node-waf configuration 21 | .lock-wscript 22 | 23 | # Compiled binary addons (http://nodejs.org/api/addons.html) 24 | build/Release 25 | 26 | # Dependency directory 27 | # https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git 28 | node_modules 29 | 30 | # Optional npm cache directory 31 | .npm 32 | 33 | # Optional REPL history 34 | .node_repl_history 35 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | BSD License 2 | 3 | For AppHub software 4 | 5 | Copyright (c) 2015-present, AppHub, Inc. All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without modification, 8 | are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name AppHub nor the names of its contributors may be used to 18 | endorse or promote products derived from this software without specific 19 | prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AppHub Reference Server 2 | 3 | This is an example server for deploying build updates to the [AppHub client](https://github.com/AppHubPlatform/apphub-ios). 4 | 5 | See the [AppHub docs](http://docs.apphub.io/v1.0/docs/self-hosting) for full documentation. 6 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var app = express(); 3 | 4 | var GET_BUILD_TYPE = 'GET-BUILD'; 5 | var NO_BUILD_TYPE = 'NO-BUILD'; 6 | 7 | app.get('/projects/:projectUid/build', function (req, res) { 8 | var projectUid = req.params.projectUid; 9 | var appVersion = req.query.app_version 10 | 11 | // Change to true if there is a newer build available for this version 12 | // of the app. 13 | var buildIsAvailable = false; 14 | 15 | var resultData; 16 | if (buildIsAvailable) { 17 | resultData = { 18 | type: GET_BUILD_TYPE, 19 | project_uid: projectUid, 20 | 21 | // A consistent id for the build, such as the key or hash. 22 | // The AppHub client uses this id to determine whether the 23 | // most current build has changed. 24 | uid: '', 25 | 26 | // Name for the build. 27 | name: 'Build Name', 28 | 29 | // Description for the build. 30 | description: '', 31 | 32 | // URL of the zipped build. Does not necessarily have to be 33 | // an s3 url. 34 | s3_url: '', 35 | 36 | // Epoch time in milliseconds since 1970 when the build was 37 | // created. This is only used for metadata, not to determine 38 | // whether the build should be used. 39 | created: 0, 40 | 41 | // Native app versions for which the build is compatible. 42 | // The official AppHub client only uses the values of the object, not the keys. 43 | app_versions: { 44 | '1.0': '1.0', 45 | }, 46 | }; 47 | } else { 48 | resultData = { 49 | type: NO_BUILD_TYPE, 50 | }; 51 | } 52 | 53 | res.setHeader('Content-Type', 'application/json'); 54 | res.end(JSON.stringify({ 55 | status: 'success', 56 | data: resultData, 57 | })); 58 | 59 | }); 60 | 61 | var server = app.listen(3000, function () { 62 | var port = server.address().port; 63 | 64 | console.log('Example app listening at port', port); 65 | }); 66 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "apphub-simple-server", 3 | "version": "0.1.0", 4 | "description": "AppHub reference server.", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/AppHubPlatform/apphub-server.git" 9 | }, 10 | "author": "AppHub )", 11 | "license": "BSD-3-Clause", 12 | "bugs": { 13 | "url": "https://github.com/AppHubPlatform/apphub-server/issues" 14 | }, 15 | "homepage": "https://github.com/AppHubPlatform/apphub-server", 16 | "dependencies": { 17 | "express": "^4.13.3" 18 | } 19 | } 20 | --------------------------------------------------------------------------------