-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
9 changed files
with
88 additions
and
46 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"appEnv": "dev", | ||
"appName": "AccessApi", | ||
"contentRoot": "http://localhost:3402", | ||
"fileStore": "disk", | ||
"mailSystem": "SMTP", | ||
"s3Bucket": "" | ||
} |
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,8 @@ | ||
{ | ||
"appEnv": "prod", | ||
"appName": "AccessApi", | ||
"contentRoot": "https://content.churchapps.org", | ||
"fileStore": "S3", | ||
"mailSystem": "SES", | ||
"s3Bucket": "churchapps-content" | ||
} |
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,8 @@ | ||
{ | ||
"appEnv": "staging", | ||
"appName": "AccessApi", | ||
"contentRoot": "https://content.staging.churchapps.org", | ||
"fileStore": "S3", | ||
"mailSystem": "SES", | ||
"s3Bucket": "staging-churchapps-content" | ||
} |
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,15 +1,5 @@ | ||
# Modify and save this file as ".env" | ||
API_ENV=dev | ||
APP_NAME=AttendanceApi | ||
|
||
# Node.js server configuration | ||
APP_ENV=dev | ||
CONNECTION_STRING=mysql:// | ||
ENCRYPTION_KEY=encryptionKey | ||
JWT_SECRET=this is a test key that is a sentence | ||
SERVER_PORT=8085 | ||
|
||
# MySql configuration | ||
DB_HOST=localhost | ||
DB_DATABASE=attendance | ||
DB_USER=root | ||
DB_PASSWORD= | ||
|
||
JWT_SECRET_KEY=this is a test key that is a sentence | ||
JWT_EXPIRATION=2 days |
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,13 +1,15 @@ | ||
const { createServer, proxy } = require('aws-serverless-express'); | ||
const { init } = require('./dist/App'); | ||
const { Pool } = require('./dist/apiBase/pool'); | ||
const { Environment } = require('./dist/helpers/Environment'); | ||
|
||
Environment.init(process.env.APP_ENV); | ||
Pool.initPool(); | ||
|
||
module.exports.universal = function universal(event, context) { | ||
init().then(app => { | ||
const server = createServer(app); | ||
return proxy(server, event, context); | ||
}); | ||
init().then(app => { | ||
const server = createServer(app); | ||
return proxy(server, event, context); | ||
}); | ||
|
||
} |
Submodule apiBase
updated
from 05af8c to 7a7316
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,22 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
import { EnvironmentBase } from "../apiBase"; | ||
|
||
export class Environment extends EnvironmentBase { | ||
|
||
static init(environment: string) { | ||
let file = "dev.json"; | ||
if (environment === "staging") file = "staging.json"; | ||
if (environment === "prod") file = "prod.json"; | ||
|
||
|
||
const relativePath = "../../config/" + file; | ||
const physicalPath = path.resolve(__dirname, relativePath); | ||
|
||
const json = fs.readFileSync(physicalPath, "utf8"); | ||
const data = JSON.parse(json); | ||
this.populateBase(data); | ||
} | ||
|
||
} |
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,13 @@ | ||
import { init } from "./App"; | ||
import { Pool } from "./apiBase/pool"; | ||
const port = process.env.SERVER_PORT; | ||
import { Environment } from './helpers/Environment'; | ||
|
||
const port = process.env.SERVER_PORT; | ||
Environment.init(process.env.APP_ENV); | ||
Pool.initPool(); | ||
|
||
init().then(app => { | ||
app.listen(port, () => { | ||
console.log(`Server running at http://localhost:${port}/`); | ||
}); | ||
app.listen(port, () => { | ||
console.log(`Server running at http://localhost:${port}/`); | ||
}); | ||
}); |
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,39 @@ | ||
import dotenv from "dotenv"; | ||
import { Environment } from "../src/helpers/Environment"; | ||
import { Pool } from "../src/apiBase/pool"; | ||
import { DBCreator } from "../src/apiBase/tools/DBCreator" | ||
|
||
const init = async () => { | ||
dotenv.config(); | ||
console.log("Connecting"); | ||
Pool.initPool(); | ||
dotenv.config(); | ||
Environment.init(process.env.APP_ENV); | ||
console.log("Connecting"); | ||
Pool.initPool(); | ||
|
||
const attendanceTables: { title: string, file: string }[] = [ | ||
{ title: "Campuses", file: "campuses.mysql" }, | ||
{ title: "Services", file: "services.mysql" }, | ||
{ title: "Service Times", file: "serviceTimes.mysql" }, | ||
{ title: "Group Service Times", file: "groupServiceTimes.mysql" }, | ||
{ title: "Sessions", file: "sessions.mysql" }, | ||
{ title: "Visits", file: "visits.mysql" }, | ||
{ title: "Visit Sessions", file: "visitSessions.mysql" } | ||
]; | ||
const attendanceTables: { title: string, file: string }[] = [ | ||
{ title: "Campuses", file: "campuses.mysql" }, | ||
{ title: "Services", file: "services.mysql" }, | ||
{ title: "Service Times", file: "serviceTimes.mysql" }, | ||
{ title: "Group Service Times", file: "groupServiceTimes.mysql" }, | ||
{ title: "Sessions", file: "sessions.mysql" }, | ||
{ title: "Visits", file: "visits.mysql" }, | ||
{ title: "Visit Sessions", file: "visitSessions.mysql" } | ||
]; | ||
|
||
await DBCreator.init(["Settings"]); | ||
await initTables("Attendance", attendanceTables); | ||
await DBCreator.init(["Settings"]); | ||
await initTables("Attendance", attendanceTables); | ||
} | ||
|
||
const initTables = async (displayName: string, tables: { title: string, file: string }[]) => { | ||
console.log(""); | ||
console.log("SECTION: " + displayName); | ||
for (const table of tables) await DBCreator.runScript(table.title, "./tools/dbScripts/" + table.file, false); | ||
console.log(""); | ||
console.log("SECTION: " + displayName); | ||
for (const table of tables) await DBCreator.runScript(table.title, "./tools/dbScripts/" + table.file, false); | ||
} | ||
|
||
init() | ||
.then(() => { console.log("Database Created"); process.exit(0); }) | ||
.catch((ex) => { | ||
console.log(ex); | ||
console.log("Database not created due to errors"); | ||
process.exit(0); | ||
}); | ||
.then(() => { console.log("Database Created"); process.exit(0); }) | ||
.catch((ex) => { | ||
console.log(ex); | ||
console.log("Database not created due to errors"); | ||
process.exit(0); | ||
}); | ||
|