mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-16 07:47:45 +00:00
use api prefix
This commit is contained in:
@@ -137,7 +137,7 @@ app.get("/api/env", (req, res) => {
|
||||
});
|
||||
|
||||
// Add lobbies endpoint to list public games for this worker
|
||||
app.get("/public_lobbies", (req, res) => {
|
||||
app.get("/api/public_lobbies", (req, res) => {
|
||||
res.send(publicLobbiesJsonStr);
|
||||
});
|
||||
|
||||
@@ -146,7 +146,7 @@ async function fetchLobbies(): Promise<void> {
|
||||
|
||||
for (const gameID of publicLobbyIDs) {
|
||||
const port = config.workerPort(gameID);
|
||||
const promise = fetch(`http://localhost:${port}/game/${gameID}`)
|
||||
const promise = fetch(`http://localhost:${port}/api/game/${gameID}`)
|
||||
.then((resp) => resp.json())
|
||||
.then((json) => {
|
||||
return json as GameInfo;
|
||||
@@ -209,7 +209,7 @@ async function schedulePublicGame() {
|
||||
// Send request to the worker to start the game
|
||||
try {
|
||||
const response = await fetch(
|
||||
`http://localhost:${config.workerPort(gameID)}/create_game/${gameID}`,
|
||||
`http://localhost:${config.workerPort(gameID)}/api/create_game/${gameID}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
||||
@@ -100,7 +100,7 @@ export function startWorker() {
|
||||
|
||||
// Endpoint to create a private lobby
|
||||
app.post(
|
||||
"/create_game/:id",
|
||||
"/api/create_game/:id",
|
||||
asyncHandler(async (req, res) => {
|
||||
const id = req.params.id;
|
||||
if (!id) {
|
||||
@@ -137,7 +137,7 @@ export function startWorker() {
|
||||
|
||||
// Add other endpoints from your original server
|
||||
app.post(
|
||||
"/start_game/:id",
|
||||
"/api/start_game/:id",
|
||||
asyncHandler(async (req, res) => {
|
||||
console.log(`starting private lobby with id ${req.params.id}`);
|
||||
const game = gm.game(req.params.id);
|
||||
@@ -157,7 +157,7 @@ export function startWorker() {
|
||||
);
|
||||
|
||||
app.put(
|
||||
"/game/:id",
|
||||
"/api/game/:id",
|
||||
asyncHandler(async (req, res) => {
|
||||
// TODO: only update public game if from local host
|
||||
const lobbyID = req.params.id;
|
||||
@@ -188,7 +188,7 @@ export function startWorker() {
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/game/:id/exists",
|
||||
"/api/game/:id/exists",
|
||||
asyncHandler(async (req, res) => {
|
||||
const lobbyId = req.params.id;
|
||||
res.json({
|
||||
@@ -198,7 +198,7 @@ export function startWorker() {
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/game/:id",
|
||||
"/api/game/:id",
|
||||
asyncHandler(async (req, res) => {
|
||||
const game = gm.game(req.params.id);
|
||||
if (game == null) {
|
||||
@@ -210,7 +210,7 @@ export function startWorker() {
|
||||
);
|
||||
|
||||
app.post(
|
||||
"/archive_singleplayer_game",
|
||||
"/api/archive_singleplayer_game",
|
||||
asyncHandler(async (req, res) => {
|
||||
const gameRecord: GameRecord = req.body;
|
||||
const clientIP = req.ip || req.socket.remoteAddress || "unknown";
|
||||
|
||||
Reference in New Issue
Block a user