This commit is contained in:
Luca Jäntsch 2019-02-12 16:25:14 +01:00
parent e8fbfb2c04
commit 0f365e8e01
9 changed files with 1582 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/node_modules
*.sqlite

10
config/db_settings.json Normal file
View File

@ -0,0 +1,10 @@
{
"settings":["database", "username", "password", {
"host": "localhost",
"dialect": "sqlite",
"storage": "sqlite/database.sqlite"
}
]
}

15
controller/ftp.js Normal file
View File

@ -0,0 +1,15 @@
const {FtpSrv, FileSystem} = require('ftp-srv');
class MyFileSystem extends FileSystem {
constructor(connection, { root, cwd } = {}) {
super(connection, root, cwd);
}
list(path){
return [{name:'test',isDirectory:"false"}]
}
get(fileName) {
console.log(fileName)
}
}
module.exports = {FtpSrv,MyFileSystem};

36
controller/storage.js Normal file
View File

@ -0,0 +1,36 @@
const db_settings = require('../config/db_settings.json');
console.log(global.dir+'/'+db_settings.settings[3].storage);
const Sequelize = require('sequelize');
const sequelize = new Sequelize('', '', '', {
dialect: 'sqlite',
storage: global.dir+'/'+db_settings.settings[3].storage
});
const Files = sequelize.define('files', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
title: Sequelize.STRING,
filename: Sequelize.STRING
});
const Tags = sequelize.define('tags',{
id:{
type: Sequelize.INTEGER,
primaryKey:true,
autoIncrement: true
},
tag_name:Sequelize.STRING
})
const Files_Tags = sequelize.define('files_tags',{
file:Sequelize.INTEGER,
tag:Sequelize.INTEGER
})
sequelize.sync()

0
files/dummy Normal file
View File

29
index.js Normal file
View File

@ -0,0 +1,29 @@
global.dir = __dirname;
const ftp = require('./controller/ftp');
//const storage = require('./controller/storage');
var f = new ftp.MyFileSystem();
const FtpSrv = require('ftp-srv');
const ftpServer = new FtpSrv({url:"ftp://127.0.0.1:2221" });
ftpServer.on('login', ({connection,username,password},resolve, reject) => {
if ((username === 'test' || username === 'testdb') && password === 'test' || username === 'anonymous') {
if (username === 'testdb') {
var root = '/code/data';
var cwd = '/';
return resolve({root: root, cwd: cwd, fs: new ftp.MyFileSystem(connection, {root: root, cwd: cwd}) });
} else {
return resolve({ root: '/code/data', cwd: '/' });
}
} else {
reject('Bad username or password');
}
});
ftpServer.listen()
.then(() => {
console.log('HELP')
});

1468
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

22
package.json Normal file
View File

@ -0,0 +1,22 @@
{
"name": "wiz",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start":"node index.js"
},
"repository": {
"type": "git",
"url": "https://gitlab.thee.moe/theenoro/wiz.git"
},
"author": "",
"license": "ISC",
"dependencies": {
"ftp-srv": "^3.0.5",
"mysql2": "^1.6.5",
"sequelize": "^4.42.0",
"sqlite3": "^4.0.6"
}
}

0
sqlite/dummy Normal file
View File