var express = require('express');
var consign = require('consign');
var app = express();
consign()
.include('./config/middlewares.js')
.then('./config/boot.js')
.then('models')
.then('controllers')
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
<?xml version="1.0" encoding="UTF-8"?> | |
<beans:beans xmlns="http://www.springframework.org/schema/mvc" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:beans="http://www.springframework.org/schema/beans" | |
xmlns:context="http://www.springframework.org/schema/context" | |
xmlns:tx="http://www.springframework.org/schema/tx" | |
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd | |
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd | |
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd | |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> |
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
#!python3 | |
""" | |
requirements: | |
requests==2.19.1 | |
Reference: http://docs.python-requests.org/en/master/user/quickstart/ | |
""" |
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
#!python3 | |
""" | |
requirements: | |
document==1.0 | |
lxml==4.2.4 | |
Pillow==5.2.0 | |
python-docx==0.8.7 |
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
import lombok.Builder; | |
import lombok.Data; | |
import org.springframework.data.mongodb.core.mapping.Document; | |
import java.util.List; | |
@Data | |
@Builder | |
@Document | |
public class Person { |
var uuid = require('uuid/v4');
module.exports = app => {
//************************************************************************************
// aqui estamos criadno nossa lista temporária que ira simular nosso Banco de Dados
//************************************************************************************
var tasks = Array.apply(null, Array(5)).map( () => {
return {
index.js
module.exports = app => {
console.log('controllers.index /');
app.get('/', (req, res) => {
res.send('REST API /');
});
};
var bodyParser = require('body-parser');
module.exports = app => {
app.set('port', 3000);
app.set('json spaces', 4);
app.use(bodyParser.json());
};
module.exports = app => {
const PORT = app.get('port');
app.listen(PORT, () => {
console.log(`Servidor rodando na porta ${PORT}`);
})
};
Obs.: a porta está sendo obtida através do app e será injetado no proximo módulo que vamos criar, o proprio objeto app estamos recebendo por injeção e será criado em outro módulo.
Chegamos ao nosso ultimo método do CRUD que é DELETE, neste método assim como no GET por id, recebemos o id da Task que deve ser deletada pela Path:
app.delete('/tasks/:id', (req, res) => {
console.log('delete...');
let id = req.params.id;
let index = tasks.findIndex((task => task.id === id));
NewerOlder