2019-09-06 12:25:50 +02:00
|
|
|
const config = require('./config');
|
|
|
|
const server = require('./server');
|
|
|
|
const express = require('express');
|
|
|
|
const app = express();
|
2019-09-24 15:08:03 +02:00
|
|
|
const bodyParser = require('body-parser');
|
2019-09-06 12:25:50 +02:00
|
|
|
const http = require('http');
|
|
|
|
|
2019-09-24 15:08:03 +02:00
|
|
|
var options = { //todo: maybe be more specific here
|
|
|
|
type: "application/*"
|
|
|
|
};
|
|
|
|
|
|
|
|
app.use(bodyParser.raw(options));
|
|
|
|
app.use(bodyParser.urlencoded({extended: true}));
|
|
|
|
|
2019-09-06 12:25:50 +02:00
|
|
|
app.set('domain', config.DOMAIN);
|
|
|
|
app.set('port', process.env.PORT || config.PORT || 3000);
|
|
|
|
app.set('port-https', process.env.PORT_HTTPS || 8443);
|
|
|
|
|
|
|
|
app.get('/', (req, res) => res.send('Hello World!'));
|
|
|
|
app.get('/u/:name', server.get_user);
|
|
|
|
app.get('/.well-known/webfinger', server.get_webfinger);
|
|
|
|
app.get('/inbox', (req, res) => res.send('Here lies the inbox'));
|
2019-09-24 15:08:03 +02:00
|
|
|
app.get('/users', server.get_users);
|
|
|
|
|
|
|
|
app.post('/inbox', server.post_inbox);
|
2019-09-06 12:25:50 +02:00
|
|
|
|
2019-09-24 15:08:03 +02:00
|
|
|
http.createServer(app).listen(app.get('port'), function () {
|
2019-09-06 12:25:50 +02:00
|
|
|
console.log('Express server listening on port ' + app.get('port'));
|
|
|
|
});
|