-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
48 lines (35 loc) · 1.27 KB
/
index.js
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
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
//controllers
const ControllerCPF = require('./src/controllers/ControllerCPF.js');
const ControllerCNPJ = require('./src/controllers/ControllerCNPJ.js');
const PORT = process.env.PORT || 9002
app.use(express.json());
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization')
next();
})
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});
app.get('/validarCpf/:cpf', async (req, res) => {
const {cpf} = req.params;
const response = await ControllerCPF.ValidarCPF(cpf)
res.json(response)
})
app.get('/gerarCpf', async (req, res) => {
const response = await ControllerCPF.GerarCPF()
res.json(response)
})
app.get('/validarCnpj/:cnpj', async (req, res) => {
const {cnpj} = req.params;
const response = await ControllerCNPJ.ValidarCNPJ(cnpj)
res.json(response)
})
app.get('/gerarCnpj', async (req, res) => {
const response = await ControllerCNPJ.GerarCNPJ()
res.json(response)
})