2020-01-14 14:38:33 +00:00
|
|
|
const constants = require("../../lib/constants")
|
2020-01-28 06:23:53 +00:00
|
|
|
const child_process = require("child_process")
|
2020-01-12 12:50:21 +00:00
|
|
|
const {fetchUser} = require("../../lib/collectors")
|
|
|
|
|
|
|
|
function reply(statusCode, content) {
|
|
|
|
return {
|
|
|
|
statusCode: statusCode,
|
|
|
|
contentType: "application/json",
|
|
|
|
content: JSON.stringify(content)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-28 06:23:53 +00:00
|
|
|
let commit = ""
|
|
|
|
{
|
|
|
|
const p = child_process.spawn("git", ["rev-parse", "--short", "HEAD"])
|
|
|
|
p.on("error", console.error)
|
|
|
|
p.stdout.on("data", data => {
|
|
|
|
const string = data.toString()
|
|
|
|
commit = "-" + string.match(/[0-9a-f]+/)[0]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-01-12 12:50:21 +00:00
|
|
|
module.exports = [
|
2020-01-28 05:39:07 +00:00
|
|
|
{
|
|
|
|
route: `/api/user/(${constants.external.username_regex})`, methods: ["GET"], code: async ({fill}) => {
|
|
|
|
const user = await fetchUser(fill[0])
|
|
|
|
const data = user.export()
|
|
|
|
return reply(200, data)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
route: "/.well-known/nodeinfo", methods: ["GET"], code: async ({fill}) => {
|
|
|
|
return reply(200, {
|
|
|
|
link: [
|
|
|
|
{
|
|
|
|
rel: "http://nodeinfo.diaspora.software/ns/schema/2.0",
|
|
|
|
href: `${constants.website_origin}/api/stats/2.0`
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
route: "/api/stats/2.0", methods: ["GET"], code: async ({fill}) => {
|
|
|
|
return reply(200, {
|
|
|
|
version: "2.0",
|
|
|
|
software: {
|
|
|
|
name: "bibliogram",
|
2020-01-28 06:23:53 +00:00
|
|
|
version: "1.0.0"+commit
|
2020-01-28 05:39:07 +00:00
|
|
|
},
|
|
|
|
protocols: [],
|
|
|
|
services: {
|
|
|
|
inbound: [
|
|
|
|
"instagram"
|
|
|
|
],
|
|
|
|
outbound: []
|
|
|
|
},
|
|
|
|
openRegistrations: false,
|
|
|
|
usage: {
|
|
|
|
users: {
|
|
|
|
total: 0,
|
|
|
|
activeHalfyear: 0,
|
|
|
|
activeMonth: 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
metadata: {
|
|
|
|
bibliogram: {
|
|
|
|
version: "1.0",
|
|
|
|
features: [
|
|
|
|
"PAGE_PROFILE",
|
|
|
|
"PAGE_POST",
|
2020-01-28 10:37:19 +00:00
|
|
|
"API_STATS",
|
2020-01-28 11:38:05 +00:00
|
|
|
"PAGE_HOME",
|
|
|
|
"API_INSTANCES"
|
2020-01-28 05:39:07 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2020-01-12 12:50:21 +00:00
|
|
|
]
|