-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (39 loc) · 1.03 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
49
require('dotenv').config() // ВЫПОЛНЯЕМ СРАЗУ МЕТОД КОНФИГ ИЗ ЗАТРЕБОВАННОЙ БИБЛЫ ДОТЕНВ
const express = require('express')
const sequelize = require('./db')
const PORT = process.env.PORT || 5000
const app = express()
const cors = require('cors');
const { response } = require('express')
const start = async () => {
try {
await sequelize.authenticate()
await sequelize.sync()
app.listen(PORT, () => console.log(`Server started on port ${PORT}`))
} catch(e) {
console.log(e)
}
}
app.get('/getdata', (req, res) => {
response.send(data);
console.log('getdata get request, data object with people array')
})
app.use(cors({
origin: '*'
}));
const data =
{
people: [
{
name: 'Dima',
age: 28
},
{
name: 'Masha',
age: 26
},
{
name: 'Sasha',
age: 20
},
]}