0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Added /images/ endpoints to Admin API v2

refs #10438

- make /images/ available
- we want to document this endpoint notiation, because it is more specific and fits better, because you can only upload images
- either we drop /uploads/ by the end of the project cycle or we keep both for now
- the Admin API v2 is currently undocumented and allows breaking changes in theory
This commit is contained in:
kirrg001 2019-01-31 13:09:09 +01:00
parent b4e2187e76
commit 23f705d556
2 changed files with 28 additions and 3 deletions

View file

@ -13,7 +13,7 @@ const notImplemented = function (req, res, next) {
// @NOTE: stable
posts: ['GET', 'PUT', 'DELETE', 'POST'],
tags: ['GET', 'PUT', 'DELETE', 'POST'],
uploads: ['POST'],
images: ['POST'],
// @NOTE: experimental
users: ['GET'],
themes: ['POST']

View file

@ -181,8 +181,8 @@ module.exports = function apiRoutes() {
router.put('/authentication/setup', mw.authAdminApi, api.http(api.authentication.updateSetup));
router.get('/authentication/setup', api.http(api.authentication.isSetup));
// ## Uploads
// @TODO: rename endpoint to /images/upload (or similar)
// ## Images
// @TODO: remove /uploads/ in favor of /images/ in Ghost 3.x
router.post('/uploads',
mw.authAdminApi,
upload.single('uploadimage'),
@ -208,6 +208,31 @@ module.exports = function apiRoutes() {
apiv2.http(apiv2.upload.image)
);
router.post('/images',
mw.authAdminApi,
upload.single('uploadimage'),
shared.middlewares.validation.upload({type: 'images'}),
shared.middlewares.image.normalize,
apiv2.http(apiv2.upload.image)
);
router.post('/images/profile-image',
mw.authAdminApi,
upload.single('uploadimage'),
shared.middlewares.validation.upload({type: 'images'}),
shared.middlewares.validation.profileImage,
shared.middlewares.image.normalize,
apiv2.http(apiv2.upload.image)
);
router.post('/images/icon',
mw.authAdminApi,
upload.single('uploadimage'),
shared.middlewares.validation.upload({type: 'icons'}),
shared.middlewares.validation.blogIcon(),
apiv2.http(apiv2.upload.image)
);
// ## Invites
router.get('/invites', mw.authAdminApi, apiv2.http(apiv2.invites.browse));
router.get('/invites/:id', mw.authAdminApi, apiv2.http(apiv2.invites.read));