-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#123 Модуль Game и его тесты переведены на TypeScript
- Loading branch information
1 parent
e3029e4
commit b89de0e
Showing
13 changed files
with
629 additions
and
698 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import db, {DUPLICATE_KEY_PG_ERROR} from '../db'; | ||
import {AddWordResult} from './model/AddWordResult'; | ||
|
||
async function addWord(word: string, approved: boolean): Promise<AddWordResult> { | ||
try { | ||
await db.query(`INSERT INTO friends_vk_bot.words (name, approved) VALUES ('${ word }', ${ approved });`); | ||
return AddWordResult.SUCCESS; | ||
} catch (error) { | ||
return (error as any).code === DUPLICATE_KEY_PG_ERROR ? AddWordResult.DUPLICATE_WORD : AddWordResult.ERROR; | ||
} | ||
} | ||
|
||
async function deleteWord(word: string): Promise<void> { | ||
try { | ||
await db.query(`DELETE FROM friends_vk_bot.words WHERE name = '${ word }';`); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
} | ||
|
||
export default { | ||
deleteWord, | ||
addWord, | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.