41 lines
1.2 KiB
JavaScript
Executable File
41 lines
1.2 KiB
JavaScript
Executable File
const express = require( 'express' );
|
|
const conf = require(`${process.env.dirtown}/conf.json`);
|
|
|
|
// Classes
|
|
const Nations = require( '../models/Nations.js' );
|
|
// Middlewares
|
|
const checkHeaders = require( '../middlewares/checkHeaders' );
|
|
const isAuthenticated = require( '../middlewares/isAuthenticated' );
|
|
const router = express.Router();
|
|
|
|
/*
|
|
Manage the social world
|
|
|
|
@Todo
|
|
|
|
Manage a new nation
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
router.post( '/push', checkHeaders, ( req, res ) => {
|
|
// Get information from other apxtrib instance in req.body
|
|
// check req.body.hashnext => means this is a candidate to validate next block
|
|
//
|
|
// return it's own information back with the last call to Nationchains.synchronize()
|
|
res.send( { status: 200, payload: { moreinfo: fs.readFileSync( `${conf.tribes}/${conf.mayorId}/nationchains/nodes/${conf.rootURL}`, 'utf-8' ) } } )
|
|
} )
|
|
|
|
router.get('/synchro',checkHeaders, isAuthenticated,(req,res)=>{
|
|
// run a sync from a list of electedtown to update nationchains folder
|
|
console.log('TODO')
|
|
})
|
|
|
|
module.exports = router;
|