diff --git a/CHANGELOG.md b/CHANGELOG.md index 8524317..4ff986e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ - Fixed date parsing bug ([#22](https://github.com/pawelmalak/snippet-box/issues/22)) - Minor UI fixes +### v1.3.1 (2021-10-05) +- Added support for raw snippets ([#15](https://github.com/pawelmalak/snippet-box/issues/15)) + ### v1.3 (2021-09-30) - Added dark mode ([#7](https://github.com/pawelmalak/snippet-box/issues/7)) - Added syntax highlighting ([#14](https://github.com/pawelmalak/snippet-box/issues/14)) diff --git a/client/src/components/Snippets/SnippetDetails.tsx b/client/src/components/Snippets/SnippetDetails.tsx index 25d9e63..016ec94 100644 --- a/client/src/components/Snippets/SnippetDetails.tsx +++ b/client/src/components/Snippets/SnippetDetails.tsx @@ -31,9 +31,9 @@ export const SnippetDetails = (props: Props): JSX.Element => { const creationDate = dateParser(createdAt); const updateDate = dateParser(updatedAt); - const copyHandler = () => { - copy(code); - }; + // const copyHandler = () => { + // copy(code); + // }; return ( @@ -74,6 +74,14 @@ export const SnippetDetails = (props: Props): JSX.Element => { {/* ACTIONS */}
+
diff --git a/client/src/styles/_variables.scss b/client/src/styles/_variables.scss index 05a014f..6d4c54d 100644 --- a/client/src/styles/_variables.scss +++ b/client/src/styles/_variables.scss @@ -10,16 +10,16 @@ $gray-700: #495057; $gray-800: #343a40; $gray-900: #212529; $black: #000; -$blue: #3459e6; +$blue: #375a7f; $indigo: #6610f2; $purple: #6f42c1; -$pink: #d63384; -$red: #da292e; -$orange: #f8765f; -$yellow: #f4bd61; -$green: #2fb380; +$pink: #e83e8c; +$red: #e74c3c; +$orange: #fd7e14; +$yellow: #f39c12; +$green: #00bc8c; $teal: #20c997; -$cyan: #287bb5; +$cyan: #3498db; $primary: $blue; $secondary: $white; $success: $green; diff --git a/src/controllers/snippets.ts b/src/controllers/snippets.ts index eb8769b..ab10976 100644 --- a/src/controllers/snippets.ts +++ b/src/controllers/snippets.ts @@ -215,6 +215,31 @@ export const countTags = asyncWrapper( } ); +/** + * @description Get raw snippet code + * @route /api/snippets/raw/:id + * @request GET + */ +export const getRawCode = asyncWrapper( + async (req: Request, res: Response, next: NextFunction): Promise => { + const snippet = await SnippetModel.findOne({ + where: { id: req.params.id }, + raw: true + }); + + if (!snippet) { + return next( + new ErrorResponse( + 404, + `Snippet with id of ${req.params.id} was not found` + ) + ); + } + + res.status(200).send(snippet.code); + } +); + /** * @description Search snippets * @route /api/snippets/search diff --git a/src/routes/snippets.ts b/src/routes/snippets.ts index c58e0d6..8e55c78 100644 --- a/src/routes/snippets.ts +++ b/src/routes/snippets.ts @@ -4,6 +4,7 @@ import { createSnippet, deleteSnippet, getAllSnippets, + getRawCode, getSnippet, searchSnippets, updateSnippet @@ -24,4 +25,5 @@ snippetRouter .delete(deleteSnippet); snippetRouter.route('/statistics/count').get(countTags); -snippetRouter.route('/search').post(searchSnippets); +snippetRouter.route('/raw/:id').get(getRawCode); +snippetRouter.route('/search').post(searchSnippets); \ No newline at end of file