7daystodie-api-wrapper 中文文档教程
7 Days to die API wrapper
来自 Alloc 的修复模块的 Web API 的简单包装器。
## Requirements
- A 7 Days to Die server running Alloc's Fixes
本模块需要的端口与动态地图页面相同。 有关详细信息,请参阅 mod 本身的文档 https://7dtd.illy.bz/wiki/Ports
## 使用示例使用
npm 安装 npm i 7daystodie-api-wrapper --only=prod
const SdtdApi = require('7daystodie-api-wrapper');
const sdtdServer = {
ip: "192.168.1.100",
port: "8082",
adminUser: "admin",
adminToken: "secret"
}
foo();
async function foo() {
let stats = await SdtdApi.getStats(sdtdServer);
console.log(`The current ingame time is ${stats.gametime.days} days, ${stats.gametime.hours} hours and ${stats.gametime.minutes} minutes.`)
}
## 运行测试
要运行测试,您必须有一个安装了 allocs 修复程序的工作 7 天死机服务器。 您还必须至少在服务器上保存一个玩家资料(登录一次即可)。
在 .env 文件中填写服务器连接信息(参见示例文件),然后运行 npm test
Other languages
7 Days to die API wrapper
A simple wrapper around the web API from Alloc's fixes mod.
## Requirements
- A 7 Days to Die server running Alloc's Fixes
The port required for this module is the same as the dynamic map page. For more info, see the documentation of the mod itself https://7dtd.illy.bz/wiki/Ports
## Example usage
Install with npm npm i 7daystodie-api-wrapper --only=prod
const SdtdApi = require('7daystodie-api-wrapper');
const sdtdServer = {
ip: "192.168.1.100",
port: "8082",
adminUser: "admin",
adminToken: "secret"
}
foo();
async function foo() {
let stats = await SdtdApi.getStats(sdtdServer);
console.log(`The current ingame time is ${stats.gametime.days} days, ${stats.gametime.hours} hours and ${stats.gametime.minutes} minutes.`)
}
## Running tests
To run tests, you must have a working 7 Days to die server with allocs fixes installed. You must also have at least one player profile saved on the server (logging in once will do this).
Fill in the server connection info in a .env file (see example file) and then run npm test