mirror of
https://github.com/TryGhost/Ghost.git
synced 2023-12-13 21:00:40 +01:00
parent
a4ce3d1be8
commit
8295f5f967
|
@ -1,4 +1,4 @@
|
||||||
var debug = require('ghost-ignition').debug('admin'),
|
const debug = require('ghost-ignition').debug('admin'),
|
||||||
express = require('express'),
|
express = require('express'),
|
||||||
|
|
||||||
// App requires
|
// App requires
|
||||||
|
@ -20,8 +20,7 @@ var debug = require('ghost-ignition').debug('admin'),
|
||||||
|
|
||||||
module.exports = function setupAdminApp() {
|
module.exports = function setupAdminApp() {
|
||||||
debug('Admin setup start');
|
debug('Admin setup start');
|
||||||
var adminApp = express(),
|
const adminApp = express();
|
||||||
configMaxAge;
|
|
||||||
|
|
||||||
// First determine whether we're serving admin or theme content
|
// First determine whether we're serving admin or theme content
|
||||||
// @TODO finish refactoring this away.
|
// @TODO finish refactoring this away.
|
||||||
|
@ -32,7 +31,7 @@ module.exports = function setupAdminApp() {
|
||||||
|
|
||||||
// Admin assets
|
// Admin assets
|
||||||
// @TODO ensure this gets a local 404 error handler
|
// @TODO ensure this gets a local 404 error handler
|
||||||
configMaxAge = config.get('caching:admin:maxAge');
|
const configMaxAge = config.get('caching:admin:maxAge');
|
||||||
adminApp.use('/assets', serveStatic(
|
adminApp.use('/assets', serveStatic(
|
||||||
config.get('paths').clientAssets,
|
config.get('paths').clientAssets,
|
||||||
{maxAge: (configMaxAge || configMaxAge === 0) ? configMaxAge : constants.ONE_YEAR_MS, fallthrough: false}
|
{maxAge: (configMaxAge || configMaxAge === 0) ? configMaxAge : constants.ONE_YEAR_MS, fallthrough: false}
|
||||||
|
@ -44,7 +43,7 @@ module.exports = function setupAdminApp() {
|
||||||
// Ember CLI's live-reload script
|
// Ember CLI's live-reload script
|
||||||
if (config.get('env') === 'development') {
|
if (config.get('env') === 'development') {
|
||||||
adminApp.get('/ember-cli-live-reload.js', function (req, res) {
|
adminApp.get('/ember-cli-live-reload.js', function (req, res) {
|
||||||
res.redirect('http://localhost:4200' + urlService.utils.getSubdir() + '/ghost/ember-cli-live-reload.js');
|
res.redirect(`http://localhost:4200${urlService.utils.getSubdir()}/ghost/ember-cli-live-reload.js`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
var urlService = require('../../services/url');
|
const urlService = require('../../services/url');
|
||||||
|
|
||||||
function redirectAdminUrls(req, res, next) {
|
function redirectAdminUrls(req, res, next) {
|
||||||
var subdir = urlService.utils.getSubdir(),
|
const subdir = urlService.utils.getSubdir(),
|
||||||
ghostPathRegex = new RegExp('^' + subdir + '/ghost/(.+)'),
|
ghostPathRegex = new RegExp(`^${subdir}/ghost/(.+)`),
|
||||||
ghostPathMatch = req.originalUrl.match(ghostPathRegex);
|
ghostPathMatch = req.originalUrl.match(ghostPathRegex);
|
||||||
|
|
||||||
if (ghostPathMatch) {
|
if (ghostPathMatch) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var debug = require('ghost-ignition').debug('admin:serviceworker'),
|
const debug = require('ghost-ignition').debug('admin:serviceworker'),
|
||||||
path = require('path');
|
path = require('path');
|
||||||
|
|
||||||
// Route: index
|
// Route: index
|
||||||
|
@ -7,7 +7,7 @@ var debug = require('ghost-ignition').debug('admin:serviceworker'),
|
||||||
module.exports = function adminController(req, res) {
|
module.exports = function adminController(req, res) {
|
||||||
debug('serviceworker called');
|
debug('serviceworker called');
|
||||||
|
|
||||||
var sw = path.join(__dirname, '..', '..', '..', 'built', 'assets', 'sw.js'),
|
const sw = path.join(__dirname, '..', '..', '..', 'built', 'assets', 'sw.js'),
|
||||||
swr = path.join(__dirname, '..', '..', '..', 'built', 'assets', 'sw-registration.js'),
|
swr = path.join(__dirname, '..', '..', '..', 'built', 'assets', 'sw-registration.js'),
|
||||||
fileToSend = req.url === '/sw.js' ? sw : swr;
|
fileToSend = req.url === '/sw.js' ? sw : swr;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// # API routes
|
// # API routes
|
||||||
var debug = require('ghost-ignition').debug('api'),
|
const debug = require('ghost-ignition').debug('api'),
|
||||||
express = require('express'),
|
express = require('express'),
|
||||||
|
|
||||||
// routes
|
// routes
|
||||||
|
@ -18,7 +18,7 @@ var debug = require('ghost-ignition').debug('api'),
|
||||||
|
|
||||||
module.exports = function setupApiApp() {
|
module.exports = function setupApiApp() {
|
||||||
debug('API setup start');
|
debug('API setup start');
|
||||||
var apiApp = express();
|
const apiApp = express();
|
||||||
|
|
||||||
// @TODO finish refactoring this away.
|
// @TODO finish refactoring this away.
|
||||||
apiApp.use(function setIsAdmin(req, res, next) {
|
apiApp.use(function setIsAdmin(req, res, next) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var prettyURLs = require('../middleware/pretty-urls'),
|
const prettyURLs = require('../middleware/pretty-urls'),
|
||||||
cors = require('../middleware/api/cors'),
|
cors = require('../middleware/api/cors'),
|
||||||
urlRedirects = require('../middleware/url-redirects'),
|
urlRedirects = require('../middleware/url-redirects'),
|
||||||
auth = require('../../services/auth');
|
auth = require('../../services/auth');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var express = require('express'),
|
const express = require('express'),
|
||||||
// This essentially provides the controllers for the routes
|
// This essentially provides the controllers for the routes
|
||||||
api = require('../../api'),
|
api = require('../../api'),
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ var express = require('express'),
|
||||||
|
|
||||||
// @TODO refactor/clean this up - how do we want the routing to work long term?
|
// @TODO refactor/clean this up - how do we want the routing to work long term?
|
||||||
module.exports = function apiRoutes() {
|
module.exports = function apiRoutes() {
|
||||||
var apiRouter = express.Router();
|
const apiRouter = express.Router();
|
||||||
|
|
||||||
// alias delete with del
|
// alias delete with del
|
||||||
apiRouter.del = apiRouter.delete;
|
apiRouter.del = apiRouter.delete;
|
||||||
|
|
Loading…
Reference in a new issue