2022-10-13 14:59:02 +01:00
|
|
|
import express from 'express'
|
2022-10-14 13:21:45 +01:00
|
|
|
import yaml from 'js-yaml'
|
|
|
|
import fs, { cpSync } from 'node:fs'
|
|
|
|
|
|
|
|
console.log('🔧 Configuring socialtree...')
|
2022-10-13 14:59:02 +01:00
|
|
|
|
|
|
|
const app = express()
|
|
|
|
const port = 3000
|
2022-10-13 20:59:07 +01:00
|
|
|
const engine = 'ejs'
|
2022-10-13 14:59:02 +01:00
|
|
|
|
|
|
|
app.set('view engine', engine)
|
|
|
|
app.set('views', './src/views')
|
2022-10-14 13:21:45 +01:00
|
|
|
app.use(express.static('src/public'))
|
|
|
|
app.use(express.static('src/assets'))
|
2022-10-13 14:59:02 +01:00
|
|
|
|
|
|
|
app.get('/', (req, res) => {
|
2022-10-14 13:21:45 +01:00
|
|
|
let config = yaml.load(fs.readFileSync('config/config.yml'), 'utf8')
|
|
|
|
console.log(JSON.stringify(config))
|
2022-10-13 20:37:37 +01:00
|
|
|
res.render('index', {
|
2022-10-14 13:21:45 +01:00
|
|
|
name: config.name,
|
|
|
|
filenameProfilePic: config.profilePic ? config.profilePic : 'profilepic.jpg'
|
2022-10-13 20:37:37 +01:00
|
|
|
})
|
2022-10-13 14:59:02 +01:00
|
|
|
})
|
|
|
|
|
2022-10-14 13:21:45 +01:00
|
|
|
app.listen(port, () => console.log(`🚀 Socialtree started on port ${port}, with view engine ${engine}`))
|