mma-gpacts-app/index.js
2020-04-04 15:50:15 -07:00

35 lines
1016 B
JavaScript

'use strict';
const express = require('express')
// ----------------------------------------------------------------------
var config = require('./config.js');
var auth = require('./auth.js');
var tasks = require('./tasks.js');
var app = express();
// ----------------------------------------------------------------------
// Routes:
// - Home page
app.get('/', (req, res) => tasks.home_page(req, res));
// - Redirect for OAuth
app.get('/redirect', (req, res) => auth.redirect(req, res));
// - Authenticated routes
app.get('/tiny', (req, res) => auth.run(req, res, tasks.tiny_photos));
// - Assets
app.get('/favicon.ico', (req, res) => res.sendStatus(204));
// - Default (404)
app.get('*', (req, res) => tasks.not_found(req, res));
// ----------------------------------------------------------------------
// Launch App
app.listen(config.port, () => console.log(`${config.app_name} running on port ${config.port}!`))
// vim: ai ts=4 sts=4 et sw=4 ft=javascript