apxtrib/api/routes/nations.js

36 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2023-01-22 09:53:09 +00:00
const express = require( 'express' );
2023-12-05 06:42:35 +00:00
const fs=require('fs-extra');
2023-05-16 08:31:27 +00:00
const conf = require(`${process.env.dirtown}/conf.json`);
2023-01-22 09:53:09 +00:00
// Classes
2023-04-27 04:17:20 +00:00
const Nations = require( '../models/Nations.js' );
2023-01-22 09:53:09 +00:00
// Middlewares
const checkHeaders = require( '../middlewares/checkHeaders' );
const isAuthenticated = require( '../middlewares/isAuthenticated' );
const router = express.Router();
/*
2023-12-05 06:42:35 +00:00
Manage nation
2023-01-22 09:53:09 +00:00
A major create a nation with at least a town => nation:{name, towns:[]} contracts/nationname.js + contracts/townsname.js
Manage a new towns in a nation => update nation:[nationname:towns:[]} contracts/townname.js
2023-12-05 06:42:35 +00:00
*/
2023-01-22 09:53:09 +00:00
2023-12-05 06:42:35 +00:00
/**
* @api {put} /nations/viewtown/:town - nationlist from a town major
* @apigroup Nation
* @apiName nationlist
* @apiDescription get list of nation from a town to help this instance to update network topology
* @apiParam {string} town fromwhich the data come from
* @apiSuccess {object} refreshnetworktopoly
* * HTTP/1.1 200 OK
* {status:200,ref:"Nations",msg:"updated",data:{}};
*
*/
router.put( '/', checkHeaders, isAuthenticated, ( req, res ) => {
const uptown = Nations.updatetown()
res.status(uptown.status).send(uptown)
2023-01-22 09:53:09 +00:00
} )
module.exports = router;