-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix tests; comment out unimplemented actions
- Loading branch information
Showing
4 changed files
with
40 additions
and
33 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,60 +1,67 @@ | ||
'use strict'; | ||
"use strict"; | ||
|
||
// express.js framework | ||
const express = require("express"); | ||
const app = express(); | ||
|
||
// parsing post bodies | ||
const bodyParser = require('body-parser'); | ||
const bodyParser = require("body-parser"); | ||
app.use(bodyParser.urlencoded({ extended: true })); | ||
app.use(bodyParser.json()); | ||
|
||
// cors - make server endpoints available on firebase domain | ||
const cors = require('cors') | ||
const cors = require("cors"); | ||
let corsOptions = { | ||
origin: 'https://attendancescannerqr.web.app', | ||
} | ||
app.use(cors(corsOptions)) | ||
origin: "https://attendancescannerqr.web.app", | ||
}; | ||
app.use(cors(corsOptions)); | ||
|
||
// ============================ PUBLIC (STATIC) FILES ============================ | ||
// http://expressjs.com/en/starter/static-files.html | ||
app.use(express.static("public")); | ||
|
||
// ============================ DATABASE ============================ | ||
const schemaFile = "./server/databaseSchema.sql"; // filepath for the database schema | ||
module.exports.initPromise = require('./Database').reinitializeIfNotExists(process.env.DB_FILE, schemaFile); | ||
module.exports.initPromise = require("./Database").reinitializeIfNotExists( | ||
process.env.DB_FILE, | ||
schemaFile | ||
); | ||
|
||
// ============================ SUPER ADMIN ============================ | ||
// for modifying and viewing database contents without manually running SQL commands | ||
// go to http://localhost:3000/super_admin/ to view | ||
module.exports.initPromise.then(() => { | ||
const { superAdminRouter } = require('./SuperAdmin'); | ||
app.use('/super_admin', superAdminRouter); | ||
}); | ||
if (process.env.DB_FILE != ":memory:") { | ||
module.exports.initPromise.then(() => { | ||
const { superAdminRouter } = require("./SuperAdmin"); | ||
app.use("/super_admin", superAdminRouter); | ||
}); | ||
} | ||
|
||
// ============================ AUTHENTICATION ============================ | ||
const { authRouter } = require('./Auth'); | ||
app.use('/', authRouter); | ||
const { authRouter } = require("./Auth"); | ||
app.use("/", authRouter); | ||
|
||
// ============================ PAYMENT ============================ | ||
const { paymentRouter } = require('./Payment'); | ||
app.use('/', paymentRouter); | ||
const { paymentRouter } = require("./Payment"); | ||
app.use("/", paymentRouter); | ||
|
||
// ============================ BUSINESS ============================ | ||
const { businessRouter } = require('./Business'); | ||
app.use('/', businessRouter); | ||
const { businessRouter } = require("./Business"); | ||
app.use("/", businessRouter); | ||
|
||
// ============================ ATTENDANCE ============================ | ||
const { attendanceRouter } = require('./Attendance'); | ||
app.use('/', attendanceRouter); | ||
const { attendanceRouter } = require("./Attendance"); | ||
app.use("/", attendanceRouter); | ||
|
||
// ============================ EVENTS ============================ | ||
const { eventRouter } = require('./Event'); | ||
app.use('/', eventRouter); | ||
const { eventRouter } = require("./Event"); | ||
app.use("/", eventRouter); | ||
|
||
// ============================ SERVER ============================ | ||
// listen for requests :) | ||
module.exports.app = app; | ||
module.exports.listener = app.listen(process.env.PORT, () => { | ||
console.log(`Your app is listening on port ${module.exports.listener.address().port}`); | ||
}); | ||
console.log( | ||
`Your app is listening on port ${module.exports.listener.address().port}` | ||
); | ||
}); |