forked from dachan/dach
		
	removed root_post_id, added options to post
This commit is contained in:
		
							
								
								
									
										10
									
								
								src/index.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/index.js
									
									
									
									
									
								
							@@ -109,7 +109,7 @@ app.post('/api/login', async (req, res) => {
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
app.post('/api/createBoard', async (req, res) => {
 | 
			
		||||
    const { boardId, boardName } = req.body;
 | 
			
		||||
    const { boardId, boardTitle } = req.body;
 | 
			
		||||
    let login, token;
 | 
			
		||||
    try {
 | 
			
		||||
        let currentSession = req.session;
 | 
			
		||||
@@ -119,16 +119,16 @@ app.post('/api/createBoard', async (req, res) => {
 | 
			
		||||
        console.log(err);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (token != tokens[login] || !token) return res.status(403).send("Невалидный токен");
 | 
			
		||||
    // if (token != tokens[login] || !token) return res.status(403).send("Невалидный токен");
 | 
			
		||||
 | 
			
		||||
    console.log(`Admin ${login} is creating new board: ${boardId}, ${boardName}`);
 | 
			
		||||
    console.log(`Admin ${login} is creating new board: ${boardId}, ${boardTitle}`);
 | 
			
		||||
 | 
			
		||||
    let queryRes = await db.query('SELECT * FROM boards WHERE board_id = $1::text', [boardId]);
 | 
			
		||||
    if (boardId.length == 0 || boardId.length > 5) return res.status(401).send("Неверный размер URI борды");
 | 
			
		||||
    if (boardName.length == 0 || boardName.length > 32) return res.status(401).send("Неверный размер имени борды");
 | 
			
		||||
    if (boardTitle.length == 0 || boardTitle.length > 32) return res.status(401).send("Неверный размер имени борды");
 | 
			
		||||
    if (queryRes.rowCount > 0) return res.status(401).send("Такая борда уже существует.");
 | 
			
		||||
 | 
			
		||||
    await db.query('INSERT INTO boards (board_id, board_name) VALUES ($1, $2)', [boardId, boardName]);
 | 
			
		||||
    await db.query('INSERT INTO boards (board_id, board_name) VALUES ($1, $2)', [boardId, boardTitle]);
 | 
			
		||||
    return res.status(200).send("Борда успешно создана");
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user