Initial Commit

This commit is contained in:
Sagi Dayan 2018-04-27 15:23:19 +03:00
commit 37853cc8b4
9 changed files with 250 additions and 0 deletions

141
.gitignore vendored Normal file
View file

@ -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

8
Server/API/API.js Normal file
View file

@ -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;

View file

@ -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;

20
Server/Config/Config.js Normal file
View file

@ -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`,
};

View file

@ -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

24
Server/Utils/DBUtil.js Normal file
View file

@ -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;

26
framez-server.js Normal file
View file

@ -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}`);
});

0
private/.empty Normal file
View file

4
private/DBAuth.js Normal file
View file

@ -0,0 +1,4 @@
module.exports = {
username: 'YOURUSERNAME',
password: 'YOURPASSWORD'
}