Merge branch 'master' of github.com:lefuturiste/condorcet-associations-server
This commit is contained in:
commit
60cebcf2ad
2 changed files with 49 additions and 21 deletions
|
@ -665,6 +665,7 @@ section {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 2.5em 1fr;
|
grid-template-columns: 2.5em 1fr;
|
||||||
|
column-gap: .75em;
|
||||||
padding-top: .75em;
|
padding-top: .75em;
|
||||||
padding-bottom: .75em;
|
padding-bottom: .75em;
|
||||||
padding-left: 2em;
|
padding-left: 2em;
|
||||||
|
@ -1061,7 +1062,7 @@ RESPONSIVE
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
@media (max-width: 600px) {
|
||||||
.schedule-category-days-container {
|
.schedule-category-days-container {
|
||||||
margin-right: 0;
|
margin-right: 0 !important;
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
padding-right: 1em;
|
padding-right: 1em;
|
||||||
|
|
67
src/app.ts
67
src/app.ts
|
@ -39,23 +39,38 @@ if (process.env.DISABLE_TWIG_CACHE === 'true') {
|
||||||
twig.cache(false)
|
twig.cache(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
const cache = ExpressRedisCache({
|
|
||||||
host: process.env.REDIS_HOST,
|
|
||||||
port: process.env.REDIS_PORT,
|
|
||||||
auth_pass: process.env.REDIS_PASSWORD,
|
|
||||||
prefix: process.env.REDIS_PREFIX
|
|
||||||
})
|
|
||||||
|
|
||||||
const cacheDuration = {
|
const cacheDuration = {
|
||||||
home: 3600 * 0.75,
|
home: 3600 * 0.5,
|
||||||
countdown: 3600 * 2,
|
countdown: 3600 * 2,
|
||||||
page: 3600 * 6
|
page: 3600 * 3
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset cache
|
let cache: any = {
|
||||||
cache.del('*', (err, deleted) => {
|
route: (x = null, y = null) => {
|
||||||
console.log('> App: Reset cache', err, deleted)
|
return (req: any, res: any, next: any) => { }
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
if (process.env.DISABLE_CACHE === 'true') {
|
||||||
|
cache = {
|
||||||
|
route: (x = null, y = null) => {
|
||||||
|
return (req: any, res: any, next: any) => {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cache = ExpressRedisCache({
|
||||||
|
host: process.env.REDIS_HOST,
|
||||||
|
port: process.env.REDIS_PORT,
|
||||||
|
auth_pass: process.env.REDIS_PASSWORD,
|
||||||
|
prefix: process.env.REDIS_PREFIX
|
||||||
|
})
|
||||||
|
|
||||||
|
// reset cache
|
||||||
|
cache.del('*', (err: any, deleted: any) => {
|
||||||
|
console.log('> App: Reset cache', err, deleted)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
let main = async () => {
|
let main = async () => {
|
||||||
EmailService.init()
|
EmailService.init()
|
||||||
|
@ -95,22 +110,34 @@ let main = async () => {
|
||||||
let byPass = req.query.bypass != null
|
let byPass = req.query.bypass != null
|
||||||
let target: any = new Date(process.env.OPEN_DATE)
|
let target: any = new Date(process.env.OPEN_DATE)
|
||||||
let now: any = new Date()
|
let now: any = new Date()
|
||||||
if (!byPass && !isProposed && target > now) {
|
// disable if 'only' key exists in query param
|
||||||
|
if (isProposed) {
|
||||||
|
res.use_express_redis_cache = false
|
||||||
|
}
|
||||||
|
// add some padding in seconds
|
||||||
|
if (!byPass && !isProposed && target - 4000 > now) {
|
||||||
return res.redirect('/c')
|
return res.redirect('/c')
|
||||||
} else {
|
} else {
|
||||||
next()
|
next()
|
||||||
}
|
}
|
||||||
|
|
||||||
let withId = req.query.only != null
|
|
||||||
if (byPass || withId) {
|
|
||||||
res.use_express_redis_cache = false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
cache.route('/home', cacheDuration.home),
|
cache.route('/home', cacheDuration.home),
|
||||||
PublicController.home
|
PublicController.home
|
||||||
)
|
)
|
||||||
app.get('/c', cache.route('/c', cacheDuration.countdown), PublicController.countdown)
|
app.get('/c', cache.route('/c', cacheDuration.countdown), PublicController.countdown)
|
||||||
app.get('/association/:slug', cache.route(cacheDuration.page), PublicController.organization)
|
app.get(
|
||||||
|
'/association/:slug',
|
||||||
|
(req, res, next) => {
|
||||||
|
// disable cache if proposed in query
|
||||||
|
let isProposed = Utils.isStrUsable(req.query, 'version')
|
||||||
|
if (isProposed) {
|
||||||
|
res.use_express_redis_cache = false
|
||||||
|
}
|
||||||
|
next()
|
||||||
|
},
|
||||||
|
cache.route(cacheDuration.page),
|
||||||
|
PublicController.organization
|
||||||
|
)
|
||||||
app.get('/a-propos', PublicController.about)
|
app.get('/a-propos', PublicController.about)
|
||||||
app.get('/mentions-legales', PublicController.legals)
|
app.get('/mentions-legales', PublicController.legals)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue