mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 02:41:50 +03:00
ca20f3a6b0
refs https://github.com/TryGhost/Ghost/issues/9623 - add `oembed-parser` module for checking provider availability for a url and fetching data from the provider - require it in the `overrides.js` file before the general Promise override so that the `promise-wrt` sub-dependency doesn't attempt to extend the Bluebird promise implementation - add `/oembed` authenticated endpoint - takes `?url=` query parameter to match against known providers - adds safeguard against oembed-parser's providers list not recognising http+https and www+non-www - responds with `ValidationError` if no provider is found - responds with oembed response from matched provider's oembed endpoint if match is found
24 lines
971 B
JavaScript
24 lines
971 B
JavaScript
const moment = require('moment-timezone');
|
|
|
|
/**
|
|
* oembed-parser uses promise-wtf to extend the global Promise with .finally
|
|
* - require it before global Bluebird Promise override so that promise-wtf
|
|
* doesn't error due to Bluebird's Promise already having a .finally
|
|
* - https://github.com/ndaidong/promise-wtf/issues/25
|
|
*/
|
|
const {extract, hasProvider} = require('oembed-parser'); // eslint-disable-line
|
|
|
|
/**
|
|
* force UTC
|
|
* - you can require moment or moment-timezone, both is configured to UTC
|
|
* - you are allowed to use new Date() to instantiate datetime values for models, because they are transformed into UTC in the model layer
|
|
* - be careful when not working with models, every value from the native JS Date is local TZ
|
|
* - be careful when you work with date operations, therefor always wrap a date into moment
|
|
*/
|
|
moment.tz.setDefault('UTC');
|
|
|
|
/**
|
|
* https://github.com/TryGhost/Ghost/issues/9064
|
|
*/
|
|
global.Promise = require('bluebird');
|