apxtrib/api/routes/towns.js

33 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2023-06-21 07:27:59 +00:00
const express = require("express");
const path = require("path");
// Classes
const Towns = require("../models/Towns.js");
const Notifications = require("../models/Notifications.js");
// Middlewares
const checkHeaders = require("../middlewares/checkHeaders");
const isAuthenticated = require("../middlewares/isAuthenticated");
const router = express.Router();
2023-12-05 06:42:35 +00:00
/**
* @api {get} /towns/ownershipr/:alias - town owner change
* @apiName changeowner
* @apiGroup Towns
* @apiDescription Change owner (major role) of a town (server) after a first install or just to resale it. Only the current major can run this.
2023-06-21 07:27:59 +00:00
* @param {string} alias an alias that will become owner of a town
2023-12-05 06:42:35 +00:00
* @apiSuccess (object) ownerchangesuccess
* @apiSuccessExample {json}
* HTTP/1.1 200 OK
* {status:200, ref:"towns",msg:"ownerchangesuccess",data: { alias } }
* @apiError {object} aliasnotallow
* @apiErrorExample {json}
* HTTP/1.1 403 Forbidden
* {status:403,ref:"towns",msg:"aliasnotallow",data: { alias} }
2023-06-21 07:27:59 +00:00
*
**/
2023-12-05 06:42:35 +00:00
router.get("/changeowner/:alias",checkHeaders, isAuthenticated, (req, res) => {
2023-06-28 13:23:17 +00:00
res.send(Towns.changeowner(req.params.alias, req.session.header.xalias));
2023-06-21 07:27:59 +00:00
});
2023-06-28 13:23:17 +00:00
2023-06-21 07:27:59 +00:00
module.exports = router;