How to create a app in Bitnami parse-server - push-notification

I have hosted Bitnami parse server in AWS as a HTTP service. I am unable to create a new app in the parse server through its dashboard. I also tried a 1 hour demo with Bitnami parse-server in that demo also I am unable to create a new app. How to do this?
https://bitnami.com/stack/parse
I am unable to achieve this through REST API also. Because the demo site doesn't required a credentials to login. The /1/apps API call requires a email/password to create an app.
How to create a app in this demo site?

Bitnami developer here,
Unfortunately, you can not create a new app using a demo site. Note that this app would serve another API. For that, you need to access via SSH and edit the /opt/bitnami/apps/parse/htdocs/server.js file. For instance, you could have 2 apps with the code below:
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
//API 1
var api1 = new ParseServer({
databaseURI: "mongodb://root:password#127.0.0.1:27017/bitnami_parse1",
cloud: "./node_modules/parse-server/lib/cloud-code/Parse.Cloud.js",
appId: "myappid1",
masterKey: "mymasterkey1",
fileKey: "myfilekey1",
serverURL: 'http://X.X.X.X:80/parse1'
});
app.use('/parse1', api1);
//API 2
var api2 = new ParseServer({
databaseURI: "mongodb://root:password#127.0.0.1:27017/bitnami_parse",
cloud: "./node_modules/parse-server/lib/cloud-code/Parse.Cloud.js",
appId: "myappid2",
masterKey: "mymasterkey2",
fileKey: "myfilekey2",
serverURL: 'http://X.X.X.X:80/parse2'
});
app.use('/parse2', api2);
var port = 1337;
app.listen(port, function() {
console.log('parse-server running on port ' + port);
});
//Parse Dashboard
var ParseDashboard = require('parse-dashboard');
var dashboard = new ParseDashboard({
apps: [
{
appName: "myapp1",
appId: 'myappid1',
masterKey: 'mymasterkey1',
fileKey: 'myfilekey1',
production: true,
serverURL: 'http://X.X.X.X:80/parse1'
}
,
{
appName: "myapp2",
appId: 'myappid2',
masterKey: 'mymasterkey2',
fileKey: 'myfilekey2',
production: true,
serverURL: 'http://X.X.X.X:80/parse2'
}
]
,
"users": [
{
"user":"user",
"pass":"password"
}
]
});
app.use('/', dashboard);
var portdash = 4040;
app.listen(portdash, function() {
console.log('parse-dashboard running on port ' + portdash);
});
Then, you would need to add the lines below to your /opt/bitnami/apps/parse/conf/httpd-app.conf to set the Apache ProxyPass configuration:
ProxyPass /parse1 http://127.0.0.1:1337/parse1
ProxyPassReverse /parse1 http://127.0.0.1:1337/parse1
ProxyPass /parse2 http://127.0.0.1:1337/parse2
ProxyPassReverse /parse2 http://127.0.0.1:1337/parse2
and then restart the services executing:
$ sudo /opt/bitnami/ctlscript.sh restart
I hope you find it useful.

Related

Next Auth doesn't work with custom basePath

My NextAuth are returning 404 when searching for api/auth/session at credential provider custom login, seems like Next Auth are pointing to the wrong url.
My next.config.js have a basePath that points to a subfolder basePath: '/twenty-test' and my NEXTAUTH_URL is already set to my subdomain,
but when I go to my credential provider login custom page (that was working at localhost because it was not at a subdomain), i see an 404 error at console like https://explample.com/api/auth/session 404.
This is my custom provider config:
providers: [
CredentialProvider({
name: 'Credentials',
type: 'credentials',
async authorize(credentials) {
//
if(credentials.email == "john#gmail.com" && credentials.password == "test"){
return {
id: 2,
name: 'John Doe',
email: 'john#gmail.com',
permition: {
group: 2,
level: 0
}
}
}
return null;
}
})
],
This is my next.config.js
const nextConfig = {
reactStrictMode: true,
basePath: '/twenty-test',
images: {
domains: ['example.com'],
},
}
module.exports = nextConfig
This is my NEXTAUTH_URL env variable
NEXTAUTH_URL="https://example.com/twenty-test/api/auth"
This is my getCsrfToken config
export async function getServerSideProps(context) {
return {
props: {
csrfToken: await getCsrfToken(context)
}
}
}
My project are not on vercel. I'm using a custom server config to deploy with cPanel
The problem was on building the app in localhost and deploying on server.
The app was building expecting NEXTAUTH_URL as localhost, and simply changing the .env variable on server didnt worked.
The solution was building the app on server.
Another workaround was replacing the localhost NEXTAUTH_URL ocurrences after building with the value of NEXTAUTH_URL on server.

How to create http and https server in nodejs?

This is the code I used to connect http server.
var app = require('http').createServer(require('express')),
io = require('socket.io').listen(app),
util = require('util'),
connectionsArray = [], // maintain active connected client details
connectionStatistics = {'summary': {'instance_count': 0, 'user_count': 0, 'customer_count': 0}, 'customers': {}}, // for debugging purpose
server_port = 3000, // port on which nodejs engine to run
POLLING_INTERVAL = 10 * 1000, // 10 sec
pollingTimer = [], // timeouts for connected sockets
fs = require('fs'), // lib for file related operations
log_file = {
'error': fs.createWriteStream(__dirname + '/debug.log', {flags: 'a'}), // file to log error messages
'info': fs.createWriteStream(__dirname + '/info.log', {flags: 'a'}) // file to log info messages
};
var server = app.listen(server_port, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Please use your browser to navigate to http://%s:%s', host, port);
});
I want to include https connection in the above code.
I tried to connect https using SSLCertificateFile and SSLCertificateKeyFile.
But it didn't work for me.
install https module ( yarn add https / npm i https )
change options (ssl file path) as below :
const options = {
key: fs.readFileSync('./ssl/private.key'),
cert: fs.readFileSync('./ssl/certificate.crt'),
ca:fs.readFileSync('./ssl/ca_bundle.crt')
}
https.createServer(options, app).listen(port);
Try this snippet using express and https module instead of http
let fs = require('fs');
let https = require('https');
let express = require('express');
let app = express();
let options = {
key: fs.readFileSync('./file.pem'),
cert: fs.readFileSync('./file.crt')
};
let serverPort = 3000;
let server = https.createServer(options, app);
let io = require('socket.io')(server);
io.on('connection', function(socket) {
console.log('new connection');
});
server.listen(serverPort, function() {
console.log('server up and running at %s port', serverPort);
});

nodejs express loads .css file correctly in localhost but fail at live plesk webserver

The Problem
I have a simple Nodejs Express Hello_World application up and running both locally and on a live server using Plesk-Onyx17.8.11. The app runs correctly on localhost:3000 in my browser:
But after I push the files to the server (using a Filezilla ftp client), my browser can't load the files in the public folder, so it won't load the CSS file:
As you can see the file http://shamimkeshani.ir/stylesheets/style.css cannot be downloaded. This is the correct URL, because we use app.use(express.static(path.join(__dirname, '/public'))); in the Express app. But hypothetically if we insert a wrong URL file of http://shamimkeshani.ir/public/stylesheets/style.css it would find the file and download it correctly from shamimkeshani.ir, which is not the correct behavior! Also, this will not work locally which is the right behavior!!
The codes
I used express-generator to create the default Hello_World Express application. The app.js file:
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
console.log(__dirname);
app.use(express.static(path.join(__dirname, '/public')));
app.use('/', indexRouter);
app.use('/users', usersRouter);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
next(createError(404));
});
// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
res.status(err.status || 500);
res.render('error');
});
module.exports = app;
I use a server.js file to run the Nodejs application. This file is actually a copy of ./bin/www file that Express uses. I use npm start which runs this file locally. Also, the server.js file is set in the Plesk for starting the application on the server:
#!/usr/bin/env node
/**
* Module dependencies.
*/
var app = require('./app');
var debug = require('debug')('app:server');
var http = require('http');
/**
* Get port from environment and store in Express.
*/
var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
/**
* Create HTTP server.
*/
var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
/**
* Normalize a port into a number, string, or false.
*/
function normalizePort(val) {
var port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
return val;
}
if (port >= 0) {
// port number
return port;
}
return false;
}
/**
* Event listener for HTTP server "error" event.
*/
function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}
var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}
/**
* Event listener for HTTP server "listening" event.
*/
function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
package.json file:
{
"name": "app",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./server.js"
},
"dependencies": {
"cookie-parser": "~1.4.3",
"debug": "~2.6.9",
"express": "~4.16.0",
"http-errors": "~1.6.2",
"morgan": "~1.9.0",
"pug": "2.0.0-beta11"
}
}
I also checked the Nodejs versions running locally and at the server and they both match (10.1.0).
I searched a lot and couldn't figure out how to solve this problem. I want for my Nodejs application to work the same locally and on the server. Any additional thoughts on the future problems that I may encounter and any further suggestions are appreciated. Thanks.

How to use webpack combine angular2 with existing spring boot server

I want the existing spring boot gateway as the backend server, instead of the angular 2 .
that is i want the angular2 combines to the spring gateway .
Assume :
the angular 2 webpack-dev-server on port 8090 , and there is a
page index.html
spring boot gateway on port 8080: and all the api .
I want to open
localhost:8080
to see the angular2 index.html ,
how to implement ?
You need to set up proxy for your backend. I know that webpack-dev-server based on Express. So, I can give you a clue how to run it with Express:
var express = require('express');
var request = require('request');
var path = require('path');
var app = express();
app.use('/api', function(req, res) {
var url = 'http://localhost:8080/api' + req.url;
req.pipe(request(url)).pipe(res);
});
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
});
/* serves all the static files */
app.get(/^(.+)$/, function(req, res){
res.sendFile( __dirname + req.params[0]);
});
app.listen(8090);
Then you refer to backend API by /api/entry-point .
#Injectable()
export class HttpProductDiscountService {
constructor(private _http: Http) {}
getProductDiscounts() {
return this._http.get('api/1.0/product-discount')
.map(res => res.json())
}
}
I have found an example of an implementation ,
front is : https://github.com/springboot-angular2-tutorial/angular2-app
and spring-server is : https://github.com/springboot-angular2-tutorial/boot-app ,
Reference to this example , I have successfully build a simplify
demo .

Pusher Authentication with Meteor

Is there a way to setup pusher authentication for private channels using Meteor? I looked in Atmosphere for a pusher package and didn't see one.
After some digging the solution I found was not very difficult to implement. Here are the steps.
mrt add npm
Add "pusher": "0.1.3" to packages.json
Add the following code block to a file INSIDE the server directory of your project. Be sure to change the appId, key, and secret to be the correct ones for your app.
if (Meteor.isServer) {
var Pusher = Meteor.require('pusher');
var pusher = new Pusher( { appId: '12345', key: 'keytext', secret: 'secrettext' } );
Meteor.Router.add('/pusher/auth','POST', function(){
var req = this.request;
var res = this.response;
var socketId = req.body.socket_id;
var channel = req.body.channel_name;
var auth = pusher.auth( socketId, channel );
res.write(JSON.stringify(auth));
})
}

Resources