commit 37853cc8b44de302f1aac34e149213dd7f2e64d6 Author: Sagi Dayan Date: Fri Apr 27 15:23:19 2018 +0300 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f704d3c --- /dev/null +++ b/.gitignore @@ -0,0 +1,141 @@ + +# Created by https://www.gitignore.io/api/osx,node,macos,linux,windows + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a +deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage +(http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + + +### OSX ### + +# Icon must end with two \r + +# Thumbnails + +# Files that might appear in the root of a volume + +# Directories potentially created on remote AFP share + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + + +# End of https://www.gitignore.io/api/osx,node,macos,linux,windows diff --git a/Server/API/API.js b/Server/API/API.js new file mode 100644 index 0000000..b7d4358 --- /dev/null +++ b/Server/API/API.js @@ -0,0 +1,8 @@ +var express = require("express"); +var router = express.Router(); + +//Routers +const UpdateRouter = require('./Routers/UpdateRouter'); +router.use('/update', UpdateRouter); + +module.exports = router; diff --git a/Server/API/Routers/UpdateRouter.js b/Server/API/Routers/UpdateRouter.js new file mode 100644 index 0000000..f0e2b42 --- /dev/null +++ b/Server/API/Routers/UpdateRouter.js @@ -0,0 +1,15 @@ +const express = require("express"); +const DBUtils = require('../../Utils/DBUtil') + +const router = express.Router(); + +router.get('/latest', (req, res) => { + res.json({ + version: '0.0.1', + downloadLink: 'https://framez.woombit.com/download/framez0-0-1.apk' + }); +}); + + + +module.exports = router; diff --git a/Server/Config/Config.js b/Server/Config/Config.js new file mode 100644 index 0000000..e4a3404 --- /dev/null +++ b/Server/Config/Config.js @@ -0,0 +1,20 @@ +// Main Configuration file +// + +const DBAuth = require('../../private/DBAuth'); + + +module.exports = { + server: { + enableSSL: false, + ssl:{ + cert: '', + key: '', + passphrase: '' + }, + port: 3000 + }, + + mongoURL: `mongodb://${DBAuth.username}:${DBAuth.password}@ds159489.mlab.com:59489/framez_db`, + +}; diff --git a/Server/Schemas/AppVersion.js b/Server/Schemas/AppVersion.js new file mode 100644 index 0000000..31e99b9 --- /dev/null +++ b/Server/Schemas/AppVersion.js @@ -0,0 +1,12 @@ +const mongoose = require('mongoose'); + +const Schema = mongoose.Schema; + +const AppVersion = new Schema({ + version: String, + commit: String, + fileName: String, + uploaded: Date +}); + +module.exports = AppVersion diff --git a/Server/Utils/DBUtil.js b/Server/Utils/DBUtil.js new file mode 100644 index 0000000..43a73d4 --- /dev/null +++ b/Server/Utils/DBUtil.js @@ -0,0 +1,24 @@ +// Config module +const Config = require('../Config/Config.js') + +const mongoose = require('mongoose'); + +mongoose.connect(Config.mongoURL); + +const Schemas = {} + +var normalizedPath = require("path").join(__dirname, "..", "Schemas"); + +// Load All Schemas and put them in Shemas Obj +require("fs").readdirSync(normalizedPath).forEach(function(file) { + Schemas[file.split('.')[0]] = require(normalizedPath + '/' + file); +}); + +const util = { + getSomething: () => { + + }, + Schemas: Schemas +} + +module.exports = util; diff --git a/framez-server.js b/framez-server.js new file mode 100644 index 0000000..26b982e --- /dev/null +++ b/framez-server.js @@ -0,0 +1,26 @@ +const express = require('express') +const https = require('https'); +// +// Config +const Config = require('./Server/Config/Config'); +// Routers +const APIRouter = require('./Server/API/API'); + +// App +const app = express() + + + +app.use('/api', APIRouter); + +if(Config.server.enableSSL){ + // HTTPS server + app = https.createServer({ + key: fs.readFileSync(Config.server.ssl.key), + cert: fs.readFileSync(Config.server.ssl.cert), + passphrase: fs.readFileSync(Config.server.ssl.passphrase) + }, app); +} +app.listen(Config.server.port,function(){ + console.log(`Running an ${(Config.server.enableSSL) ? 'HTTPS' : 'HTTP'}, and listening on port ${Config.server.port}`); +}); diff --git a/private/.empty b/private/.empty new file mode 100644 index 0000000..e69de29 diff --git a/private/DBAuth.js b/private/DBAuth.js new file mode 100644 index 0000000..d73a900 --- /dev/null +++ b/private/DBAuth.js @@ -0,0 +1,4 @@ +module.exports = { + username: 'YOURUSERNAME', + password: 'YOURPASSWORD' +}