-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (24 loc) · 667 Bytes
/
Copy pathindex.js
File metadata and controls
33 lines (24 loc) · 667 Bytes
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
import express from 'express';
import sharp from "sharp";
import cors from 'cors';
import morgan from 'morgan';
import getDominantColor from './getDominantColor.js';
const app = express();
//Middlewares
app.use(cors());
app.use(morgan('dev'));
app.use(express.json());
// Funcionalidades
app.post('/api/color', async (req, res) => {
try {
const { url } = req.body;
console.log(url);
const color = await getDominantColor(url);
res.json({message: 'success', color});
} catch (error) {
res.status(500).send({ error: error.message });
}
});
app.listen(3000, () => {
console.log('Server on port 3000');
});