could listen to unix socket, better conf
This commit is contained in:
@@ -42,7 +42,7 @@ const exportController = {
|
||||
|
||||
feed(res, events) {
|
||||
res.type('application/rss+xml; charset=UTF-8')
|
||||
res.render('feed/rss.pug', { events, config: process.env.config, moment })
|
||||
res.render('feed/rss.pug', { events, config: process.env, moment })
|
||||
},
|
||||
|
||||
ics(res, events) {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
const Mastodon = require('mastodon-api')
|
||||
const { setting: Setting } = require('../models')
|
||||
|
||||
const baseurl = process.env.baseurl
|
||||
|
||||
const settingsController = {
|
||||
|
||||
async setAdminSetting(key, value) {
|
||||
@@ -20,7 +18,7 @@ const settingsController = {
|
||||
|
||||
async getAuthURL(req, res) {
|
||||
const instance = req.body.instance
|
||||
const callback = `${baseurl}/api/settings/oauth`
|
||||
const callback = `${process.env.baseurl}/api/settings/oauth`
|
||||
const { client_id, client_secret } = await Mastodon.createOAuthApp(`https://${instance}/api/v1/apps`,
|
||||
'gancio', 'read write', callback)
|
||||
const url = await Mastodon.getAuthorizationUrl(client_id, client_secret,
|
||||
@@ -33,7 +31,7 @@ const settingsController = {
|
||||
async code(req, res) {
|
||||
const code = req.query.code
|
||||
let client_id, client_secret, instance
|
||||
const callback = `${baseurl}/api/settings/oauth`
|
||||
const callback = `${process.env.baseurl}/api/settings/oauth`
|
||||
|
||||
const settings = await settingsController.settings()
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ const userController = {
|
||||
email: user.email,
|
||||
scope: [user.is_admin ? 'admin' : 'user']
|
||||
},
|
||||
config.SECRET_CONF.secret
|
||||
config.secret
|
||||
)
|
||||
|
||||
res.json({ token: accessToken })
|
||||
@@ -164,7 +164,7 @@ const userController = {
|
||||
if (!user) return res.sendStatus(200)
|
||||
|
||||
user.recover_code = crypto.randomBytes(16).toString('hex')
|
||||
mail.send(user.email, 'recover', { user, config: config.SHARED_CONF })
|
||||
mail.send(user.email, 'recover', { user, config })
|
||||
|
||||
await user.save()
|
||||
res.sendStatus(200)
|
||||
@@ -208,7 +208,7 @@ const userController = {
|
||||
const user = await User.findByPk(req.body.id)
|
||||
if (user) {
|
||||
if (!user.is_active && req.body.is_active) {
|
||||
await mail.send(user.email, 'confirm', { user, config: config.SHARED_CONF })
|
||||
await mail.send(user.email, 'confirm', { user, config })
|
||||
}
|
||||
await user.update(req.body)
|
||||
res.json(user)
|
||||
@@ -229,7 +229,7 @@ const userController = {
|
||||
|
||||
const user = await User.create(req.body)
|
||||
try {
|
||||
mail.send([user.email, config.SECRET_CONF.admin], 'register', { user, config: config.SHARED_CONF })
|
||||
mail.send([user.email, config.admin], 'register', { user, config })
|
||||
} catch (e) {
|
||||
return res.status(400).json(e)
|
||||
}
|
||||
@@ -238,7 +238,7 @@ const userController = {
|
||||
email: user.email,
|
||||
scope: [user.is_admin ? 'admin' : 'user']
|
||||
}
|
||||
const token = jwt.sign(payload, config.SECRET_CONF.secret)
|
||||
const token = jwt.sign(payload, config.secret)
|
||||
res.json({ token, user })
|
||||
} catch (e) {
|
||||
res.status(404).json(e)
|
||||
|
||||
@@ -22,7 +22,7 @@ api.use(bodyParser.urlencoded({ extended: false }))
|
||||
api.use(bodyParser.json())
|
||||
|
||||
const jwt = expressJwt({
|
||||
secret: config.SECRET_CONF.secret,
|
||||
secret: config.secret,
|
||||
credentialsRequired: false
|
||||
})
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ const path = require('path')
|
||||
const moment = require('moment')
|
||||
const config = require('../config')
|
||||
|
||||
moment.locale(config.SHARED_CONF.locale)
|
||||
moment.locale(config.locale)
|
||||
const mail = {
|
||||
send(addresses, template, locals) {
|
||||
const email = new Email({
|
||||
@@ -17,25 +17,25 @@ const mail = {
|
||||
}
|
||||
},
|
||||
message: {
|
||||
from: `${config.SHARED_CONF.title} <${config.SECRET_CONF.smtp.auth.user}>`
|
||||
from: `${config.title} <${config.smtp.auth.user}>`
|
||||
},
|
||||
send: true,
|
||||
i18n: {
|
||||
directory: path.join(__dirname, '..', '..', 'locales', 'email'),
|
||||
defaultLocale: config.SHARED_CONF.locale
|
||||
defaultLocale: config.locale
|
||||
},
|
||||
transport: config.SECRET_CONF.smtp
|
||||
transport: config.smtp
|
||||
})
|
||||
const msg = {
|
||||
template,
|
||||
message: {
|
||||
to: addresses,
|
||||
bcc: config.SECRET_CONF.admin
|
||||
bcc: config.admin
|
||||
},
|
||||
locals: {
|
||||
...locals,
|
||||
locale: config.SHARED_CONF.locale,
|
||||
config: config.SHARED_CONF,
|
||||
locale: config.locale,
|
||||
config: { title: config.title, baseurl: config.baseurl, description: config.description },
|
||||
datetime: datetime => moment(datetime).format('ddd, D MMMM HH:mm')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ const path = require('path')
|
||||
const Sequelize = require('sequelize')
|
||||
const config_path = path.resolve(argv.config || './config.js')
|
||||
const basename = path.basename(__filename)
|
||||
const config = require(config_path).SECRET_CONF.db
|
||||
const config = require(config_path)
|
||||
const db = {}
|
||||
|
||||
const sequelize = new Sequelize(config)
|
||||
const sequelize = new Sequelize(config.db)
|
||||
|
||||
fs
|
||||
.readdirSync(__dirname)
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
doctype xml
|
||||
rss(version='2.0')
|
||||
channel
|
||||
title #{config.title}
|
||||
link #{config.baseurl}
|
||||
description #{config.description}
|
||||
language #{config.locale}
|
||||
//- if events.length
|
||||
lastBuildDate= new Date(posts[0].publishedAt).toUTCString()
|
||||
each event in events
|
||||
item
|
||||
title= event.title
|
||||
link #{config.baseurl}/event/#{event.id}
|
||||
description
|
||||
| <![CDATA[
|
||||
| <h4>#{event.title}</h4>
|
||||
| <strong>#{event.place.name} - #{event.place.address}</strong>
|
||||
| #{moment(event.start_datetime).format("dddd, D MMMM HH:mm")}<br/>
|
||||
| <img src="#{config.apiurl}/../uploads/#{event.image_path}"/>
|
||||
| <pre>!{event.description}</pre>
|
||||
| ]]>
|
||||
pubDate= new Date(event.createdAt).toUTCString()
|
||||
guid(isPermaLink='false') #{config.baseurl}/event/#{event.id}
|
||||
Reference in New Issue
Block a user