-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
69 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
require('dotenv').config() | ||
const env = process.env.NODE_ENV || 'development' | ||
require("dotenv").config(); | ||
const env = process.env ?? process.secrets; | ||
const mode = env.NODE_ENV || "development"; | ||
|
||
// common environmental variables for all environments | ||
const common = { | ||
PORT: process.env.PORT || 3600, | ||
GIPHY_API_KEY: 'dqp8GYkt1VqBk7GjiuKUYj4QdbJS4phJ', | ||
} | ||
PORT: env.PORT || 3600, | ||
GIPHY_API_KEY: env.GIPHY_API_KEY, | ||
}; | ||
|
||
// environmental variables for development | ||
const development = { | ||
NODE_ENV: 'development', | ||
DB_URI: 'mongodb://localhost:27017/hobbes', | ||
NODE_ENV: "development", | ||
DB_URI: "mongodb://localhost:27017/hobbes", | ||
...common, | ||
} | ||
}; | ||
|
||
// environmental variables for production | ||
const production = { | ||
NODE_ENV: 'production', | ||
DB_URI: process.env.DB_URI, | ||
NODE_ENV: "production", | ||
DB_URI: env.DB_URI, | ||
...common, | ||
} | ||
}; | ||
|
||
// environmental variables for testing | ||
const test = { | ||
NODE_ENV: 'test', | ||
DB_URI: 'mongodb://localhost:27017/hobbes_test', | ||
NODE_ENV: "test", | ||
DB_URI: "mongodb://localhost:27017/hobbes_test", | ||
...common, | ||
} | ||
}; | ||
|
||
const config = { | ||
development, | ||
production, | ||
test, | ||
} | ||
}; | ||
|
||
module.exports = config[env] | ||
module.exports = config[mode]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
const response = require('../utils/response') | ||
const response = require("../utils/response"); | ||
|
||
class PluginInfoController { | ||
async getInfo(req, res) { | ||
const info = `The company online tools plugin is a feature which allows users to interact with third party tools like Google Drive, Figma, Github, etc. to make work flow for themselves or their team faster and easier. | ||
All our tools are external applications that you may have used or heard of but to maximize productivity, we are giving you access to some of their awesome features right in Zuri Chat.` | ||
All our tools are external applications that you may have used or heard of but to maximize productivity, we are giving you access to some of their awesome features right in Zuri Chat.`; | ||
|
||
res.send(response('Plugin Info returned successfully', info)) | ||
res.send(response("Plugin Info returned successfully", info)); | ||
} | ||
} | ||
|
||
module.exports = new PluginInfoController() | ||
module.exports = new PluginInfoController(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const response = require("../utils/response"); | ||
|
||
class SidebarController { | ||
async getSideBarEndpoints(req, res) { | ||
const endpoints = ["/gmail", "github", "figma", "google-drive", "giphy"]; | ||
|
||
res.send( | ||
response( | ||
"Sidebar endpoints for Online Tools returned successfully", | ||
endpoints | ||
) | ||
); | ||
} | ||
} | ||
|
||
module.exports = new SidebarController(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
const router = require('express').Router() | ||
const giphy = require('../controllers/giphy') | ||
const router = require("express").Router(); | ||
const giphy = require("../controllers/giphy"); | ||
|
||
module.exports = function () { | ||
router.get('/random', giphy.randomGif) | ||
router.get("/giphy/random", giphy.randomGif); | ||
|
||
router.get('/trending', giphy.trendingGifs) | ||
router.get("/giphy/trending", giphy.trendingGifs); | ||
|
||
return router | ||
} | ||
return router; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
const router = require('express').Router() | ||
const pluginInfoRouter = require('./plugin-info') | ||
const giphy = require('./giphy') | ||
const router = require("express").Router(); | ||
const pluginInfoRouter = require("./plugin-info"); | ||
const googleDriveApi = require("./googledrive"); | ||
const sideBarRouter = require("./sidebar"); | ||
const giphy = require("./giphy"); | ||
|
||
module.exports = () => { | ||
router.use('/giphy', giphy()) | ||
router.use(pluginInfoRouter()) | ||
router.use('/googledrive',googleDriveApi()); | ||
return router | ||
} | ||
router.use(pluginInfoRouter()); | ||
router.use(googleDriveApi()); | ||
router.use(sideBarRouter()); | ||
router.use(giphy()); | ||
|
||
// Handle Invalid API routes | ||
router.use((req, res, next) => { | ||
next(new NotFoundError()); | ||
}); | ||
|
||
return router; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const router = require("express").Router(); | ||
|
||
const sideBarController = require("../controllers/sidebar"); | ||
|
||
module.exports = function () { | ||
router.get("/sidebar", sideBarController.getSideBarEndpoints); | ||
|
||
return router; | ||
}; |