Copero
Public Snippets
Open Source
ltLRet
Copy Content
[{"snippet":"import mongoose from \"mongoose\";\n\nconst { Schema } = mongoose;\n\nconst SnippetSchema = new Schema({\n snippet: String,\n slug: String,\n});\n\nconst Snippet =\n mongoose.models.Snippet || mongoose.model(\"Snippet\", SnippetSchema);\n\nexport default Snippet;","slug":"VPLkxD"},{"snippet":"import React from 'react';\nimport { Form, Button } from 'react-bootstrap';\nimport { useRouter } from 'next/router';\n\nexport default function CreateSnippet() {\n const [snippet, setSnippet] = React.useState('');\n\n const router = useRouter();\n\n const saveSnippet = async () => {\n const response = await fetch('/api/post', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ snippet }),\n });\n\n const parsedResponse = await response.json();\n router.push(`/${parsedResponse.slug}`);\n };\n\n return (\n <div className=\"text-center mt-5\">\n <h1>Upload your snippet</h1>\n <p>\n Paste your text snippet in the text area below, save it, and share the\n link.\n </p>\n\n <Form>\n <Form.Group className=\"mb-2 pt-4\">\n <Form.Control\n style={{ width: '80%', height: '300px', margin: '0 auto' }}\n as=\"textarea\"\n rows={3}\n onChange={(e) => setSnippet(e.target.value)}\n />\n </Form.Group>\n\n <Button onClick={saveSnippet} variant=\"outline-info\">\n Save your snippet\n </Button>\n </Form>\n </div>\n );\n}","slug":"fdOqXz"},{"snippet":"import dotenv from \"dotenv\";\nimport dotenv from 'dotenv';\n\ndotenv.config();\n\nexport const { DB_USER, PASSWORD, CLUSTER_NAME, SUBDOMAIN } = process.env;\nexport const {\n DB_USER, PASSWORD, CLUSTER_NAME, SUBDOMAIN, DB,\n} = process.env;","slug":"GIobVf"},{"snippet":" name: CI \n \n on: [push, pull_request] \n \n jobs: \n lint: \n name: CI \n runs-on: ubuntu-latest \n steps: \n - uses: actions/checkout@v2 \n - uses: actions/setup-node@v2 \n with: \n node-version: '16' \n - run: yarn \n - run: yarn lint","slug":"YlWAeH"},{"snippet":"{\"error\":\"Snippet OexaRw not found.\"} LOL","slug":"ggoXpB"},{"snippet":"import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Form, Button, Alert } from 'react-bootstrap';\n\nimport Image from 'next/image';\nimport { useRouter } from 'next/router';\n\nimport copy from 'clipboard-copy';\n\nexport default function CreateSnippet({ snippetText, slug, notExist }) {\n const router = useRouter();\n\n if (notExist) {\n return (\n <>\n <div className=\"mt-4\">\n <h1>There is nothing here yet</h1>\n </div>\n\n <div className=\"mt-4\">\n <Image\n src=\"/404.jpeg\"\n alt=\"Picture of the author\"\n width={360}\n height={360}\n />\n </div>\n\n <div className=\"mt-1\">\n <Button onClick={() => router.push('/')} variant=\"outline-info\">\n Return Home\n </Button>\n </div>\n </>\n );\n }\n\n CreateSnippet.propTypes = {\n snippetText: PropTypes.string.isRequired,\n slug: PropTypes.string.isRequired,\n notExist: PropTypes.bool,\n };\n\n return (\n <div className=\"text-center mt-4\">\n <h1>Snippet</h1>\n <Button\n onClick={() => copy(window.location)}\n className=\"mb-4 mt-2 mr-1\"\n variant=\"outline-info\"\n >\n Copy Link to Clipboard\n </Button>\n \n <Button\n onClick={() => router.push(`/api/${slug}`)}\n className=\"mb-4 mt-2\"\n variant=\"outline-info\"\n >\n Raw Text\n </Button>\n <Form>\n <Form.Group controlId=\"exampleForm.ControlTextarea1\">\n <Form.Control\n style={{\n margin: '0 auto',\n width: '80%',\n height: '300px',\n }}\n disabled\n value={snippetText}\n as=\"textarea\"\n rows={3}\n />\n </Form.Group>\n </Form>\n <Alert className=\"mt-4\" variant=\"info\">\n Done successfully\n </Alert>\n </div>\n );\n}\n\n// eslint-disable-next-line unicorn/prevent-abbreviations\nexport async function getServerSideProps({ req: request, params: { slug } }) {\n const response = await fetch(`http://${request.headers.host}/api/${slug}`);\n try {\n const json = await response.json();\n if (json.error) {\n return { props: { notExist: true } };\n }\n } catch {\n const snippetObject = await response.text();\n\n return {\n props: {\n snippetText: snippetObject,\n slug,\n },\n };\n }\n\n return { props: {} };\n}","slug":"trctdp"},{"snippet":"","slug":"Iykpvl"},{"snippet":"adssaw","slug":"dLVlNV"},{"snippet":" <div class=\"container my-4\">\n\n\t\t<hr>\n\n <p class=\"font-weight-bold\">Basic example</p>\n \n <nav class=\"navbar fixed-bottom navbar-expand-lg navbar-dark default-color\">\n\t<a class=\"navbar-brand\" href=\"#\">Navbar</a>\n\n\t<div class=\"collapse navbar-collapse\" id=\"navbarSupportedContent\">\n\t\t<ul class=\"navbar-nav mr-auto\">\n\t\t\t<li class=\"nav-item active\">\n\t\t\t\t<a class=\"nav-link\" href=\"#\">Home <span class=\"sr-only\">(current)</span></a>\n\t\t\t</li>\n\t\t\t<li class=\"nav-item\">\n\t\t\t\t<a class=\"nav-link\" href=\"#\">Features</a>\n\t\t\t</li>\n\t\t\t<li class=\"nav-item\">\n\t\t\t\t<a class=\"nav-link\" href=\"#\">Pricing</a>\n\t\t\t</li>\n\t\t\t<li class=\"nav-item\">\n\t\t\t\t<a class=\"nav-link\" href=\"#\">Testimonials</a>\n\t\t\t</li>\n\t\t</ul>\n\t\t<form class=\"form-inline\">\n\t\t\t<div class=\"md-form my-0\">\n\t\t\t\t<input class=\"form-control mr-sm-2\" type=\"text\" placeholder=\"Search\" aria-label=\"Search\">\n\t\t\t</div>\n\t\t</form>\n\t</div>\n</nav>\n\n<!--Main layout-->\n<main>\n\n\t<div class=\"container-fluid\">\n\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<br>\n\n\t</div>\n\n</main>\n<!--Main layout-->\n\n </div>","slug":"sVOIsG"},{"snippet":" <div class=\"container my-4\">\n\n\t\t<hr>\n\n <p class=\"font-weight-bold\">Basic example</p>\n \n <nav class=\"navbar fixed-bottom navbar-expand-lg navbar-dark default-color\">\n\t<a class=\"navbar-brand\" href=\"#\">Navbar</a>\n\n\t<div class=\"collapse navbar-collapse\" id=\"navbarSupportedContent\">\n\t\t<ul class=\"navbar-nav mr-auto\">\n\t\t\t<li class=\"nav-item active\">\n\t\t\t\t<a class=\"nav-link\" href=\"#\">Home <span class=\"sr-only\">(current)</span></a>\n\t\t\t</li>\n\t\t\t<li class=\"nav-item\">\n\t\t\t\t<a class=\"nav-link\" href=\"#\">Features</a>\n\t\t\t</li>\n\t\t\t<li class=\"nav-item\">\n\t\t\t\t<a class=\"nav-link\" href=\"#\">Pricing</a>\n\t\t\t</li>\n\t\t\t<li class=\"nav-item\">\n\t\t\t\t<a class=\"nav-link\" href=\"#\">Testimonials</a>\n\t\t\t</li>\n\t\t</ul>\n\t\t<form class=\"form-inline\">\n\t\t\t<div class=\"md-form my-0\">\n\t\t\t\t<input class=\"form-control mr-sm-2\" type=\"text\" placeholder=\"Search\" aria-label=\"Search\">\n\t\t\t</div>\n\t\t</form>\n\t</div>\n</nav>\n\n<!--Main layout-->\n<main>\n\n\t<div class=\"container-fluid\">\n\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<h1>Scroll down</h1>\n\t\t<br>\n\t\t<br>\n\n\t</div>\n\n</main>\n<!--Main layout-->\n\n </div>","slug":"DtBAVn"},{"snippet":"","slug":"llEyjV"},{"snippet":"MIT License\n\nCopyright (c) 2021 Eliaz Bobadilla\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","slug":"PrAHYM"},{"snippet":"<ul class=\"xxx_list\"> \n <li class=\"hproduct\"> \n <a href=\"#\" class=\"url\" title=\"\" target=\"_blank\"> \n <img class=\"photo\" src=\"shoujike.jpg\" alt=\"手机壳\"> \n <span class=\"some-class-name\"> \n <span class=\"price_wrap\">¥<span class=\"price\">88.00</span</span> \n <span class=\"fav\">收藏</span> \n </span> \n <span class=\"fn\">基本商品单元的商品名称</span> \n </a> \n </li> \n</ul>","slug":"qCnAUv"},{"snippet":"aaaaaaa","slug":"HdzBPz"},{"snippet":"import mongoose from 'mongoose'; const SnippetSchema = new mongoose.Schema({ snippet: String, slug: String, }); export default mongoose.models.snippet || mongoose.model('snippet', SnippetSchema);","slug":"XVFcKo"}]
Copy Shareable Link