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
FROM node:11-alpine | |
WORKDIR /node-app | |
COPY package.json . | |
RUN npm install --quiet | |
RUN npm install nodemon -g --quiet |
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
const mongoose = require('mongoose'); | |
const { Schema } = mongoose; | |
const carroSchema = new Schema({ | |
marca: { | |
type: String, | |
required: true | |
}, | |
modelo: { | |
type: String, |
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
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const mongoose = require('mongoose'); | |
const app = express(); | |
app.use(bodyParser.json()); | |
mongoose | |
.connect('mongodb://db:27017/crud-node-mongo-docker', { |
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
const express = require('express'); | |
const router = express.Router(); | |
const Carro = require('../models/Carro'); | |
router.post('/novo', (req, res) => { | |
const novoCarro = new Carro({ | |
marca: req.body.marca, | |
modelo: req.body.modelo | |
}); |
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
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const mongoose = require('mongoose'); | |
const app = express(); | |
app.use(bodyParser.json()); | |
// Adicionando arquivo de rota no endpoint /carros | |
const carros = require('./routes/carros'); |
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
const express = require('express'); | |
const router = express.Router(); | |
const Carro = require('../models/Carro'); | |
// Retorna um array com todos os documentos do banco de dados | |
router.get('/', (req, res) => { | |
Carro.find() | |
.then(carros => { | |
res.json(carros); |
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
version: '3' | |
services: | |
server: | |
container_name: NODEJS_SERVER_MEDIUM | |
build: '.' | |
volumes: | |
- ./:/node-app | |
- ./node_modules:/node-app/node_modules | |
environment: |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> | |
<title>Localstorage Page</title> | |
<!-- Bootstrap CSS --> | |
<link | |
rel="stylesheet" |
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
<script> | |
function addItem() { | |
// Pegando os valores dos campos name e qtd | |
const name = $('input[name=name]').val(); | |
const qtd = $('input[name=qtd]').val(); | |
// Criando uma string com o objeto a ser adicionado no localstorage | |
const dataObj = JSON.stringify({ name, qtd }); | |
localStorage.setItem('item', dataObj); |
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
<script> | |
function addItem() { | |
// Pegando os valores dos campos name e qtd | |
const name = $('input[name=name]').val(); | |
const qtd = $('input[name=qtd]').val(); | |
// Criando objeto com dados dos inputs | |
const dataObj = { name, qtd }; | |
/* |
OlderNewer