gulp and a lot of others updates
This commit is contained in:
parent
4a97c240eb
commit
2e6e64a6d3
57 changed files with 6411 additions and 2629 deletions
|
|
@ -72,7 +72,7 @@ export default class MediaService {
|
|||
size: file.size,
|
||||
// @ts-ignore
|
||||
originalFileName: file.originalname,
|
||||
type
|
||||
type: type === 'media' ? file.contentType.split('/')[0] : type
|
||||
}
|
||||
}
|
||||
}
|
||||
16
src/app.ts
16
src/app.ts
|
|
@ -15,6 +15,7 @@ import cors from 'cors'
|
|||
import twig from 'twig'
|
||||
import EmailService from './EmailService'
|
||||
import ErrorController from './controllers/ErrorController'
|
||||
import { createProxyMiddleware, Filter, Options, RequestHandler } from 'http-proxy-middleware';
|
||||
|
||||
process.on('unhandledRejection', (err) => {
|
||||
console.error(err)
|
||||
|
|
@ -27,7 +28,7 @@ dotenv.config({
|
|||
})
|
||||
|
||||
const app: express.Application = express()
|
||||
const host: string = "0.0.0.0"
|
||||
const host: string = process.env.HOST === undefined ? '127.0.0.1' : process.env.HOST
|
||||
const port: number = 8001
|
||||
|
||||
twig.cache(false)
|
||||
|
|
@ -100,6 +101,14 @@ let main = async () => {
|
|||
.delete('/', DelegateController.destroy)
|
||||
)
|
||||
|
||||
app.use('/proxy-s3', createProxyMiddleware({
|
||||
target: 'https://fva-condorcet.s3.fr-par.scw.cloud',
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
'^/proxy-s3/': '/'
|
||||
},
|
||||
}))
|
||||
|
||||
/*
|
||||
|
||||
.put('/tags/:id', AdminTagController.update)
|
||||
|
|
@ -111,8 +120,9 @@ let main = async () => {
|
|||
|
||||
//app.post('/api/media', MediaController.uploadRoute())
|
||||
//app.delete('/api/media/:key', MediaController.delete)
|
||||
|
||||
app.use(express.static(path.resolve('./static')))
|
||||
const assetsPath: string = process.env.ASSETS_PATH === undefined ? './assets/development' : process.env.ASSETS_PATH
|
||||
|
||||
app.use(express.static(path.resolve(assetsPath)))
|
||||
|
||||
app.get('/500', ErrorController.internalError)
|
||||
|
||||
|
|
|
|||
|
|
@ -180,6 +180,8 @@ export default class AdminOrganizationController {
|
|||
extra.slugs = currentSlugs.concat([slug])
|
||||
}
|
||||
extra.adminName = proposedVersion.name
|
||||
|
||||
// keep updated the contacts.email address with the root address
|
||||
extra.email = proposedVersion.contacts.email
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -38,6 +38,11 @@ export default class DelegateController {
|
|||
// only update proposedVersion
|
||||
let proposedVersion: any = req.body
|
||||
proposedVersion.tags = tags
|
||||
|
||||
// remove useless isResponsable
|
||||
if (Utils.isUsable(proposedVersion, 'contacts.peoples') && Array.isArray(proposedVersion.contacts.peoples)) {
|
||||
proposedVersion.contacts.peoples = proposedVersion.contacts.peoples.filter((p: any) => !p.isResponsable)
|
||||
}
|
||||
|
||||
// sanitize long description
|
||||
if (Utils.isStrUsable(proposedVersion.descriptionLong)) {
|
||||
|
|
@ -127,6 +132,7 @@ export default class DelegateController {
|
|||
Promise.all(promises).then(() => {
|
||||
next(req.body.tags)
|
||||
}).catch((err) => {
|
||||
console.log(err)
|
||||
return res.status(400).json({ success: false, errors: err, _note: 'One of the tag id provided is invalid' })
|
||||
})
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -78,26 +78,38 @@ export default class PublicController {
|
|||
// if (lastPublished !== null) {
|
||||
// lastPublished = lastPublished
|
||||
// }
|
||||
let formatPhone = (phone: string) => {
|
||||
if (phone.indexOf('+33') === 0) {
|
||||
phone = '0' + phone.substr(3)
|
||||
}
|
||||
let phoneSplit = ''
|
||||
let partEnd = false
|
||||
for (var i = 0; i < phone.length; i++) {
|
||||
phoneSplit += phone.charAt(i)
|
||||
if (partEnd === true) {
|
||||
phoneSplit += ' '
|
||||
}
|
||||
partEnd = !partEnd
|
||||
}
|
||||
return [ "+33" + phone.substr(1), phoneSplit ]
|
||||
}
|
||||
|
||||
if (Utils.isUsable(version.contacts)) {
|
||||
if (Utils.isStrUsable(version.contacts, 'address')) {
|
||||
version.contacts.address = version.contacts.address.split('\n')
|
||||
}
|
||||
if (Utils.isStrUsable(version.contacts, 'phone')) {
|
||||
let phone = version.contacts.phone
|
||||
if (phone.indexOf('+33') === 0) {
|
||||
phone = '0' + phone.substr(3)
|
||||
}
|
||||
let phoneSplit = ''
|
||||
let partEnd = false
|
||||
for (var i = 0; i < phone.length; i++) {
|
||||
phoneSplit += phone.charAt(i)
|
||||
if (partEnd === true) {
|
||||
phoneSplit += ' '
|
||||
}
|
||||
partEnd = !partEnd
|
||||
}
|
||||
version.contacts.phoneInt = "+33" + phone.substr(1)
|
||||
version.contacts.phoneSplit = phoneSplit
|
||||
let formated: any = formatPhone(version.contacts.phone)
|
||||
version.contacts.phoneInt = formated[0]
|
||||
version.contacts.phoneSplit = formated[1]
|
||||
}
|
||||
if (Utils.isUsable(version.contacts, 'peoples') && Array.isArray(version.contacts.peoples)) {
|
||||
version.contacts.peoples = version.contacts.peoples.map((p: any) => {
|
||||
let formated: any = formatPhone(p.phone)
|
||||
p.phoneInt = formated[0]
|
||||
p.phoneSplit = formated[1]
|
||||
return p
|
||||
})
|
||||
}
|
||||
}
|
||||
if (Array.isArray(version.gallery)) {
|
||||
|
|
@ -136,4 +148,4 @@ export default class PublicController {
|
|||
static async legals(req: express.Request, res: express.Response) {
|
||||
res.render('legals.twig')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue