@WellsSA
@WellsSA
@WellsSA
Falando de APIs...
Como? { ... }
Por exemplo:
{
nome: 'Wells',
idade: 19,
avatar? : 'file_name.jpg'
image_url? : 'http://gambs:4000/files/file_name.jpg'
}
Divisão de responsabilidades! \o/
No geral:
{
...info,
avatar: {
...avatarInfo,
url: 'https://gambs:4000/dir/file_name.extension'
}
}
@WellsSA
Beleza, mas isso a gente já sabia
@WellsSA
Precisamos fazer isso funcionar!
https://gambs:4000/images/wells.jpg
@WellsSA
https://images.youracclaim.com/
images/993f0916-3c26-4d06-89ff-76c29e986d68/Watson%2BAssistant%2B-%2BFoundations.png
https://images.youracclaim.com/
images/993f0916-3c26-4d06-89ff-76c29e986d68/Watson%2BAssistant%2B-%2BFoundations.png
Por padrão nada, maaas:
Express.static
app.use(express.static('dirname'))
app.use('/route', express.static('dirname'))
Beleza! Então agora sim, certo?
const express = require('express'); //import express from 'express';
const app = express();
app.use('/files', express.static('images'));
app.listen(4000);
const express = require('express');
const app = express();
app.use('/files', express.static('../../..\assets\images/?'))
app.listen(4000);
Mas... !?
NodeJS <3
const express = require('express');
const path = require('path');
const app = express();
app.use('/files', express.static(path.resolve(__dirname, '..', 'assets', 'images')));
app.listen(4000);
Path resolver <3
@WellsSA
@WellsSA
{
nome: 'Wells',
idade: 19,
avatar: {
url: 'https://wellsadev.com/images/wells.jpg',
urlWebP: 'https://wellsadev.com/images/wells.webp'
}
}
Agora sim!
@WellsSA