Ver Fonte

Added basic API file that integrates with express

theflametrooper há 8 anos atrás
pai
commit
f49c025de1
3 ficheiros alterados com 20 adições e 6 exclusões
  1. 1 1
      backend/index.js
  2. 11 0
      backend/logic/api.js
  3. 8 5
      backend/logic/app.js

+ 1 - 1
backend/index.js

@@ -31,7 +31,7 @@ async.waterfall([
 	// setup our MongoDB database
 	(next) => db.init(config.get("mongo").url, next),
 
-	// setup the express server (not used right now, but may be used for OAuth stuff later, or for an API)
+	// setup the express server
 	(next) => app.init(next),
 
 	// setup the socket.io server (all client / server communication is done over this)

+ 11 - 0
backend/logic/api.js

@@ -0,0 +1,11 @@
+module.exports = (app) => {
+	'use strict';
+
+	app.get('/', (req, res) => {
+		res.json({
+			status: 'success',
+			message: 'Coming Soon'
+		});
+	});
+
+}

+ 8 - 5
backend/logic/app.js

@@ -1,18 +1,17 @@
 'use strict';
 
-// This file contains all the logic for Express
-
 const express = require('express');
 const bodyParser = require('body-parser');
 const cors = require('cors');
 const config = require('config');
 const request = require('request');
-const cache = require('./cache');
-const db = require('./db');
-let utils;
 const OAuth2 = require('oauth').OAuth2;
 
+const api = require('./api');
+const cache = require('./cache');
+const db = require('./db');
 
+let utils;
 
 const lib = {
 
@@ -35,6 +34,8 @@ const lib = {
 		app.use(cors(corsOptions));
 		app.options('*', cors(corsOptions));
 
+		api(app);
+
 		let oauth2 = new OAuth2(
 			config.get('apis.github.client'),
 			config.get('apis.github.secret'),
@@ -134,6 +135,8 @@ const lib = {
 		});
 
 		cb();
+
+
 	}
 };