mirror of https://github.com/MaxLeiter/Drift
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import * as express from "express"
|
|
import * as bodyParser from "body-parser"
|
|
import * as errorhandler from "strong-error-handler"
|
|
import { posts, users, auth, files, admin, health } from "@routes/index"
|
|
import { errors } from "celebrate"
|
|
import secretKey from "@lib/middleware/secret-key"
|
|
import markdown from "@lib/render-markdown"
|
|
import config from "@lib/config"
|
|
|
|
export const app = express()
|
|
|
|
app.use(bodyParser.urlencoded({ extended: true }))
|
|
app.use(bodyParser.json({ limit: "5mb" }))
|
|
|
|
app.use("/auth", auth)
|
|
app.use("/posts", posts)
|
|
app.use("/users", users)
|
|
app.use("/files", files)
|
|
app.use("/admin", admin)
|
|
app.use("/health", health)
|
|
|
|
app.get("/welcome", secretKey, (req, res) => {
|
|
const introContent = config.welcome_content
|
|
const introTitle = config.welcome_title
|
|
if (!introContent || !introTitle) {
|
|
return res.status(500).json({ error: "Missing welcome content" })
|
|
}
|
|
|
|
return res.json({
|
|
title: introTitle,
|
|
content: introContent,
|
|
rendered: markdown(introContent)
|
|
})
|
|
})
|
|
|
|
app.use(errors())
|
|
|
|
app.use(
|
|
errorhandler({
|
|
debug: !config.is_production,
|
|
log: true
|
|
})
|
|
)
|