wrapped imagemagic functions in promises
This commit is contained in:
parent
41ccf06370
commit
27eddbe42e
3 changed files with 42 additions and 26 deletions
34
README.md
34
README.md
|
@ -9,6 +9,11 @@ To get started running your own version of spee.ch, visit [lbryio/www.spee.ch](h
|
||||||
npm install spee.ch --save
|
npm install spee.ch --save
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Dependenceis
|
||||||
|
Install the following programs:
|
||||||
|
* [imagemagick](https://www.imagemagick.org/)
|
||||||
|
* [ffmpeg](https://www.ffmpeg.org/)
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
* the `server/` folder contains all of the server code
|
* the `server/` folder contains all of the server code
|
||||||
* `index.js` is the entry point for the server. It creates the [express app](https://expressjs.com/), requires the routes, syncs the database, and starts the server listening on the `PORT` designated in the config file.
|
* `index.js` is the entry point for the server. It creates the [express app](https://expressjs.com/), requires the routes, syncs the database, and starts the server listening on the `PORT` designated in the config file.
|
||||||
|
@ -23,21 +28,7 @@ npm install spee.ch --save
|
||||||
* To run only tests that do not require LBC, run `npm run test:no-lbc`
|
* To run only tests that do not require LBC, run `npm run test:no-lbc`
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
* _(post)_ /api/claim/publish
|
||||||
#### GET
|
|
||||||
* /api/claim/resolve/:name/:claimId
|
|
||||||
* example: `curl https://spee.ch/api/claim/resolve/doitlive/xyz`
|
|
||||||
* /api/claim/list/:name
|
|
||||||
* example: `curl https://spee.ch/api/claim/list/doitlive`
|
|
||||||
* /api/claim/availability/:name
|
|
||||||
* returns the name if it is available
|
|
||||||
* example: `curl https://spee.ch/api/claim/availability/doitlive`
|
|
||||||
* /api/channel/availability/:name
|
|
||||||
* returns the name if it is available
|
|
||||||
* example: `curl https://spee.ch/api/channel/availability/@CoolChannel`
|
|
||||||
|
|
||||||
#### POST
|
|
||||||
* /api/claim/publish
|
|
||||||
* example: `curl -F 'name=MyPictureName' -F 'file=@/path/to/myPicture.jpeg' https://spee.ch/api/claim/publish`
|
* example: `curl -F 'name=MyPictureName' -F 'file=@/path/to/myPicture.jpeg' https://spee.ch/api/claim/publish`
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* `name` (required)
|
* `name` (required)
|
||||||
|
@ -49,6 +40,16 @@ npm install spee.ch --save
|
||||||
* `thumbnail` url to thumbnail image, for .mp4 uploads only (optional)
|
* `thumbnail` url to thumbnail image, for .mp4 uploads only (optional)
|
||||||
* `channelName`(optional)
|
* `channelName`(optional)
|
||||||
* `channelPassword` (optional,; required if `channelName` is provided)
|
* `channelPassword` (optional,; required if `channelName` is provided)
|
||||||
|
* _(get)_ /api/claim/resolve/:name/:claimId
|
||||||
|
* example: `curl https://spee.ch/api/claim/resolve/doitlive/xyz`
|
||||||
|
* _(get)_ /api/claim/list/:name
|
||||||
|
* example: `curl https://spee.ch/api/claim/list/doitlive`
|
||||||
|
* _(get)_ /api/claim/availability/:name
|
||||||
|
* returns the name if it is available
|
||||||
|
* example: `curl https://spee.ch/api/claim/availability/doitlive`
|
||||||
|
* _(get)_ /api/channel/availability/:name
|
||||||
|
* returns the name if it is available
|
||||||
|
* example: `curl https://spee.ch/api/channel/availability/@CoolChannel`
|
||||||
|
|
||||||
## Bugs
|
## Bugs
|
||||||
If you find a bug or experience a problem, please report your issue here on github and find us in the lbry discord!
|
If you find a bug or experience a problem, please report your issue here on github and find us in the lbry discord!
|
||||||
|
@ -69,4 +70,7 @@ Issues with spee.ch strong familiarity with the spee.ch code base and how the lb
|
||||||
Issues with lbry (e.g. the spee.ch wallet, lbrynet configuration, etc.) that require strong familiarity with the lbry daemon and/or network to fix. Generally these issues are best suited for the lbry protocol team but are placed in this repo because of they are part of the spee.ch implementation
|
Issues with lbry (e.g. the spee.ch wallet, lbrynet configuration, etc.) that require strong familiarity with the lbry daemon and/or network to fix. Generally these issues are best suited for the lbry protocol team but are placed in this repo because of they are part of the spee.ch implementation
|
||||||
|
|
||||||
### Stack
|
### Stack
|
||||||
|
* node
|
||||||
|
* mysql
|
||||||
|
* react
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const { getImageHeightAndWidth } = require('./imageProcessing');
|
const { getImageHeightAndWidth } = require('./imageProcessing');
|
||||||
const { getVideoHeightAndWidth } = require('./utils/videoProcessing');
|
const { getVideoHeightAndWidth } = require('./videoProcessing');
|
||||||
|
|
||||||
async function getMediaDimensions (fileType, filePath) {
|
async function getMediaDimensions (fileType, filePath) {
|
||||||
let height = 0;
|
let height = 0;
|
||||||
|
|
|
@ -1,24 +1,36 @@
|
||||||
const im = require('imagemagick');
|
const im = require('imagemagick');
|
||||||
|
|
||||||
const getImageMetadata = (filePath) => {
|
const getImageMetadata = (filePath) => {
|
||||||
return im.readMetadata(filePath, (err, metadata) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (err) throw err;
|
im.readMetadata(filePath, (err, metadata) => {
|
||||||
return metadata;
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
resolve(metadata);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const getImageDetails = (filePath) => {
|
const getImageDetails = (filePath) => {
|
||||||
return im.identify(filePath, (err, details) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (err) throw err;
|
im.identify(filePath, (err, details) => {
|
||||||
return details;
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
resolve(details);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const getImageHeightAndWidth = (filePath) => {
|
const getImageHeightAndWidth = (filePath) => {
|
||||||
return im.identify(filePath, (err, details) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (err) throw err;
|
im.identify(filePath, (err, details) => {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
const { height, width } = details;
|
const { height, width } = details;
|
||||||
return [height, width];
|
resolve([height, width]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue