clean configuration
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -16,6 +16,8 @@ pids
|
|||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
lib-cov
|
lib-cov
|
||||||
|
|
||||||
|
uploads
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
# Coverage directory used by tools like istanbul
|
||||||
coverage
|
coverage
|
||||||
|
|
||||||
|
|||||||
57
.vscode/vscode-kanban.json
vendored
57
.vscode/vscode-kanban.json
vendored
@@ -1,5 +1,16 @@
|
|||||||
{
|
{
|
||||||
"done": [
|
"done": [
|
||||||
|
{
|
||||||
|
"assignedTo": {
|
||||||
|
"name": "lesion"
|
||||||
|
},
|
||||||
|
"category": "feature",
|
||||||
|
"creation_time": "2019-04-23T19:47:35.777Z",
|
||||||
|
"id": "5",
|
||||||
|
"prio": 3,
|
||||||
|
"references": [],
|
||||||
|
"title": "server side auth"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"assignedTo": {
|
"assignedTo": {
|
||||||
"name": "lesion"
|
"name": "lesion"
|
||||||
@@ -19,19 +30,6 @@
|
|||||||
"references": [],
|
"references": [],
|
||||||
"title": "export page",
|
"title": "export page",
|
||||||
"type": "bug"
|
"type": "bug"
|
||||||
}
|
|
||||||
],
|
|
||||||
"in-progress": [
|
|
||||||
{
|
|
||||||
"assignedTo": {
|
|
||||||
"name": "lesion"
|
|
||||||
},
|
|
||||||
"category": "feature",
|
|
||||||
"creation_time": "2019-04-23T19:46:46.332Z",
|
|
||||||
"id": "3",
|
|
||||||
"prio": 0,
|
|
||||||
"references": [],
|
|
||||||
"title": "export lista"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"assignedTo": {
|
"assignedTo": {
|
||||||
@@ -43,21 +41,31 @@
|
|||||||
"prio": 1,
|
"prio": 1,
|
||||||
"references": [],
|
"references": [],
|
||||||
"title": "get comments / media from mastodon"
|
"title": "get comments / media from mastodon"
|
||||||
}
|
},
|
||||||
],
|
|
||||||
"testing": [
|
|
||||||
{
|
{
|
||||||
"assignedTo": {
|
"assignedTo": {
|
||||||
"name": "lesion"
|
"name": "lesion"
|
||||||
},
|
},
|
||||||
"category": "feature",
|
"category": "feature",
|
||||||
"creation_time": "2019-04-23T19:47:35.777Z",
|
"creation_time": "2019-04-23T19:46:46.332Z",
|
||||||
"id": "5",
|
"id": "3",
|
||||||
"prio": 3,
|
"prio": 0,
|
||||||
"references": [],
|
"references": [],
|
||||||
"title": "server side auth"
|
"title": "export lista"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"in-progress": [
|
||||||
|
{
|
||||||
|
"assignedTo": {
|
||||||
|
"name": "lesion"
|
||||||
|
},
|
||||||
|
"creation_time": "2019-04-30T12:31:20.056Z",
|
||||||
|
"id": "15",
|
||||||
|
"references": [],
|
||||||
|
"title": "test deploy"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testing": [],
|
||||||
"todo": [
|
"todo": [
|
||||||
{
|
{
|
||||||
"assignedTo": {
|
"assignedTo": {
|
||||||
@@ -174,6 +182,15 @@
|
|||||||
"references": [],
|
"references": [],
|
||||||
"title": "documentare sorgenti",
|
"title": "documentare sorgenti",
|
||||||
"type": "bug"
|
"type": "bug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"assignedTo": {
|
||||||
|
"name": "lesion"
|
||||||
|
},
|
||||||
|
"creation_time": "2019-04-30T12:46:42.208Z",
|
||||||
|
"id": "16",
|
||||||
|
"references": [],
|
||||||
|
"title": "riesco a rimuovere bootstrap-vue e usare solo element ?"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
58
config.js
Normal file
58
config.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/**
|
||||||
|
* GANCIO CONFIGURATION
|
||||||
|
*/
|
||||||
|
const env = process.env.NODE_ENV || 'development'
|
||||||
|
|
||||||
|
|
||||||
|
console.log(__dirname + '/db.sqlite')
|
||||||
|
/**
|
||||||
|
* Database configuration
|
||||||
|
* `development` configuration is enabled running `yarn dev`
|
||||||
|
* while `production` with `yarn start`
|
||||||
|
* ref: http://docs.sequelizejs.com/class/lib/sequelize.js~Sequelize.html#instance-constructor-constructor
|
||||||
|
*/
|
||||||
|
const DB_CONF = {
|
||||||
|
development: {
|
||||||
|
storage: __dirname + '/db.sqlite',
|
||||||
|
dialect: 'sqlite',
|
||||||
|
logging: false
|
||||||
|
},
|
||||||
|
production: {
|
||||||
|
storage: __dirname + '/db.sqlite',
|
||||||
|
dialect: 'sqlite',
|
||||||
|
logging: false
|
||||||
|
// username: 'docker',
|
||||||
|
// password: 'docker',
|
||||||
|
// database: 'gancio',
|
||||||
|
// host: 'db',
|
||||||
|
// dialect: 'postgres',
|
||||||
|
// logging: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main Gancio configuration
|
||||||
|
*/
|
||||||
|
const GANCIO_CONF = {
|
||||||
|
locale: 'it',
|
||||||
|
title: 'GANCIO',
|
||||||
|
description: 'A calendar for radical communities',
|
||||||
|
baseurl: '',
|
||||||
|
db: DB_CONF[env],
|
||||||
|
|
||||||
|
admin_email: process.env.ADMIN_EMAIL,
|
||||||
|
|
||||||
|
smtp: {
|
||||||
|
host: process.env.SMTP_HOST,
|
||||||
|
secure: true,
|
||||||
|
auth: {
|
||||||
|
user: process.env.SMTP_USER,
|
||||||
|
pass: process.env.SMTP_PASS
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
secret: 'notsosecret'
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = GANCIO_CONF
|
||||||
@@ -57,6 +57,7 @@ module.exports = {
|
|||||||
** Axios module configuration
|
** Axios module configuration
|
||||||
*/
|
*/
|
||||||
axios: {
|
axios: {
|
||||||
|
baseURL: '',
|
||||||
prefix: '/api',
|
prefix: '/api',
|
||||||
credentials: true
|
credentials: true
|
||||||
// See https://github.com/nuxt-community/axios-module#options
|
// See https://github.com/nuxt-community/axios-module#options
|
||||||
@@ -70,11 +71,11 @@ module.exports = {
|
|||||||
logout: { url: '/auth/logout', method: 'post' },
|
logout: { url: '/auth/logout', method: 'post' },
|
||||||
user: { url: '/auth/user', method: 'get', propertyName: false }
|
user: { url: '/auth/user', method: 'get', propertyName: false }
|
||||||
},
|
},
|
||||||
// tokenRequired: true,
|
|
||||||
// tokenType: 'bearer',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Build configuration
|
** Build configuration
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const { Op } = require('sequelize')
|
const { Op } = require('sequelize')
|
||||||
const config = require('./config')
|
const config = require('../../config')
|
||||||
const User = require('./models/user')
|
const User = require('./models/user')
|
||||||
|
|
||||||
const Auth = {
|
const Auth = {
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
/* backend configuration */
|
|
||||||
const env = process.env.NODE_ENV || 'development'
|
|
||||||
const db = require('./config/config.json')[env]
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
locale: process.env.LOCALE || 'it',
|
|
||||||
title: process.env.TITLE || 'GANCIO',
|
|
||||||
description: process.env.DESCRIPTION || 'A calendar for radical communities',
|
|
||||||
baseurl: process.env.BASE_URL || 'http://localhost:3000',
|
|
||||||
apiurl:
|
|
||||||
env === 'production'
|
|
||||||
? process.env.BASE_URL + '/api'
|
|
||||||
: 'http://localhost:3000/api',
|
|
||||||
db,
|
|
||||||
admin: process.env.ADMIN_EMAIL,
|
|
||||||
|
|
||||||
smtp: {
|
|
||||||
host: process.env.SMTP_HOST,
|
|
||||||
secure: true,
|
|
||||||
auth: {
|
|
||||||
user: process.env.SMTP_USER,
|
|
||||||
pass: process.env.SMTP_PASS
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
secret: process.env.SECRET || 'notsosecret'
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
const { User, Event, Comment, Tag } = require('../model')
|
const { User, Event, Comment, Tag } = require('../model')
|
||||||
const config = require('../config')
|
const config = require('../../../config')
|
||||||
const Mastodon = require('mastodon-api')
|
const Mastodon = require('mastodon-api')
|
||||||
// const Sequelize = require('sequelize')
|
// const Sequelize = require('sequelize')
|
||||||
// const Op = Sequelize.Op
|
// const Op = Sequelize.Op
|
||||||
@@ -12,11 +12,9 @@ moment.locale('it')
|
|||||||
const botController = {
|
const botController = {
|
||||||
bot: null,
|
bot: null,
|
||||||
async initialize () {
|
async initialize () {
|
||||||
console.log('initialize bot')
|
|
||||||
const settings = await settingsController.settings()
|
const settings = await settingsController.settings()
|
||||||
if (!settings.mastodon_auth) return
|
if (!settings.mastodon_auth) return
|
||||||
const mastodon_auth = settings.mastodon_auth
|
const mastodon_auth = settings.mastodon_auth
|
||||||
console.log('instance ', `https://${mastodon_auth.instance}/api/v1/`)
|
|
||||||
botController.bot = new Mastodon({
|
botController.bot = new Mastodon({
|
||||||
access_token: mastodon_auth.access_token,
|
access_token: mastodon_auth.access_token,
|
||||||
api_url: `https://${mastodon_auth.instance}/api/v1`
|
api_url: `https://${mastodon_auth.instance}/api/v1`
|
||||||
@@ -45,7 +43,6 @@ const botController = {
|
|||||||
// botController.bots.push({ email: user.email, bot })
|
// botController.bots.push({ email: user.email, bot })
|
||||||
},
|
},
|
||||||
async post (mastodon_auth, event) {
|
async post (mastodon_auth, event) {
|
||||||
console.log('dentro post!')
|
|
||||||
const { access_token, instance } = mastodon_auth
|
const { access_token, instance } = mastodon_auth
|
||||||
const bot = new Mastodon({ access_token, api_url: `https://${instance}/api/v1/` })
|
const bot = new Mastodon({ access_token, api_url: `https://${instance}/api/v1/` })
|
||||||
const status = `${event.title} @ ${event.place.name} ${moment(event.start_datetime).format('ddd, D MMMM HH:mm')} -
|
const status = `${event.title} @ ${event.place.name} ${moment(event.start_datetime).format('ddd, D MMMM HH:mm')} -
|
||||||
@@ -67,7 +64,6 @@ ${event.description.length > 200 ? event.description.substr(0, 200) + '...' : ev
|
|||||||
if (!replyid) return
|
if (!replyid) return
|
||||||
const event = await Event.findOne({ where: { activitypub_id: replyid } })
|
const event = await Event.findOne({ where: { activitypub_id: replyid } })
|
||||||
if (!event) {
|
if (!event) {
|
||||||
console.error('associated event not found !')
|
|
||||||
// check for comment..
|
// check for comment..
|
||||||
// const comment = await Comment.findOne( {where: { }})
|
// const comment = await Comment.findOne( {where: { }})
|
||||||
return
|
return
|
||||||
@@ -79,7 +75,6 @@ ${event.description.length > 200 ? event.description.substr(0, 200) + '...' : ev
|
|||||||
author: msg.data.accounts[0].username
|
author: msg.data.accounts[0].username
|
||||||
})
|
})
|
||||||
event.addComment(comment)
|
event.addComment(comment)
|
||||||
console.log(event)
|
|
||||||
// const comment = await Comment.findOne( { where: {activitypub_id: msg.data.in_reply_to}} )
|
// const comment = await Comment.findOne( { where: {activitypub_id: msg.data.in_reply_to}} )
|
||||||
// console.log('dentro message ', data)
|
// console.log('dentro message ', data)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const { Event, Comment, Tag, Place } = require('../model')
|
const { Event, Comment, Tag, Place } = require('../model')
|
||||||
const { Op } = require('sequelize')
|
const { Op } = require('sequelize')
|
||||||
const config = require('../config')
|
const config = require('../../../config')
|
||||||
const moment = require('moment')
|
const moment = require('moment')
|
||||||
const ics = require('ics')
|
const ics = require('ics')
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const Mastodon = require('mastodon-api')
|
|||||||
const { Op } = require('sequelize')
|
const { Op } = require('sequelize')
|
||||||
const jsonwebtoken = require('jsonwebtoken')
|
const jsonwebtoken = require('jsonwebtoken')
|
||||||
const User = require('../models/user')
|
const User = require('../models/user')
|
||||||
const config = require('../config')
|
const config = require('../../../config')
|
||||||
const mail = require('../mail')
|
const mail = require('../mail')
|
||||||
const { Event, Tag, Place } = require('../models/event')
|
const { Event, Tag, Place } = require('../models/event')
|
||||||
const settingsController = require('./settings')
|
const settingsController = require('./settings')
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const Sequelize = require('sequelize')
|
const Sequelize = require('sequelize')
|
||||||
const conf = require('./config.js')
|
const conf = require('../../config.js')
|
||||||
const db = new Sequelize(conf.db)
|
const db = new Sequelize(conf.db)
|
||||||
db.sync()
|
db.sync()
|
||||||
module.exports = db
|
module.exports = db
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const eventController = require('./controller/event')
|
|||||||
const exportController = require('./controller/export')
|
const exportController = require('./controller/export')
|
||||||
const userController = require('./controller/user')
|
const userController = require('./controller/user')
|
||||||
const settingsController = require('./controller/settings')
|
const settingsController = require('./controller/settings')
|
||||||
const config = require('./config')
|
const config = require('../../config')
|
||||||
|
|
||||||
const botController = require('./controller/bot')
|
const botController = require('./controller/bot')
|
||||||
const jwt = require('express-jwt')({secret: config.secret})
|
const jwt = require('express-jwt')({secret: config.secret})
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
const Email = require('email-templates')
|
const Email = require('email-templates')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const config = require('./config')
|
const config = require('../../config')
|
||||||
const moment = require('moment')
|
const moment = require('moment')
|
||||||
moment.locale('it')
|
moment.locale(config.locale)
|
||||||
|
|
||||||
const mail = {
|
const mail = {
|
||||||
send (addresses, template, locals) {
|
send (addresses, template, locals) {
|
||||||
|
|||||||
@@ -1,37 +1,29 @@
|
|||||||
'use strict';
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
const Sequelize = require('sequelize')
|
||||||
|
const basename = path.basename(__filename)
|
||||||
|
const config = require('../../../config')
|
||||||
|
const db = {}
|
||||||
|
|
||||||
const fs = require('fs');
|
const sequelize = new Sequelize(config.db)
|
||||||
const path = require('path');
|
|
||||||
const Sequelize = require('sequelize');
|
|
||||||
const basename = path.basename(__filename);
|
|
||||||
const env = process.env.NODE_ENV || 'development';
|
|
||||||
const config = require(__dirname + '/../config/config.json')[env];
|
|
||||||
const db = {};
|
|
||||||
|
|
||||||
let sequelize;
|
|
||||||
if (config.use_env_variable) {
|
|
||||||
sequelize = new Sequelize(process.env[config.use_env_variable], config);
|
|
||||||
} else {
|
|
||||||
sequelize = new Sequelize(config.database, config.username, config.password, config);
|
|
||||||
}
|
|
||||||
|
|
||||||
fs
|
fs
|
||||||
.readdirSync(__dirname)
|
.readdirSync(__dirname)
|
||||||
.filter(file => {
|
.filter(file => {
|
||||||
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
|
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js')
|
||||||
})
|
})
|
||||||
.forEach(file => {
|
.forEach(file => {
|
||||||
const model = sequelize['import'](path.join(__dirname, file));
|
const model = sequelize['import'](path.join(__dirname, file))
|
||||||
db[model.name] = model;
|
db[model.name] = model;
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.keys(db).forEach(modelName => {
|
Object.keys(db).forEach(modelName => {
|
||||||
if (db[modelName].associate) {
|
if (db[modelName].associate) {
|
||||||
db[modelName].associate(db);
|
db[modelName].associate(db)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
db.sequelize = sequelize;
|
db.sequelize = sequelize
|
||||||
db.Sequelize = Sequelize;
|
db.Sequelize = Sequelize
|
||||||
|
|
||||||
module.exports = db;
|
module.exports = db;
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ async function sendNotification (notification, event, eventNotification) {
|
|||||||
// instance publish
|
// instance publish
|
||||||
if (settings.mastodon_auth.instance && settings.mastodon_auth.access_token) {
|
if (settings.mastodon_auth.instance && settings.mastodon_auth.access_token) {
|
||||||
const b = bot.post(settings.mastodon_auth, event).then(b => {
|
const b = bot.post(settings.mastodon_auth, event).then(b => {
|
||||||
console.log('ho postato admin post cose', b.data.id)
|
|
||||||
event.activitypub_id = b.data.id
|
event.activitypub_id = b.data.id
|
||||||
return event.save()
|
return event.save()
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user