-
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.
backend: no cors headers being set; relying in reverse-proxy to do that
- Loading branch information
1 parent
aaf0260
commit 90ddd6b
Showing
2 changed files
with
28 additions
and
18 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,45 @@ | ||
import cors from 'cors'; | ||
import express from 'express'; | ||
import { ScenarioAPIConfig, addScenarioApi } from './scenarios/scenario.interface'; | ||
import { | ||
ScenarioAPIConfig, | ||
addScenarioApi, | ||
} from './scenarios/scenario.interface'; | ||
// import { parseCode } from './parser/scenarioParser'; | ||
import { peruFactory } from './usr/peru/peru'; | ||
import { peruShortFactory } from './usr/peru_short/peru'; | ||
import { peruCachedFactory } from './usr/peru_cached/peru'; | ||
import config from './config.json'; | ||
import { chileFactory } from './usr/chile/chile'; | ||
import { chileShortFactory } from './usr/chile_short/chileShort'; | ||
import { chileCachedFactory } from './usr/chile_cached/chile'; | ||
import { chileShortFactory } from './usr/chile_short/chileShort'; | ||
import { ecuadorFactory } from './usr/ecuador/ecuador'; | ||
import config from "./config.json"; | ||
|
||
|
||
import { peruFactory } from './usr/peru/peru'; | ||
import { peruCachedFactory } from './usr/peru_cached/peru'; | ||
import { peruShortFactory } from './usr/peru_short/peru'; | ||
|
||
const port = config.port; | ||
|
||
const configuration: ScenarioAPIConfig = { | ||
logDir: config.logDir, | ||
storeDir: config.storeDir, | ||
maxStoreLifeTimeMinutes: parseInt(config.maxStoreLifeTimeMinutes), | ||
sender: config.sender || "[email protected]", | ||
sendMailTo: config.sendMailTo.split(","), | ||
sender: config.sender || '[email protected]', | ||
sendMailTo: config.sendMailTo.split(','), | ||
maxLogAgeMinutes: parseInt(config.maxLogAgeMinutes), | ||
verbosity: config.verbosity === "silent" ? "silent" : "verbose" | ||
} | ||
verbosity: config.verbosity === 'silent' ? 'silent' : 'verbose', | ||
}; | ||
|
||
async function main() { | ||
// Setting up express | ||
const app = express(); | ||
app.use(cors()); | ||
// app.use(cors()); <-- not necessary; already done by reverse proxy | ||
|
||
// const scenarioFactories = await parseCode(scriptDir); | ||
const scenarioFactories = [chileFactory, chileShortFactory, chileCachedFactory, ecuadorFactory, peruFactory, peruShortFactory, peruCachedFactory]; | ||
const scenarioFactories = [ | ||
chileFactory, | ||
chileShortFactory, | ||
chileCachedFactory, | ||
ecuadorFactory, | ||
peruFactory, | ||
peruShortFactory, | ||
peruCachedFactory, | ||
]; | ||
|
||
// Checking that all scenarios are ready | ||
// for (const factory of scenarioFactories) { | ||
|
@@ -47,7 +55,9 @@ async function main() { | |
|
||
// Adding API-endpoints to express app | ||
addScenarioApi(app, scenarioFactories, configuration); | ||
const server = app.listen(port, () => console.log(`app now listening on port ${port}`)); | ||
const server = app.listen(port, () => | ||
console.log(`app now listening on port ${port}`) | ||
); | ||
} | ||
|
||
main(); |
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