mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
fix(#9315): api v3 post, put, del JSON
also allow `app.alertError` to be called without an argument also fix `./nodebb build --dev` to actually build in dev mode
This commit is contained in:
committed by
Julian Lam
parent
c5231f10ff
commit
0d59fe3d2b
@@ -179,7 +179,7 @@ app.cacheBuster = null;
|
|||||||
};
|
};
|
||||||
|
|
||||||
app.alertError = function (message, timeout) {
|
app.alertError = function (message, timeout) {
|
||||||
message = message.message || message;
|
message = (message && message.message) || message;
|
||||||
|
|
||||||
if (message === '[[error:invalid-session]]') {
|
if (message === '[[error:invalid-session]]') {
|
||||||
app.handleInvalidSession();
|
app.handleInvalidSession();
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ define('api', () => {
|
|||||||
api.post = (route, payload, onSuccess) => call({
|
api.post = (route, payload, onSuccess) => call({
|
||||||
url: route,
|
url: route,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: payload,
|
data: JSON.stringify(payload),
|
||||||
|
contentType: 'application/json; charset=utf-8',
|
||||||
headers: {
|
headers: {
|
||||||
'x-csrf-token': config.csrf_token,
|
'x-csrf-token': config.csrf_token,
|
||||||
},
|
},
|
||||||
@@ -64,7 +65,8 @@ define('api', () => {
|
|||||||
api.put = (route, payload, onSuccess) => call({
|
api.put = (route, payload, onSuccess) => call({
|
||||||
url: route,
|
url: route,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: payload,
|
data: JSON.stringify(payload),
|
||||||
|
contentType: 'application/json; charset=utf-8',
|
||||||
headers: {
|
headers: {
|
||||||
'x-csrf-token': config.csrf_token,
|
'x-csrf-token': config.csrf_token,
|
||||||
},
|
},
|
||||||
@@ -73,7 +75,8 @@ define('api', () => {
|
|||||||
api.del = (route, payload, onSuccess) => call({
|
api.del = (route, payload, onSuccess) => call({
|
||||||
url: route,
|
url: route,
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
data: payload,
|
data: JSON.stringify(payload),
|
||||||
|
contentType: 'application/json; charset=utf-8',
|
||||||
headers: {
|
headers: {
|
||||||
'x-csrf-token': config.csrf_token,
|
'x-csrf-token': config.csrf_token,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -95,10 +95,6 @@ nconf.argv(opts).env({
|
|||||||
separator: '__',
|
separator: '__',
|
||||||
});
|
});
|
||||||
|
|
||||||
const env = program.dev ? 'development' : (process.env.NODE_ENV || 'production');
|
|
||||||
process.env.NODE_ENV = env;
|
|
||||||
global.env = env;
|
|
||||||
|
|
||||||
prestart.setupWinston();
|
prestart.setupWinston();
|
||||||
|
|
||||||
// Alternate configuration file support
|
// Alternate configuration file support
|
||||||
@@ -197,6 +193,10 @@ program
|
|||||||
.description(`Compile static assets ${'(JS, CSS, templates, languages)'.red}`)
|
.description(`Compile static assets ${'(JS, CSS, templates, languages)'.red}`)
|
||||||
.option('-s, --series', 'Run builds in series without extra processes')
|
.option('-s, --series', 'Run builds in series without extra processes')
|
||||||
.action((targets, options) => {
|
.action((targets, options) => {
|
||||||
|
if (program.dev) {
|
||||||
|
process.env.NODE_ENV = 'development';
|
||||||
|
global.env = 'development';
|
||||||
|
}
|
||||||
require('./manage').build(targets.length ? targets : true, options);
|
require('./manage').build(targets.length ? targets : true, options);
|
||||||
})
|
})
|
||||||
.on('--help', () => {
|
.on('--help', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user