2022-10-17 14:13:20 +00:00
|
|
|
import Redis from 'ioredis'
|
2022-10-17 07:52:55 +00:00
|
|
|
import config from '../base/config.mjs'
|
|
|
|
import Parent from '../base/server.mjs'
|
|
|
|
import IndexPost from './post.mjs'
|
|
|
|
import ServeHandler from './serve.mjs'
|
|
|
|
|
|
|
|
export default class Server extends Parent {
|
|
|
|
init() {
|
|
|
|
super.init()
|
|
|
|
let localUtil = new this.core.sc.Util(import.meta.url)
|
|
|
|
|
2022-10-17 14:13:20 +00:00
|
|
|
this.flaskaOptions.appendHeaders['Content-Security-Policy'] = `default-src 'self'; script-src 'self' 'nonce-0d1valZOnjp8ZpR6vBd4dg=='; style-src 'self' 'unsafe-inline'; img-src * data: blob:; media-src *; font-src 'self' data:; object-src 'none'; frame-ancestors 'none'`
|
|
|
|
this.flaskaOptions.appendHeaders['Cross-Origin-Embedder-Policy'] = 'unsafe-none'
|
|
|
|
this.redis = new Redis(config.get('redis'))
|
|
|
|
this.redis.on('error', (err) => {
|
|
|
|
this.core.log.error(err)
|
|
|
|
})
|
2022-10-17 07:52:55 +00:00
|
|
|
this.routes = {
|
|
|
|
post: new IndexPost({
|
|
|
|
frontend: config.get('frontend:url'),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
this.routes.serve = new ServeHandler({
|
|
|
|
root: localUtil.getPathFromRoot('../public'),
|
|
|
|
version: this.core.app.running,
|
|
|
|
frontend: config.get('frontend:url'),
|
|
|
|
})
|
|
|
|
}
|
2022-10-17 14:13:20 +00:00
|
|
|
|
|
|
|
runCreateServer() {
|
|
|
|
super.runCreateServer()
|
|
|
|
|
|
|
|
|
|
|
|
this.flaska.before((ctx) => {
|
|
|
|
ctx.redis = this.redis
|
|
|
|
})
|
|
|
|
}
|
2022-10-17 07:52:55 +00:00
|
|
|
}
|