socialtree/src/index.js

27 lines
784 B
JavaScript
Raw Normal View History

2022-10-13 14:59:02 +01:00
import express from 'express'
import yaml from 'js-yaml'
2022-10-18 08:20:54 +01:00
import fs from 'node:fs'
console.log('🔧 Configuring socialtree...')
2022-10-13 14:59:02 +01:00
const app = express()
const port = 3000
const engine = 'ejs'
2022-10-13 14:59:02 +01:00
app.set('view engine', engine)
app.set('views', './src/views')
2022-10-18 08:20:54 +01:00
app.use(express.static('src/dist'))
app.use(express.static('src/assets'))
2022-10-13 14:59:02 +01:00
app.get('/', (req, res) => {
let config = yaml.load(fs.readFileSync('config/config.yml'), 'utf8')
2022-10-13 20:37:37 +01:00
res.render('index', {
name: config.name,
2022-10-15 20:13:48 +01:00
filenameProfilePic: config.profilePic ? config.profilePic : 'profilepic.jpg',
2022-10-18 08:20:54 +01:00
links: config.links,
2022-10-28 07:57:30 +01:00
smallLinks: config.smallLinks,
2022-10-18 08:20:54 +01:00
theme: config.theme
2022-10-13 20:37:37 +01:00
})
2022-10-13 14:59:02 +01:00
})
app.listen(port, () => console.log(`🚀 Socialtree started on port ${port}, with view engine ${engine}`))