添加 meta接口 status接口 完善 config和gitignore
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
95b30485ea
commit
324d8b3b54
|
@ -1,3 +1,5 @@
|
|||
yarn-error.log
|
||||
node_modules
|
||||
production
|
||||
production
|
||||
**/*.key
|
||||
**/*.pem
|
|
@ -18,14 +18,14 @@
|
|||
- [ ] 基础世界树 API
|
||||
+ [x] /authserver
|
||||
+ [x] /sessionserver
|
||||
+ [ ] 测试
|
||||
+ [x] 测试
|
||||
+ [ ] /api
|
||||
- [ ] 进阶 API
|
||||
- [ ] 皮肤上传和安全检查
|
||||
+ [ ] 皮肤数据的RSA签名
|
||||
- [ ] 兼容S3后端
|
||||
- [ ] 服务器状态接口
|
||||
- [ ] authlib-injector 元数据接口
|
||||
- [x] 服务器状态接口
|
||||
- [x] authlib-injector 元数据接口
|
||||
|
||||
#### Release 1.0
|
||||
- [ ] TGbot前端
|
||||
|
|
|
@ -3,11 +3,24 @@ export const config = {
|
|||
url: 'mongodb://localhost:27017/yggdrasil?readPreference=primary&appname=MongoDB%20Compass&directConnection=true&ssl=false',
|
||||
},
|
||||
server: {
|
||||
port: 3000
|
||||
port: 3000,
|
||||
skinDomain: [ "assets.lama.icu" ],
|
||||
serverName: "老色批世界树",
|
||||
advanced: { // 详情可见 -> https://github.com/yushijinhun/authlib-injector/wiki/Yggdrasil-%E6%9C%8D%E5%8A%A1%E7%AB%AF%E6%8A%80%E6%9C%AF%E8%A7%84%E8%8C%83#meta-%E4%B8%AD%E7%9A%84%E5%85%83%E6%95%B0%E6%8D%AE
|
||||
links: {
|
||||
homepage: "",
|
||||
register: ""
|
||||
},
|
||||
"feature.non_email_login": false,
|
||||
"feature.legacy_skin_api": false,
|
||||
"feature.no_mojang_namespace": false,
|
||||
"feature.enable_mojang_anti_features": false,
|
||||
"feature.enable_profile_key": false
|
||||
}
|
||||
},
|
||||
signing: { // 签名材质信息使用
|
||||
public: '/path/to/public.pem',
|
||||
private: '/path/to/private.key'
|
||||
public: 'public.pem',
|
||||
private: 'private.key'
|
||||
},
|
||||
custom: {
|
||||
override: {
|
||||
|
|
|
@ -4,7 +4,9 @@ import { registerModels } from './models/index.js';
|
|||
import * as Hooks from './hooks.js'
|
||||
import * as AuthenticateRoutings from './routes/authenticate.js'
|
||||
import * as SessionServerRoutings from './routes/session.js'
|
||||
import * as AdvancedRoutings from './routes/advanced.js'
|
||||
import { config } from './config.js'
|
||||
import { readFileSync } from 'fs'
|
||||
|
||||
export const server = fastify({
|
||||
logger: {
|
||||
|
@ -19,9 +21,12 @@ export const server = fastify({
|
|||
export const setup = async () => {
|
||||
const mongooseClient = await mongoose.connect(config.database.url)
|
||||
const models = registerModels(mongooseClient)
|
||||
const publicKey = readFileSync(config.signing.public).toString()
|
||||
const privateKey = readFileSync(config.signing.private).toString()
|
||||
|
||||
server.decorate('mongoose', mongooseClient)
|
||||
server.decorate('models', models)
|
||||
server.decorate('keys', { publicKey, privateKey })
|
||||
|
||||
config.custom.preHooks(server)
|
||||
server.addHook('preHandler', Hooks.headerValidation)
|
||||
|
@ -39,6 +44,9 @@ export const setup = async () => {
|
|||
server.route(SessionServerRoutings.hasJoined)
|
||||
server.route(SessionServerRoutings.profile)
|
||||
|
||||
server.route(AdvancedRoutings.meta)
|
||||
server.route(AdvancedRoutings.status)
|
||||
|
||||
config.custom.postRouting(server)
|
||||
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
import { config, getOverrideHandler, getOverridePreHandler } from "../config.js"
|
||||
|
||||
export const meta = {
|
||||
method: "GET",
|
||||
url: "/",
|
||||
schema: {
|
||||
response: {
|
||||
200: {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"meta": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"serverName": {
|
||||
"type": "string"
|
||||
},
|
||||
"implementationName": {
|
||||
"type": "string"
|
||||
},
|
||||
"implementationVersion": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"skinDomains": {
|
||||
"type": "string"
|
||||
},
|
||||
"signaturePublickey": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
preHandler: getOverridePreHandler("/"),
|
||||
handler: getOverrideHandler("/") ?? async function(req, rep) {
|
||||
rep.code(200).send({
|
||||
meta: {
|
||||
serverName: config.server.serverName,
|
||||
implementationName: "lsp-yggdrasil",
|
||||
implementationVersion: "1.0",
|
||||
|
||||
},
|
||||
skinDomains: config.server.skinDomain,
|
||||
signaturePublickey: this.keys.publicKey
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const status = {
|
||||
method: "GET",
|
||||
url: "/status",
|
||||
schema: {
|
||||
response: {
|
||||
200: {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"public": {
|
||||
"type": "string"
|
||||
},
|
||||
"version": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
preHandler: getOverridePreHandler("/status"),
|
||||
handler: getOverrideHandler("/status") ?? async function(req, rep) {
|
||||
rep.code(200).send({
|
||||
public: this.keys.publicKey,
|
||||
version: "1.0"
|
||||
})
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
export {
|
||||
|
||||
}
|
Loading…
Reference in New Issue