├── docs ├── nlw.png ├── screenshots │ ├── home.png │ ├── search.png │ └── register.png └── icones │ ├── papeis-papelao.svg │ ├── baterias.svg │ ├── lampadas.svg │ ├── eletronicos.svg │ ├── oleo.svg │ ├── logo.svg │ └── organicos.svg ├── .editorconfig ├── .gitignore ├── src ├── views │ ├── partials │ │ ├── page-header.html │ │ ├── point-created.html │ │ └── modal.html │ ├── layout.html │ ├── index.html │ ├── search-results.html │ └── create-point.html ├── server.ts ├── log │ └── log.ts ├── database │ └── db.ts └── routes.ts ├── public ├── assets │ ├── x.svg │ ├── search.svg │ ├── arrow-left.svg │ ├── log-in.svg │ ├── papeis-papelao.svg │ ├── check.svg │ ├── baterias.svg │ ├── lampadas.svg │ ├── eletronicos.svg │ ├── oleo.svg │ ├── logo.svg │ ├── organicos.svg │ └── home-background.svg ├── scripts │ ├── index.js │ └── create-point.js └── styles │ ├── main.css │ ├── responsive.css │ ├── modal.css │ ├── search-results.css │ ├── home.css │ └── create-point.css ├── .vscode ├── settings.json └── extensions.json ├── .eslintrc.json ├── LICENSE ├── package.json ├── tsconfig.json └── README.md /docs/nlw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateusfg7/Ecoleta/HEAD/docs/nlw.png -------------------------------------------------------------------------------- /docs/screenshots/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateusfg7/Ecoleta/HEAD/docs/screenshots/home.png -------------------------------------------------------------------------------- /docs/screenshots/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateusfg7/Ecoleta/HEAD/docs/screenshots/search.png -------------------------------------------------------------------------------- /docs/screenshots/register.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateusfg7/Ecoleta/HEAD/docs/screenshots/register.png -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = false 8 | insert_final_newline = true 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | node_modules 3 | package-lock.json 4 | yarn.lock 5 | 6 | # database 7 | *.db 8 | 9 | #logs 10 | logs.txt 11 | 12 | #builds 13 | dist/ 14 | -------------------------------------------------------------------------------- /src/views/partials/page-header.html: -------------------------------------------------------------------------------- 1 |
2 | Logomarca 3 | 4 | 5 | Voltar para home 6 | 7 |
8 | -------------------------------------------------------------------------------- /public/assets/x.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/assets/search.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/assets/arrow-left.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/views/partials/point-created.html: -------------------------------------------------------------------------------- 1 | 7 | 8 | 13 | -------------------------------------------------------------------------------- /public/assets/log-in.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/scripts/index.js: -------------------------------------------------------------------------------- 1 | const buttomSearch = document.querySelector("#page-home main a") 2 | const modal = document.querySelector("#modal") 3 | const close = document.querySelector("#modal .header a") 4 | 5 | 6 | buttomSearch.addEventListener("click", () => { 7 | modal.classList.remove("hide") 8 | }) 9 | 10 | close.addEventListener("click", () => { 11 | modal.classList.add("hide") 12 | }) -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnSave": false, 3 | "deno.enable": false, 4 | "sqltools.connections": [ 5 | { 6 | "database": "${workspaceFolder:Ecoleta}/src/database/database.db", 7 | "driver": "SQLite", 8 | "group": "Ecoleta", 9 | "name": "Ecoleta Database", 10 | "previewLimit": 50 11 | } 12 | ], 13 | "sqltools.useNodeRuntime": true 14 | } 15 | -------------------------------------------------------------------------------- /src/server.ts: -------------------------------------------------------------------------------- 1 | import express from 'express'; 2 | import nunjucks from 'nunjucks'; 3 | import routes from './routes'; 4 | 5 | const server = express(); 6 | 7 | nunjucks.configure('src/views/', { 8 | express: server, 9 | noCache: true, 10 | }); 11 | 12 | server.use(express.static('public')); 13 | server.use(express.urlencoded({ extended: true })); 14 | server.use(routes); 15 | 16 | server.listen(3000); 17 | -------------------------------------------------------------------------------- /src/log/log.ts: -------------------------------------------------------------------------------- 1 | import filesystem from "fs"; 2 | 3 | function showAndSaveLog(logText: string, hour: string): void { 4 | const string = `[${hour}] ${logText}`; 5 | 6 | filesystem.writeFile( 7 | "src/log/logs.txt", 8 | `${string}\n`, 9 | { flag: "a" }, 10 | (err) => { 11 | if (err) { 12 | throw err; 13 | } 14 | }, 15 | ); 16 | 17 | console.log(string); 18 | } 19 | 20 | export default showAndSaveLog; 21 | -------------------------------------------------------------------------------- /public/styles/main.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --title-color: #322153; 3 | --primary-color: #34cb79; 4 | } 5 | 6 | * { 7 | margin: 0; 8 | padding: 0; 9 | box-sizing: border-box; 10 | } 11 | 12 | html { 13 | font-family: 'Roboto', sans-serif; 14 | } 15 | 16 | body { 17 | background: #f0f0f5; 18 | -webkit-font-smoothing: antialised; 19 | } 20 | 21 | a { 22 | text-decoration: none; 23 | } 24 | 25 | h1, h2, h3, h4, h5, h6 { 26 | font-family: 'Ubuntu', sans-serif; 27 | color: var(--title-color); 28 | } -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es2020": true, 5 | "node": true 6 | }, 7 | "extends": [ 8 | "airbnb-base" 9 | ], 10 | "parser": "@typescript-eslint/parser", 11 | "parserOptions": { 12 | "ecmaVersion": 11, 13 | "sourceType": "module" 14 | }, 15 | "plugins": [ 16 | "@typescript-eslint" 17 | ], 18 | "settings": { 19 | "import/extensions": [ 20 | ".ts", 21 | ], 22 | }, 23 | "rules": { 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/views/partials/modal.html: -------------------------------------------------------------------------------- 1 | 18 | -------------------------------------------------------------------------------- /docs/icones/papeis-papelao.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /public/assets/papeis-papelao.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /public/assets/check.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /docs/icones/baterias.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /public/assets/baterias.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/views/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {% block title %} 8 | Ecoleta 9 | {% endblock title %} 10 | 11 | 12 | 13 | 14 | {% block styles %}{% endblock styles %} 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | {% block content %}{% endblock content %} 23 |
24 | 25 | {% block modal %}{% endblock modal %} 26 | 27 | {% block scripts %}{% endblock scripts %} 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. 3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp 4 | 5 | // List of extensions which should be recommended for users of this workspace. 6 | "recommendations": [ 7 | "ysemeniuk.emmet-live", 8 | "dbaeumer.vscode-eslint", 9 | "ecmel.vscode-html-css", 10 | "wix.vscode-import-cost", 11 | "FallenMax.mithril-emmet", 12 | "eseom.nunjucks-template", 13 | "alexcvzz.vscode-sqlite", 14 | "mtxr.sqltools-driver-sqlite", 15 | "mtxr.sqltools", 16 | ], 17 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace. 18 | "unwantedRecommendations": [] 19 | } 20 | -------------------------------------------------------------------------------- /src/views/index.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% set pageId = "page-home" %} 4 | 5 | {% block styles %} 6 | 7 | 8 | {% endblock styles %} 9 | 10 | {% block content %} 11 |
12 |
13 | Logomarca 14 | 15 | 16 | Cadastre um ponto de coleta 17 | 18 |
19 |
20 |

Seu marketplace de coleta de resíduos.

21 |

Ajudamos pessoas a encontrarem pontos de coleta de forma efciente.

22 | 23 | 24 | Pesquisar ponto de coleta 25 | 26 |
27 | 28 |
29 | {% endblock content %} 30 | 31 | {% block modal %} 32 | {% include "partials/modal.html" %} 33 | {% endblock modal %} 34 | 35 | {% block scripts %} 36 | 37 | {% endblock scripts %} 38 | -------------------------------------------------------------------------------- /public/styles/responsive.css: -------------------------------------------------------------------------------- 1 | @media (max-width: 900px) { 2 | #page-home { 3 | background-position-x: 70vw; 4 | } 5 | 6 | #page-home .content { 7 | align-items: center; 8 | text-align: center; 9 | } 10 | 11 | #page-home header a { 12 | position: absolute; 13 | bottom: 48px; 14 | 15 | left: 50%; 16 | transform: translateX(-50%); 17 | } 18 | 19 | #page-home main { 20 | align-items: center; 21 | } 22 | 23 | #page-search-results .cards { 24 | grid-template-columns: 1fr; 25 | } 26 | 27 | #page-search-results .cards img { 28 | height: 250px; 29 | } 30 | 31 | #page-create-point .field-group { 32 | flex-direction: column; 33 | } 34 | 35 | #page-create-point .field-group .field + .field { 36 | margin-left: 0; 37 | } 38 | 39 | #page-create-point .items-grid { 40 | grid-template-columns: 1fr 1fr; 41 | } 42 | } 43 | 44 | 45 | @media(min-width: 1700px) { 46 | #page-home { 47 | background-position-x: 40vw; 48 | } 49 | } 50 | 51 | @media(max-height: 760px) { 52 | #page-home { 53 | background-position-y: 200px; 54 | } 55 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Mateus Felipe Gonçalves 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Ecoleta", 3 | "version": "1.0.0", 4 | "description": "Aplicação Ecoleta feita na Next Level Week #1 da Rocketseat, feita com HTML e CSS puro.", 5 | "main": "src/server.js", 6 | "scripts": { 7 | "start:server": "tsc && node dist/server.js", 8 | "dev:server": "ts-node-dev --respawn --transpileOnly src/server.ts" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/mateusfg7/Ecoleta.git" 13 | }, 14 | "author": "Rocketseat/Mateus Felipe", 15 | "license": "MIT", 16 | "bugs": { 17 | "url": "https://github.com/mateusfg7/Ecoleta/issues" 18 | }, 19 | "homepage": "https://github.com/mateusfg7/Ecoleta#readme", 20 | "dependencies": { 21 | "express": "^4.17.1", 22 | "nunjucks": "^3.2.1", 23 | "sqlite3": "^4.2.0" 24 | }, 25 | "devDependencies": { 26 | "@types/express": "^4.17.6", 27 | "@types/nunjucks": "^3.1.3", 28 | "@types/sqlite3": "^3.1.6", 29 | "@typescript-eslint/eslint-plugin": "^3.3.0", 30 | "@typescript-eslint/parser": "^3.3.0", 31 | "eslint": "^7.2.0", 32 | "eslint-config-airbnb-base": "^14.2.0", 33 | "eslint-plugin-import": "^2.21.2", 34 | "nodemon": "^2.0.4", 35 | "ts-node-dev": "^1.0.0-pre.49", 36 | "typescript": "^3.9.5" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/views/search-results.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% set pageId = "page-search-results" %} 4 | 5 | {% block title %} 6 | Resultado da pesquisa 7 | {% endblock title %} 8 | 9 | {% block styles %} 10 | 11 | {% endblock styles %} 12 | 13 | {% block content %} 14 | {% include "partials/page-header.html" %} 15 | 16 |
17 | 18 | {% if total > 0 %} 19 |

20 | {{ total }} 21 | pontos 22 | encontrados 23 |

24 | 25 |
26 | 27 | {% for place in places %} 28 | 29 |
30 | {{ place.name }} 31 |

{{ place.name }}

32 |

{{ place.items }}

33 |

34 | {{ place.city }}, 35 | {{ place.state }} 36 |
37 | {{ place.address }} 38 |
39 | {{ place.address2 }} 40 |

41 |
42 | 43 | {% endfor %} 44 | 45 |
46 | 47 | {% else %} 48 | 49 |

50 | Nenhum 51 | local encontrado

52 | 53 | {% endif %} 54 | 55 |
56 | {% endblock content %} 57 | -------------------------------------------------------------------------------- /public/styles/modal.css: -------------------------------------------------------------------------------- 1 | #modal { 2 | background-color: #0E0A14ef; 3 | 4 | height: 100vh; 5 | width: 100vw; 6 | 7 | position: fixed; 8 | top: 0; 9 | 10 | display: flex; 11 | justify-content: center; 12 | align-items: center; 13 | 14 | transition: 400ms; 15 | } 16 | 17 | #modal.hide { 18 | display: none; 19 | } 20 | 21 | 22 | #modal .content { 23 | color: white; 24 | 25 | width: 420px; 26 | } 27 | 28 | #modal .header { 29 | display: flex; 30 | align-items: center; 31 | justify-content: space-between; 32 | 33 | margin-bottom: 48px; 34 | } 35 | 36 | #modal .header a { 37 | background-image: url("../assets/x.svg"); 38 | 39 | width: 20px; 40 | height: 20px; 41 | 42 | display: flex; 43 | 44 | font-size: 0.01px; 45 | } 46 | 47 | #modal .header h1 { 48 | color: white; 49 | 50 | font-size: 36px; 51 | line-height: 42px; 52 | } 53 | 54 | 55 | #modal form label { 56 | font-size: 14px; 57 | line-height: 16px; 58 | 59 | display: block; 60 | margin-bottom: 8px; 61 | } 62 | 63 | 64 | #modal form .field { 65 | display: flex; 66 | } 67 | 68 | #modal form input { 69 | flex: 1; 70 | 71 | background-color: #f0f0f5; 72 | 73 | border-radius: 8px 0 0 8px; 74 | border: 0; 75 | 76 | padding: 16px 24px; 77 | 78 | font-size: 16px; 79 | 80 | color: #6c6c80; 81 | } 82 | 83 | #modal form button { 84 | width: 72px; 85 | height: 72px; 86 | 87 | background-color: var(--primary-color); 88 | 89 | border: 0; 90 | border-radius: 0 8px 8px 0; 91 | } 92 | 93 | #modal form button:hover { 94 | background-color: #2fb86e; 95 | } 96 | 97 | /* isso é para o modal point-created */ 98 | #modal.point .content { 99 | display: flex; 100 | flex-direction: column; 101 | align-items: center; 102 | } 103 | 104 | #modal.point h1 { 105 | color: white; 106 | 107 | margin-top: 32px; 108 | } 109 | -------------------------------------------------------------------------------- /public/styles/search-results.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: white; 3 | } 4 | 5 | body::after { 6 | content: ""; 7 | position: absolute; 8 | background: #f0f0f5; 9 | top: 0; 10 | right: 0; 11 | left: 0; 12 | bottom: 0; 13 | height: 16rem; 14 | z-index: -1; 15 | } 16 | 17 | 18 | #page-search-results { 19 | width: 90%; 20 | max-width: 1100px; 21 | 22 | margin: 0 auto; 23 | } 24 | 25 | #page-search-results header { 26 | margin-top: 48px; 27 | 28 | display: flex; 29 | justify-content: space-between; 30 | align-items: center; 31 | } 32 | 33 | #page-search-results header a { 34 | color: var(--title-color); 35 | font-weight: bold; 36 | 37 | display: flex; 38 | align-items: center; 39 | } 40 | 41 | #page-search-results header a span { 42 | margin-right: 16px; 43 | background-image: url('../assets/arrow-left.svg'); 44 | 45 | display: flex; 46 | 47 | width: 20px; 48 | height: 24px; 49 | } 50 | 51 | 52 | main { 53 | margin: 48px; 54 | } 55 | 56 | main h4 { 57 | font-weight: normal; 58 | font-family: 'Roboto', sans-serif; 59 | 60 | margin-bottom: 32px; 61 | } 62 | 63 | main .cards { 64 | display: grid; 65 | grid-template-columns: 1fr 1fr 1fr; 66 | 67 | gap: 24px; 68 | } 69 | 70 | main .card img { 71 | width: 100%; 72 | height: 150px; 73 | 74 | object-fit: cover; 75 | 76 | border-radius: 8px 8px 0 0 ; 77 | } 78 | 79 | main .card h1 { 80 | margin-top: 32px; 81 | 82 | font-size: 36px; 83 | line-height: 41px; 84 | color: #322253; 85 | } 86 | 87 | main .card h3 { 88 | margin: 24px 0; 89 | 90 | font-family: Roboto; 91 | font-weight: bold; 92 | 93 | font-size: 24px; 94 | line-height: 34px; 95 | 96 | color: var(--primary-color); 97 | } 98 | 99 | main .card p { 100 | font-size: 16px; 101 | line-height: 26px; 102 | 103 | color: #6c6c80; 104 | } 105 | -------------------------------------------------------------------------------- /public/styles/home.css: -------------------------------------------------------------------------------- 1 | #page-home { 2 | height: 100vh; 3 | 4 | background: url('../assets/home-background.svg') no-repeat; 5 | background-position: 35vw bottom; 6 | } 7 | 8 | #page-home .content { 9 | width: 90%; 10 | max-width: 1100px; 11 | height: 100%; 12 | 13 | margin: 0 auto; 14 | 15 | display: flex; 16 | flex-direction: column; 17 | } 18 | 19 | #page-home header{ 20 | 21 | margin-top: 48px; 22 | 23 | display: flex; 24 | align-items: center; 25 | justify-content: space-between; 26 | } 27 | 28 | #page-home header a { 29 | display: flex; 30 | 31 | color: var(--title-color); 32 | font-weight: 700; 33 | } 34 | 35 | #page-home header a span { 36 | margin-right: 16px; 37 | display: flex; 38 | 39 | background-image: url('../assets/log-in.svg'); 40 | 41 | width: 20px; 42 | height: 20px; 43 | } 44 | 45 | #page-home main { 46 | max-width: 560px; 47 | 48 | flex: 1; 49 | 50 | display: flex; 51 | flex-direction: column; 52 | justify-content: center; 53 | } 54 | 55 | #page-home main h1 { 56 | font-size: 54px; 57 | } 58 | 59 | #page-home main p { 60 | font-size: 24px; 61 | line-height: 38px; 62 | margin-top: 24px; 63 | } 64 | 65 | #page-home main a { 66 | width: 100%; 67 | max-width: 360px; 68 | height: 72px; 69 | 70 | border-radius: 8px; 71 | 72 | display: flex; 73 | align-items: center; 74 | 75 | margin-top: 40px; 76 | 77 | background: var(--primary-color); 78 | 79 | transition: 400ms; 80 | } 81 | 82 | #page-home main a:hover { 83 | background-color: #2fb86e; 84 | } 85 | 86 | #page-home main a span { 87 | width: 72px; 88 | height: 72px; 89 | 90 | border-top-left-radius: 8px; 91 | border-bottom-left-radius: 8px; 92 | 93 | background-color: rgba(0, 0, 0, 0.08); 94 | 95 | display: flex; 96 | align-items: center; 97 | justify-content: center; 98 | } 99 | 100 | #page-home main a span::after { 101 | content: ''; 102 | background-image: url('../assets/search.svg'); 103 | 104 | width: 20px; 105 | height: 20px; 106 | } 107 | 108 | #page-home main a strong { 109 | flex: 1; 110 | color: white; 111 | text-align: center; 112 | } -------------------------------------------------------------------------------- /src/database/db.ts: -------------------------------------------------------------------------------- 1 | import sqlite3 from 'sqlite3'; 2 | 3 | const db = new sqlite3.Database("./src/database/database.db"); 4 | 5 | export default db; 6 | 7 | interface IPlaces { 8 | image: string, 9 | name: string, 10 | address: string, 11 | address2: string, 12 | state: string, 13 | city: string, 14 | items: string 15 | } 16 | 17 | db.serialize(() => { 18 | // create a table with SQL commands: 19 | // the firs param of data is the type of same 20 | // PRIMARY KEY -> main data 21 | // AUTOINCRMENT -> autoincrement when add a new register 22 | db.run(` 23 | CREATE TABLE IF NOT EXISTS places ( 24 | id INTEGER PRIMARY KEY AUTOINCREMENT, 25 | image TEXT, 26 | name TEXT, 27 | address TEXT, 28 | address2 TEXT, 29 | state TEXT, 30 | city TEXT, 31 | items TEXT 32 | ); 33 | `); 34 | 35 | // // insert data into the table with SQL commands 36 | // const query = ` 37 | // INSERT INTO places ( 38 | // image, 39 | // name, 40 | // address, 41 | // address2, 42 | // state, 43 | // city, 44 | // items 45 | // ) VALUES (?,?,?,?,?,?,?); 46 | // ` 47 | // const values = [ 48 | // "https://images.unsplash.com/photo-1567393528677-d6adae7d4a0a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80", 49 | // "Papersider", 50 | // "Gulherme Gemballa, Jardim América", 51 | // "Nº 260", 52 | // "Santa Catarina", 53 | // "Rio do Sul", 54 | // "Papéis e Papelão" 55 | // ] 56 | 57 | // function afterInsertData(err: any): void { 58 | // if (err) { 59 | // return console.log(err) 60 | // } 61 | 62 | // console.log("[personal] Cadastrado com sucesso") 63 | // console.log(this) 64 | // } 65 | 66 | // db.run(query, values, afterInsertData); 67 | 68 | // // query table data with SQL commands 69 | // db.all(`SELECT * FROM places`, function(err, rows: [IPlaces]) { 70 | // if (err) { 71 | // return console.log(err) 72 | // } 73 | 74 | // console.log("[personal] Aqui estão seus registros") 75 | // console.log(rows) 76 | // }) 77 | 78 | // // delete a table data with SQL commands 79 | // db.run(`DELETE FROM places WHERE id = ?`, [8], function(err) { 80 | // if (err) { 81 | // return console.log(err) 82 | // } 83 | 84 | // console.log("[personal] Registro deletado com sucesso") 85 | // }) 86 | }); 87 | -------------------------------------------------------------------------------- /src/routes.ts: -------------------------------------------------------------------------------- 1 | import express from 'express'; 2 | import showAndSaveLog from './log/log'; 3 | import db from './database/db'; 4 | 5 | interface IPlaces { 6 | image: string, 7 | name: string, 8 | address: string, 9 | address2: string, 10 | state: string, 11 | city: string, 12 | items: string 13 | } 14 | 15 | const now = () => { 16 | const dateClass = new Date(); 17 | const dateHour = `${dateClass.getDay()}/${dateClass.getMonth()}/${dateClass.getFullYear()}-${dateClass.getHours()}:${dateClass.getMinutes()}:${dateClass.getSeconds()}`; 18 | return dateHour; 19 | }; 20 | 21 | const routes = express.Router(); 22 | 23 | routes.get('/', (req, res) => { 24 | showAndSaveLog('rendering index.html', now()); 25 | return res.render('index.html'); 26 | }); 27 | 28 | routes.get('/create-point', (req, res) => { 29 | showAndSaveLog('rendering create-point.html', now()); 30 | return res.render('create-point.html'); 31 | }); 32 | 33 | routes.post('/savepoint', (req, res) => { 34 | const query = ` 35 | INSERT INTO places ( 36 | image, 37 | name, 38 | address, 39 | address2, 40 | state, 41 | city, 42 | items 43 | ) VALUES (?,?,?,?,?,?,?); 44 | `; 45 | const values = [ 46 | req.body.image, 47 | req.body.name, 48 | req.body.address, 49 | req.body.address2, 50 | req.body.state, 51 | req.body.city, 52 | req.body.items, 53 | ]; 54 | 55 | showAndSaveLog('registering point', now()); 56 | db.run(query, values, (err: any) => { 57 | if (err) { 58 | showAndSaveLog('error when registering point', now()); 59 | // eslint-disable-next-line no-console 60 | console.log(err); 61 | return res.send('Erro no cadastro'); 62 | } 63 | 64 | showAndSaveLog('data registered in database', now()); 65 | showAndSaveLog('rendering create-point.html', now()); 66 | return res.render('create-point.html', { saved: true }); 67 | }); 68 | }); 69 | 70 | routes.get('/search-results', (req, res) => { 71 | const { search } = req.query; 72 | 73 | if (search === '') { 74 | showAndSaveLog('rendering search-results.html', now()); 75 | return res.render('search-results.html', { total: 0 }); 76 | } 77 | 78 | db.all(`SELECT * FROM places WHERE city LIKE '%${search}%'`, (err: any, rows: [IPlaces]) => { 79 | if (err) { 80 | console.log(err); 81 | } 82 | 83 | showAndSaveLog('rendering search-results.html', now()); 84 | return res.render('search-results.html', { 85 | places: rows, 86 | total: rows.length, 87 | }); 88 | }); 89 | }); 90 | 91 | export default routes; 92 | -------------------------------------------------------------------------------- /public/scripts/create-point.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | function populatesUfs() { 4 | const ufSelect = document.querySelector("select[name=uf]") 5 | 6 | fetch("https://servicodados.ibge.gov.br/api/v1/localidades/estados") 7 | .then( res => res.json() ) 8 | .then( states => { 9 | 10 | for ( const state of states ) { 11 | ufSelect.innerHTML += `` 12 | } 13 | 14 | } ) 15 | } 16 | 17 | populatesUfs() 18 | 19 | 20 | function getCities(event) { 21 | const citySelect = document.querySelector("[name=city]") 22 | const stateInput = document.querySelector("[name=state]") 23 | 24 | const ufValue = event.target.value 25 | 26 | 27 | const indexOfSelectedState = event.target.selectedIndex 28 | stateInput.value = event.target.options[indexOfSelectedState].text 29 | 30 | 31 | const url = `https://servicodados.ibge.gov.br/api/v1/localidades/estados/${ufValue}/municipios` 32 | 33 | citySelect.innerHTML = "" 34 | citySelect.disabled = true 35 | 36 | fetch(url) 37 | .then( res => res.json() ) 38 | .then( cities => { 39 | 40 | for ( const city of cities ) { 41 | citySelect.innerHTML += `` 42 | } 43 | 44 | citySelect.disabled = false 45 | } ) 46 | 47 | 48 | } 49 | 50 | 51 | document 52 | .querySelector("select[name=uf]") 53 | .addEventListener("change", getCities) 54 | 55 | 56 | // items de coleta 57 | // pegar todos os li's 58 | 59 | const itemsToCollect = document.querySelectorAll(".items-grid li") 60 | 61 | for (const item of itemsToCollect) { 62 | item.addEventListener("click", handleSelectedItem) 63 | } 64 | 65 | const collectedItems = document.querySelector("input[name=items]") 66 | 67 | 68 | let selectedItems = [] 69 | 70 | 71 | 72 | function handleSelectedItem(event) { 73 | const itemLi = event.target 74 | 75 | // add or remove a class with javascript 76 | itemLi.classList.toggle("selected") 77 | 78 | const itemId = itemLi.dataset.id 79 | 80 | 81 | // verificar se existem items selecionados, se sim 82 | // pegar ps itens selecionados 83 | 84 | const alreadySelected = selectedItems.findIndex( item => { 85 | const itemFound = item == itemId // isso será true ou false 86 | return itemFound 87 | } ) 88 | 89 | 90 | // se ja estiver selecionado, tirar da seleção 91 | if (alreadySelected >= 0) { 92 | // tirar da seleção 93 | const filteredItems = selectedItems.filter( item => { 94 | const itemIsDifferent = item != itemId 95 | return itemIsDifferent 96 | } ) 97 | 98 | selectedItems = filteredItems 99 | } else { 100 | // se não estiver selecionado adicionar a seleção 101 | selectedItems.push(itemId) 102 | } 103 | 104 | 105 | // atualisar o campo escondido com os dados selecionados 106 | collectedItems.value = selectedItems 107 | 108 | } -------------------------------------------------------------------------------- /public/styles/create-point.css: -------------------------------------------------------------------------------- 1 | #page-create-point { 2 | width: 90%; 3 | max-width: 1100px; 4 | 5 | margin: 0 auto; 6 | } 7 | 8 | #page-create-point header { 9 | margin-top: 48px; 10 | 11 | display: flex; 12 | justify-content: space-between; 13 | align-items: center; 14 | } 15 | 16 | #page-create-point header a { 17 | color: var(--title-color); 18 | font-weight: bold; 19 | 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | #page-create-point header a span { 25 | margin-right: 16px; 26 | background-image: url('../assets/arrow-left.svg'); 27 | 28 | display: flex; 29 | 30 | width: 20px; 31 | height: 24px; 32 | } 33 | 34 | form { 35 | background-color: white; 36 | 37 | margin: 80px auto; 38 | padding: 64px; 39 | 40 | border-radius: 8px; 41 | 42 | max-width: 730px; 43 | } 44 | 45 | 46 | 47 | form h1 { 48 | font-size: 36px; 49 | } 50 | 51 | form fieldset { 52 | margin-top: 64px; 53 | 54 | border: 0; 55 | } 56 | 57 | form legend { 58 | margin-bottom: 40px; 59 | 60 | display: flex; 61 | align-items: center; 62 | justify-content: space-between; 63 | 64 | width: 100%; 65 | } 66 | 67 | form legend h2 { 68 | font-size: 24px; 69 | } 70 | 71 | form legend span { 72 | font-size: 14px; 73 | color: var(--title-color); 74 | } 75 | 76 | form .field { 77 | flex: 1; 78 | 79 | display: flex; 80 | flex-direction: column; 81 | 82 | margin-bottom: 24px; 83 | } 84 | 85 | form .field-group { 86 | display: flex; 87 | } 88 | 89 | form input, 90 | form select { 91 | background-color: #f0f0f5; 92 | 93 | border: 0; 94 | padding: 16px 24px; 95 | font-size: 16px; 96 | 97 | border-radius: 8px; 98 | 99 | /* outline: none; */ 100 | } 101 | 102 | form select { 103 | -webkit-appearance: none; 104 | -moz-appearance: none; 105 | appearance: none; 106 | } 107 | 108 | form label { 109 | font-size: 14px; 110 | margin-bottom: 8px; 111 | } 112 | 113 | form .field-group .field + .field { 114 | margin-left: 24px; 115 | } 116 | 117 | form button { 118 | width: 260px; 119 | height: 56px; 120 | 121 | background-color: var(--primary-color); 122 | border-radius: 8px; 123 | 124 | color: white; 125 | font-weight: bold; 126 | font-size: 16px; 127 | 128 | border: 0; 129 | 130 | margin-top: 40px; 131 | 132 | transform: background-color 400ms; 133 | } 134 | 135 | form button:hover { 136 | background-color: #2fb86e; 137 | } 138 | 139 | .items-grid { 140 | display: grid; 141 | grid-template-columns: 1fr 1fr 1fr; 142 | gap: 16px; 143 | } 144 | 145 | .items-grid li { 146 | background-color: #f5f5f5; 147 | list-style: none; 148 | 149 | border: 2px solid #f5f5f5; 150 | border-radius: 8px; 151 | height: 180px; 152 | 153 | padding: 32px 24px 16px; 154 | 155 | display: flex; 156 | flex-direction: column; 157 | align-items: center; 158 | justify-content: space-between; 159 | 160 | text-align: center; 161 | 162 | cursor: pointer; 163 | } 164 | 165 | .items-grid li span { 166 | margin-top: 12px; 167 | 168 | flex: 1; 169 | 170 | display: flex; 171 | align-items: center; 172 | 173 | color: var(--title-color); 174 | } 175 | 176 | .items-grid li.selected { 177 | background: #e1faec; 178 | border: 2px solid #34cb79; 179 | } 180 | 181 | .items-grid li img, 182 | .items-grid li span { 183 | pointer-events: none; 184 | } -------------------------------------------------------------------------------- /src/views/create-point.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% set pageId = "page-create-point" %} 4 | 5 | {% block title %} 6 | Criar um ponto de coleta 7 | {% endblock title %} 8 | 9 | {% block styles %} 10 | 11 | 12 | {% endblock styles %} 13 | 14 | {% block content %} 15 | {% include "partials/page-header.html" %} 16 | 17 |
18 | 19 |

Cadastro do ponto de coleta

20 | 21 |
22 | 23 |

Dados da entidade

24 |
25 | 26 |
27 |
28 | 29 | 30 |
31 |
32 | 33 | 34 |
35 |
36 | 37 |
38 |
39 | 40 | 41 |
42 |
43 | 44 | 45 |
46 |
47 | 48 |
49 |
50 | 51 | 54 | 55 | 56 |
57 | 58 |
59 | 60 | 63 |
64 |
65 | 66 |
67 | 68 |
69 | 70 |

Ítens de coleta

71 | Seleciona um ou mais ítens abaixo 72 |
73 | 74 |
75 |
  • 76 | Lâmpadas 77 | Lâmpadas 78 |
  • 79 | 80 |
  • 81 | Pilhas e Baterias 82 | Pilhas e Baterias 83 |
  • 84 | 85 |
  • 86 | Papéis e Papelão 87 | Papéis e Papelão 88 |
  • 89 | 90 |
  • 91 | Resíduos Eletrônicos 92 | Resíduos Eletrônicos 93 |
  • 94 | 95 |
  • 96 | Resíduos Orgânicos 97 | Resíduos Orgânicos 98 |
  • 99 | 100 |
  • 101 | Óleo de Cosinha 102 | Óleo de Cosinha 103 |
  • 104 |
    105 | 106 | 107 | 108 |
    109 | 110 | 111 | 112 | 113 | 114 |
    115 | 116 | {% endblock content %} 117 | 118 | {% block modal %} 119 | {% if saved %} 120 | {% include "partials/point-created.html" %} 121 | {% endif %} 122 | {% endblock modal %} 123 | 124 | {% block scripts %} 125 | 126 | {% endblock scripts %} 127 | -------------------------------------------------------------------------------- /docs/icones/lampadas.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /public/assets/lampadas.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/icones/eletronicos.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /public/assets/eletronicos.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "./dist", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
    2 | 3 | # ![Ecoleta](docs/icones/logo.svg) 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | **Ecoleta é uma aplicação que ajuda a encontrar pontos de coleta de lixo reciclável no Brasil.** 13 | 14 | Página principal 15 | 16 | Home 17 | 18 | Página de pesquisa de Pontos de Coleta em uma determinada cidade 19 | 20 | Página de pesquisa 21 | 22 | Página de cadastro de Ponto de Coleta 23 | 24 | Página de cadastro 25 | 26 | --- 27 | 28 | 29 | _Aplicação feita na Next Level Week #1 da [@Rocketseat](https://github.com/Rocketseat), nos dias 1 a 5 de Junho_ 30 | ![nlw](docs/nlw.png) 31 | 32 |
    33 | 34 | ### Tecnologias 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | #### Front-end: 44 | 45 | - [Nunjucks](https://mozilla.github.io/nunjucks/) 46 | - [HTML 5](http://www.w3.org/TR/html5/) 47 | - [CSS 3](https://www.w3schools.com/Css/) 48 | - [JavaScript](https://www.javascript.com/) 49 | 50 | #### Back-end: 51 | 52 | - [NodeJS](https://nodejs.org/) 53 | - [Express](https://expressjs.com/) 54 | - [Nodemon](https://nodemon.io/) 55 | - [SQLite3](https://www.sqlite.org/) 56 | 57 | #### APIs 58 | 59 | - [IBGE](https://servicodados.ibge.gov.br/api/docs/localidades?versao=1) 60 | 61 | ### Uso 62 | 63 | #### Instalar dependencias: 64 |
    65 | com npm 66 | 67 | ```bash 68 | $ npm install 69 | ``` 70 |
    71 |
    72 | com yarn 73 | 74 | ```bash 75 | $ yarn install 76 | ``` 77 |
    78 | 79 | #### Iniciar servidor: 80 |
    81 | com npm 82 | 83 | ```bash 84 | $ npm start 85 | ``` 86 |
    87 |
    88 | com yarn 89 | 90 | ```bash 91 | $ yarn run start 92 | ``` 93 |
    94 | 95 | > porta: 3000 96 | 97 | Para trocar a porta basta ir em [src/server.js:97](https://github.com/mateusfg7/Ecoleta/blob/master/src/server.js#L97), e trocar o porta 3000 para a porta desejada. 98 | ```javascript 99 | // turn on the server 100 | server.listen(3000); 101 | ``` 102 | 103 | ### Criar Bando de Dados 104 | 105 | Para criar o banco de dados descomente as linhas 9 a 79, depois as linhas 11 a 26 do arquivo [src/database/db.js](https://github.com/mateusfg7/Ecoleta/blob/master/src/database/db.js) 106 | 107 | ```js 108 | // use the object of the database, for our operations 109 | db.serialize(() => { 110 | // create a table with SQL commands: 111 | // the firs param of data is the type of same 112 | // PRIMARY KEY -> main data 113 | // AUTOINCRMENT -> autoincrement when add a new register 114 | db.run(` 115 | CREATE TABLE IF NOT EXISTS places ( 116 | id INTEGER PRIMARY KEY AUTOINCREMENT, 117 | image TEXT, 118 | name TEXT, 119 | address TEXT, 120 | address2 TEXT, 121 | state TEXT, 122 | city TEXT, 123 | items TEXT 124 | ); 125 | `); 126 | 127 | // // insert data into the table with SQL commands 128 | // const query = ` 129 | // INSERT INTO places ( 130 | // image, 131 | // name, 132 | // address, 133 | // address2, 134 | // state, 135 | // city, 136 | // items 137 | // ) VALUES (?,?,?,?,?,?,?); 138 | // ` 139 | // const values = [ 140 | // "https://images.unsplash.com/photo-1567393528677-d6adae7d4a0a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80", 141 | // "Papersider", 142 | // "Gulherme Gemballa, Jardim América", 143 | // "Nº 260", 144 | // "Santa Catarina", 145 | // "Rio do Sul", 146 | // "Papéis e Papelão" 147 | // ] 148 | 149 | // function afterInsertData(err) { 150 | // if (err) { 151 | // return console.log(err) 152 | // } 153 | 154 | // console.log("[personal] Cadastrado com sucesso") 155 | // console.log(this) 156 | // } 157 | 158 | // db.run(query, values, afterInsertData); 159 | 160 | // // query table data with SQL commands 161 | // db.all(`SELECT * FROM places`, function(err, rows) { 162 | // if (err) { 163 | // return console.log(err) 164 | // } 165 | 166 | // console.log("[personal] Aqui estão seus registros") 167 | // console.log(rows) 168 | // }) 169 | 170 | // // delete a table data with SQL commands 171 | // db.run(`DELETE FROM places WHERE id = ?`, [8], function(err) { 172 | // if (err) { 173 | // return console.log(err) 174 | // } 175 | 176 | // console.log("[personal] Registro deletado com sucesso") 177 | // }) 178 | }); 179 | ``` 180 | 181 | e rode com 182 | ```bash 183 | $ node src/database/db.js 184 | ``` 185 | Depois de criado, recomente as linhas e [rode o servidor](#iniciar-servidor). 186 | 187 | > O arquivo do banco de dados ficara salvo em src/database/database.db 188 | 189 | --- 190 | 191 | 192 | 193 | 196 | 199 | 200 | 201 | 206 | 211 | 212 | 213 | 216 | 219 | 220 |
    194 | Code by 195 | 197 | Instrutor 198 |
    202 | 203 | 204 | 205 | 207 | 208 | 209 | 210 |
    214 | @mateusfg7 215 | 217 | @maykbrito 218 |
    221 | 222 | > Branch com alterações pessoais: [master](https://github.com/mateusfg7/Ecoleta/tree/master) 223 | 224 | > Branch com o projeto original: [nlw_main_project](https://github.com/mateusfg7/Ecoleta/tree/nlw_main_projects) 225 | 226 | --- 227 | 228 | [@Rocketseat](https://github.com/Rocketseat) 229 | 230 | 231 | 232 | 233 | 234 | 235 | -------------------------------------------------------------------------------- /docs/icones/oleo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /public/assets/oleo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/icones/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /public/assets/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /docs/icones/organicos.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /public/assets/organicos.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /public/assets/home-background.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | --------------------------------------------------------------------------------